On Tue, Oct 15, 2013 at 11:19:57AM +0530, Pekon Gupta wrote: > "Managed Device Resource" or devm_xx calls takes care of automatic freeing > of the resource in case of: > - failure during driver probe > - failure during resource allocation > - detaching or unloading of driver module (rmmod) > Reference: Documentation/driver-model/devres.txt > > Though OMAP NAND driver handles freeing of resource allocation in most of > the cases, but using devm_xx provides more clean and effortless approach > to handle all such cases. > > Signed-off-by: Pekon Gupta <pekon@xxxxxx> > --- > drivers/mtd/nand/omap2.c | 44 ++++++++++++++------------------------------ > 1 file changed, 14 insertions(+), 30 deletions(-) > > diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c > index 769ff65..0ed0d6f 100644 > --- a/drivers/mtd/nand/omap2.c > +++ b/drivers/mtd/nand/omap2.c [...] > @@ -1796,8 +1799,9 @@ static int omap_nand_probe(struct platform_device *pdev) > err = -ENODEV; > goto out_release_mem_region; > } > - err = request_irq(info->gpmc_irq_count, omap_nand_irq, > - IRQF_SHARED, "gpmc-nand-count", info); > + err = devm_request_irq(&pdev->dev, info->gpmc_irq_count, > + omap_nand_irq, IRQF_SHARED, > + "gpmc-nand-count", info); > if (err) { > dev_err(&pdev->dev, "requesting irq(%d) error:%d", > info->gpmc_irq_count, err); > @@ -2010,45 +2014,25 @@ static int omap_nand_probe(struct platform_device *pdev) > out_release_mem_region: Now that you've simplified this error path, you don't need so verbose of a name (it could just be 'out'), but that's not worth another revision. > if (info->dma) > dma_release_channel(info->dma); > - if (info->gpmc_irq_count > 0) > - free_irq(info->gpmc_irq_count, info); > - if (info->gpmc_irq_fifo > 0) > - free_irq(info->gpmc_irq_fifo, info); > - release_mem_region(info->phys_base, info->mem_size); > -out_free_info: > if (info->nand.ecc.priv) { > nand_bch_free(info->nand.ecc.priv); > info->nand.ecc.priv = NULL; > } > - kfree(info); > - > return err; > } [...] This patch version looks much better. Thanks for the rewrite. Brian -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html