diff mbox

[4/5] mtd: nand: omap2: Use devm_kzalloc

Message ID 1382652737-20239-5-git-send-email-ezequiel.garcia@free-electrons.com
State Superseded
Headers show

Commit Message

Ezequiel Garcia Oct. 24, 2013, 10:12 p.m. UTC
This simplifies the error path and makes the code less error-prone.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/mtd/nand/omap2.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Belisko Marek Oct. 24, 2013, 10:24 p.m. UTC | #1
Hi,

On Fri, Oct 25, 2013 at 12:12 AM, Ezequiel Garcia
<ezequiel.garcia@free-electrons.com> wrote:
> This simplifies the error path and makes the code less error-prone.
>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/mtd/nand/omap2.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> index e01a936..d4cafb0 100644
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -1837,7 +1837,7 @@ static int omap_nand_probe(struct platform_device *pdev)
>                 return -ENODEV;
>         }
>
> -       info = kzalloc(sizeof(struct omap_nand_info), GFP_KERNEL);
> +       info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
>         if (!info)
>                 return -ENOMEM;
>
> @@ -2066,9 +2066,6 @@ out_release_mem_region:
>         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:
You remove ^^^^ statement but it's still used in line ~1868 as return when
cannot get resource.
> -       kfree(info);
> -
>         return err;
>  }
>
> @@ -2091,7 +2088,6 @@ static int omap_nand_remove(struct platform_device *pdev)
>         nand_release(&info->mtd);
>         iounmap(info->nand.IO_ADDR_R);
>         release_mem_region(info->phys_base, info->mem_size);
> -       kfree(info);
>         return 0;
>  }
>
> --
> 1.8.1.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

BR,

marek
Ezequiel Garcia Oct. 24, 2013, 10:50 p.m. UTC | #2
On Fri, Oct 25, 2013 at 12:24:38AM +0200, Belisko Marek wrote:
> Hi,
> 
> On Fri, Oct 25, 2013 at 12:12 AM, Ezequiel Garcia
> <ezequiel.garcia@free-electrons.com> wrote:
> > This simplifies the error path and makes the code less error-prone.
> >
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/mtd/nand/omap2.c | 6 +-----
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> > index e01a936..d4cafb0 100644
> > --- a/drivers/mtd/nand/omap2.c
> > +++ b/drivers/mtd/nand/omap2.c
> > @@ -1837,7 +1837,7 @@ static int omap_nand_probe(struct platform_device *pdev)
> >                 return -ENODEV;
> >         }
> >
> > -       info = kzalloc(sizeof(struct omap_nand_info), GFP_KERNEL);
> > +       info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> >         if (!info)
> >                 return -ENOMEM;
> >
> > @@ -2066,9 +2066,6 @@ out_release_mem_region:
> >         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:
> You remove ^^^^ statement but it's still used in line ~1868 as return when
> cannot get resource.

Right, I missed that. This happens when you do two cleanups at once and then
try to commit them separatedly!

Thanks!
diff mbox

Patch

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index e01a936..d4cafb0 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1837,7 +1837,7 @@  static int omap_nand_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	info = kzalloc(sizeof(struct omap_nand_info), GFP_KERNEL);
+	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -2066,9 +2066,6 @@  out_release_mem_region:
 	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:
-	kfree(info);
-
 	return err;
 }
 
@@ -2091,7 +2088,6 @@  static int omap_nand_remove(struct platform_device *pdev)
 	nand_release(&info->mtd);
 	iounmap(info->nand.IO_ADDR_R);
 	release_mem_region(info->phys_base, info->mem_size);
-	kfree(info);
 	return 0;
 }