Re: [PATCH] fsl-dma: allow Freescale Elo DMA driver to be compiledas a module

From: Timur Tabi
Date: Mon Sep 22 2008 - 17:00:27 EST


Dan Williams wrote:

> The last three hunks should be broken out into a separate 'fix' patch
> with its own changelog.

Can you be more specific? I can see how "return 0" -> "return -ENOMEM" could be
separated out, but the Kconfig hunk is integral to the patch, and the "if
(fsl_chan->desc_pool) return 1;" is needed to prevent a memory leak if the
module is unloaded.

>> -static __init int of_fsl_dma_chan_init(void)
>> +static void fsl_dma_chan_remove(struct fsl_dma_chan *fchan)
>> {
>> - return of_register_platform_driver(&of_fsl_dma_chan_driver);
>> + if (fchan) {
>> + of_device_unregister(fchan->of_dev);
>> +
>> + free_irq(fchan->irq, fchan);
>> + list_del(&fchan->common.device_node);
>> + iounmap(fchan->reg_base);
>> + kfree(fchan);
>> + }
>> }
>
> removing a NULL fchan should be an error right?

No, this is a side-effect of not using a linked-list to store the channels found
by the driver. The driver has a 4-element array to store the channel info.
Normally, all four channels are defined in the OF device tree, so all four
elements are defined. But it's not a requirement, so in those cases, the
non-defined channels will have NULL for fchan.

I have plans to replace the array with a linked list. This change will fix a
few other minor problems with the driver.

> Perhaps move the
> check up to of_fsl_dma_remove().

I can do that.

--
Timur Tabi
Linux kernel developer at Freescale
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/