mtd: docg3: Use devm_*() functions
Subsystems (4)
PATCH 1/8 mtd: docg3: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
--- drivers/mtd/devices/docg3.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/mtd/devices/docg3.c +6 -14
@@ -2047,21 +2047,21 @@ static int __init docg3_probe(struct platform_device *pdev) ress =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!ress) {dev_err (dev,"No I/O memory resource defined\n" ); - goto noress; +return ret; } - base =ioremap (ress->start,DOC_IOSPACE_SIZE ); + base =devm_ioremap (dev, ress->start,DOC_IOSPACE_SIZE ); ret = -ENOMEM ; - cascade =kzalloc (sizeof (*cascade) *DOC_MAX_NBFLOORS , -GFP_KERNEL ); + cascade =devm_kzalloc (dev,sizeof (*cascade) *DOC_MAX_NBFLOORS , +GFP_KERNEL );if (!cascade) - goto nomem1; +return ret; cascade->base = base;mutex_init (&cascade->lock); cascade->bch =init_bch (DOC_ECC_BCH_M ,DOC_ECC_BCH_T ,DOC_ECC_BCH_PRIMPOLY );if (!cascade->bch) - goto nomem2; +return ret;for (floor =0 ; floor <DOC_MAX_NBFLOORS ; floor++) { mtd =doc_probe_device (cascade, floor, dev);
@@ -2101,11 +2101,6 @@ err_probe:for (floor =0 ; floor <DOC_MAX_NBFLOORS ; floor++)if (cascade->floors[floor])doc_release_device (cascade->floors[floor]); -nomem2: -kfree (cascade); -nomem1: -iounmap (base); -noress:return ret; }
@@ -2119,7 +2114,6 @@ static int __exit docg3_release(struct platform_device *pdev) {struct docg3_cascade *cascade =platform_get_drvdata (pdev);struct docg3 *docg3 = cascade->floors[0 ]->priv; -void __iomem *base = cascade->base;int floor;doc_unregister_sysfs (pdev, cascade);
@@ -2129,8 +2123,6 @@ static int __exit docg3_release(struct platform_device *pdev)doc_release_device (cascade->floors[floor]);free_bch (docg3->cascade->bch); -kfree (cascade); -iounmap (base);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 2/8 mtd: ixp4xx: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
--- drivers/mtd/maps/ixp4xx.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
drivers/mtd/maps/ixp4xx.c +5 -22
@@ -162,13 +162,6 @@ static int ixp4xx_flash_remove(struct platform_device *dev)mtd_device_unregister (info->mtd);map_destroy (info->mtd); } -if (info->map.virt) -iounmap (info->map.virt); - -if (info->res) { -release_resource (info->res); -kfree (info->res); - }if (plat->exit) plat->exit ();
@@ -194,7 +187,8 @@ static int ixp4xx_flash_probe(struct platform_device *dev)return err; } - info =kzalloc (sizeof (struct ixp4xx_flash_info ),GFP_KERNEL ); + info =devm_kzalloc (&dev->dev,sizeof (struct ixp4xx_flash_info ), +GFP_KERNEL );if (!info) { err = -ENOMEM ; goto Error;
@@ -220,20 +214,9 @@ static int ixp4xx_flash_probe(struct platform_device *dev) info->map.write = ixp4xx_probe_write16; info->map.copy_from = ixp4xx_copy_from; - info->res =request_mem_region (dev->resource->start, -resource_size (dev->resource), -"IXP4XXFlash" ); -if (!info->res) { -printk (KERN_ERR "IXP4XXFlash: Could not reserve memory region\n" ); - err = -ENOMEM ; - goto Error; - } - - info->map.virt =ioremap (dev->resource->start, -resource_size (dev->resource)); -if (!info->map.virt) { -printk (KERN_ERR "IXP4XXFlash: Failed to ioremap region\n" ); - err = -EIO ; + info->map.virt =devm_ioremap_resource (&dev->dev, dev->resource); +if (IS_ERR (info->map.virt)) { + err =PTR_ERR (info->map.virt); goto Error; }
Signature · 1 line
1.7.10.4
PATCH 3/8 mtd: lantiq-flash: Use devm_kzalloc()
In reply to Jingoo HanUse devm_kzalloc() to make cleanup paths simpler.
--- drivers/mtd/maps/lantiq-flash.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/mtd/maps/lantiq-flash.c +6 -11
@@ -123,7 +123,7 @@ ltq_mtd_probe(struct platform_device *pdev)return -ENODEV ; } - ltq_mtd =kzalloc (sizeof (struct ltq_mtd ),GFP_KERNEL ); + ltq_mtd =devm_kzalloc (&pdev->dev,sizeof (struct ltq_mtd ),GFP_KERNEL );platform_set_drvdata (pdev, ltq_mtd); ltq_mtd->res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -133,7 +133,8 @@ ltq_mtd_probe(struct platform_device *pdev) goto err_out; } - ltq_mtd->map =kzalloc (sizeof (struct map_info ),GFP_KERNEL ); + ltq_mtd->map =devm_kzalloc (&pdev->dev,sizeof (struct map_info ), +GFP_KERNEL ); ltq_mtd->map->phys = ltq_mtd->res->start; ltq_mtd->map->size =resource_size (ltq_mtd->res); ltq_mtd->map->virt =devm_ioremap_resource (&pdev->dev, ltq_mtd->res);
@@ -178,9 +179,7 @@ ltq_mtd_probe(struct platform_device *pdev) err_destroy:map_destroy (ltq_mtd->mtd); err_free: -kfree (ltq_mtd->map); err_out: -kfree (ltq_mtd);return err; }
@@ -189,13 +188,9 @@ ltq_mtd_remove(struct platform_device *pdev) {struct ltq_mtd *ltq_mtd =platform_get_drvdata (pdev); -if (ltq_mtd) { -if (ltq_mtd->mtd) { -mtd_device_unregister (ltq_mtd->mtd); -map_destroy (ltq_mtd->mtd); - } -kfree (ltq_mtd->map); -kfree (ltq_mtd); +if (ltq_mtd && ltq_mtd->mtd) { +mtd_device_unregister (ltq_mtd->mtd); +map_destroy (ltq_mtd->mtd); }return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 4/8 mtd: denali_dt: Use devm_clk_get()
In reply to Jingoo HanUse devm_clk_get() to make cleanup paths simpler.
--- drivers/mtd/nand/denali_dt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/denali_dt.c +1 -3
@@ -108,7 +108,7 @@ static int denali_dt_probe(struct platform_device *ofdev) denali->dev->dma_mask =NULL ; } - dt->clk =clk_get (&ofdev->dev,NULL ); + dt->clk =devm_clk_get (&ofdev->dev,NULL );if (IS_ERR (dt->clk)) {dev_err (&ofdev->dev,"no clk available\n" );return PTR_ERR (dt->clk);
@@ -124,7 +124,6 @@ static int denali_dt_probe(struct platform_device *ofdev) out_disable_clk:clk_disable_unprepare (dt->clk); -clk_put (dt->clk);return ret; }
@@ -135,7 +134,6 @@ static int denali_dt_remove(struct platform_device *ofdev)denali_remove (&dt->denali);clk_disable (dt->clk); -clk_put (dt->clk);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 5/8 mtd: lpc32xx_slc: Use devm_*() functions
In reply to Jingoo HanUse devm_*() functions to make cleanup paths simpler.
--- drivers/mtd/nand/lpc32xx_slc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/mtd/nand/lpc32xx_slc.c +3 -7
@@ -791,8 +791,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) }if (host->ncfg->wp_gpio == -EPROBE_DEFER )return -EPROBE_DEFER ; -if (gpio_is_valid (host->ncfg->wp_gpio) && -gpio_request (host->ncfg->wp_gpio,"NAND WP" )) { +if (gpio_is_valid (host->ncfg->wp_gpio) &&devm_gpio_request (&pdev->dev, + host->ncfg->wp_gpio,"NAND WP" )) {dev_err (&pdev->dev,"GPIO not available\n" );return -EBUSY ; }
@@ -808,7 +808,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) mtd->dev.parent = &pdev->dev;/* Get NAND clock */ - host->clk =clk_get (&pdev->dev,NULL ); + host->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (host->clk)) {dev_err (&pdev->dev,"Clock failure\n" ); res = -ENOENT ;
@@ -927,10 +927,8 @@ err_exit3:dma_release_channel (host->dma_chan); err_exit2:clk_disable (host->clk); -clk_put (host->clk); err_exit1:lpc32xx_wp_enable (host); -gpio_free (host->ncfg->wp_gpio);return res; }
@@ -953,9 +951,7 @@ static int lpc32xx_nand_remove(struct platform_device *pdev)writel (tmp,SLC_CTRL (host->io_base));clk_disable (host->clk); -clk_put (host->clk);lpc32xx_wp_enable (host); -gpio_free (host->ncfg->wp_gpio);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 6/8 mtd: nuc900_nand: Use devm_*() functions
In reply to Jingoo HanUse devm_*() functions to make cleanup paths simpler.
--- drivers/mtd/nand/nuc900_nand.c | 55 ++++++++++------------------------------ 1 file changed, 13 insertions(+), 42 deletions(-)
drivers/mtd/nand/nuc900_nand.c +13 -42
@@ -241,12 +241,10 @@ static int nuc900_nand_probe(struct platform_device *pdev) {struct nuc900_nand *nuc900_nand;struct nand_chip *chip; -int retval;struct resource *res; - retval =0 ; - - nuc900_nand =kzalloc (sizeof (struct nuc900_nand ),GFP_KERNEL ); + nuc900_nand =devm_kzalloc (&pdev->dev,sizeof (struct nuc900_nand ), +GFP_KERNEL );if (!nuc900_nand)return -ENOMEM ; chip = &(nuc900_nand->chip);
@@ -255,11 +253,9 @@ static int nuc900_nand_probe(struct platform_device *pdev) nuc900_nand->mtd.owner =THIS_MODULE ;spin_lock_init (&nuc900_nand->lock); - nuc900_nand->clk =clk_get (&pdev->dev,NULL ); -if (IS_ERR (nuc900_nand->clk)) { - retval = -ENOENT ; - goto fail1; - } + nuc900_nand->clk =devm_clk_get (&pdev->dev,NULL ); +if (IS_ERR (nuc900_nand->clk)) +return -ENOENT ;clk_enable (nuc900_nand->clk); chip->cmdfunc = nuc900_nand_command_lp;
@@ -272,57 +268,32 @@ static int nuc900_nand_probe(struct platform_device *pdev) chip->ecc.mode =NAND_ECC_SOFT ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { - retval = -ENXIO ; - goto fail1; - } +if (!res) +return -ENXIO ; -if (!request_mem_region (res->start,resource_size (res), pdev->name)) { - retval = -EBUSY ; - goto fail1; - } - - nuc900_nand->reg =ioremap (res->start,resource_size (res)); -if (!nuc900_nand->reg) { - retval = -ENOMEM ; - goto fail2; - } + nuc900_nand->reg =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (nuc900_nand->reg)) +return PTR_ERR (nuc900_nand->reg);nuc900_nand_enable (nuc900_nand); -if (nand_scan (&(nuc900_nand->mtd),1 )) { - retval = -ENXIO ; - goto fail3; - } +if (nand_scan (&(nuc900_nand->mtd),1 )) +return -ENXIO ;mtd_device_register (&(nuc900_nand->mtd), partitions,ARRAY_SIZE (partitions));platform_set_drvdata (pdev, nuc900_nand); -return retval; - -fail3:iounmap (nuc900_nand->reg); -fail2:release_mem_region (res->start,resource_size (res)); -fail1:kfree (nuc900_nand); -return retval; +return 0 ; }static int nuc900_nand_remove (struct platform_device *pdev) {struct nuc900_nand *nuc900_nand =platform_get_drvdata (pdev); -struct resource *res;nand_release (&nuc900_nand->mtd); -iounmap (nuc900_nand->reg); - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -release_mem_region (res->start,resource_size (res)); -clk_disable (nuc900_nand->clk); -clk_put (nuc900_nand->clk); - -kfree (nuc900_nand);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 7/8 mtd: plat_nand: Use devm_*() functions
In reply to Jingoo HanUse devm_*() functions to make cleanup paths simpler.
--- drivers/mtd/nand/plat_nand.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-)
drivers/mtd/nand/plat_nand.c +5 -25
@@ -52,25 +52,16 @@ static int plat_nand_probe(struct platform_device *pdev)return -ENXIO ;/* Allocate memory for the device structure (and zero it) */ - data =kzalloc (sizeof (struct plat_nand_data ),GFP_KERNEL ); + data =devm_kzalloc (&pdev->dev,sizeof (struct plat_nand_data ), +GFP_KERNEL );if (!data) {dev_err (&pdev->dev,"failed to allocate device structure.\n" );return -ENOMEM ; } -if (!request_mem_region (res->start,resource_size (res), -dev_name (&pdev->dev))) { -dev_err (&pdev->dev,"request_mem_region failed\n" ); - err = -EBUSY ; - goto out_free; - } - - data->io_base =ioremap (res->start,resource_size (res)); -if (data->io_base ==NULL ) { -dev_err (&pdev->dev,"ioremap failed\n" ); - err = -EIO ; - goto out_release_io; - } + data->io_base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (data->io_base)) +return PTR_ERR (data->io_base); data->chip.priv = &data; data->mtd.priv = &data->chip;
@@ -122,11 +113,6 @@ static int plat_nand_probe(struct platform_device *pdev) out:if (pdata->ctrl.remove) pdata->ctrl.remove (pdev); -iounmap (data->io_base); -out_release_io: -release_mem_region (res->start,resource_size (res)); -out_free: -kfree (data);return err; }
@@ -137,16 +123,10 @@ static int plat_nand_remove(struct platform_device *pdev) {struct plat_nand_data *data =platform_get_drvdata (pdev);struct platform_nand_data *pdata =dev_get_platdata (&pdev->dev); -struct resource *res; - - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );nand_release (&data->mtd);if (pdata->ctrl.remove) pdata->ctrl.remove (pdev); -iounmap (data->io_base); -release_mem_region (res->start,resource_size (res)); -kfree (data);return 0 ; }
Signature · 1 line
1.7.10.4
PATCH 8/8 mtd: tmio_nand: Use devm_*() functions
In reply to Jingoo HanUse devm_*() functions to make cleanup paths simpler.
--- drivers/mtd/nand/tmio_nand.c | 46 ++++++++++++------------------------------ 1 file changed, 13 insertions(+), 33 deletions(-)
drivers/mtd/nand/tmio_nand.c +13 -33
@@ -371,11 +371,9 @@ static int tmio_probe(struct platform_device *dev)if (data ==NULL )dev_warn (&dev->dev,"NULL platform data!\n" ); - tmio =kzalloc (sizeof *tmio,GFP_KERNEL ); -if (!tmio) { - retval = -ENOMEM ; - goto err_kzalloc; - } + tmio =devm_kzalloc (&dev->dev,sizeof (*tmio),GFP_KERNEL ); +if (!tmio) +return -ENOMEM ; tmio->dev = dev;
@@ -385,22 +383,18 @@ static int tmio_probe(struct platform_device *dev) mtd->priv = nand_chip; mtd->name ="tmio-nand" ; - tmio->ccr =ioremap (ccr->start,resource_size (ccr)); -if (!tmio->ccr) { - retval = -EIO ; - goto err_iomap_ccr; - } + tmio->ccr =devm_ioremap (&dev->dev, ccr->start,resource_size (ccr)); +if (!tmio->ccr) +return -EIO ; tmio->fcr_base = fcr->start &0xfffff ; - tmio->fcr =ioremap (fcr->start,resource_size (fcr)); -if (!tmio->fcr) { - retval = -EIO ; - goto err_iomap_fcr; - } + tmio->fcr =devm_ioremap (&dev->dev, fcr->start,resource_size (fcr)); +if (!tmio->fcr) +return -EIO ; retval =tmio_hw_init (dev, tmio);if (retval) - goto err_hwinit; +return retval;/* Set address of NAND IO lines */ nand_chip->IO_ADDR_R = tmio->fcr;
@@ -428,7 +422,8 @@ static int tmio_probe(struct platform_device *dev)/* 15 us command delay time */ nand_chip->chip_delay =15 ; - retval =request_irq (irq, &tmio_irq,0 ,dev_name (&dev->dev), tmio); + retval =devm_request_irq (&dev->dev, irq, &tmio_irq,0 , +dev_name (&dev->dev), tmio);if (retval) {dev_err (&dev->dev,"request_irq error %d\n" , retval); goto err_irq;
@@ -440,7 +435,7 @@ static int tmio_probe(struct platform_device *dev)/* Scan to find existence of the device */ if (nand_scan (mtd,1 )) { retval = -ENODEV ; - goto err_scan; + goto err_irq; }/* Register the partitions */ retval = mtd_device_parse_register(mtd, NULL, NULL,
@@ -451,18 +446,8 @@ static int tmio_probe(struct platform_device *dev)nand_release (mtd); -err_scan: -if (tmio->irq) -free_irq (tmio->irq, tmio); err_irq:tmio_hw_stop (dev, tmio); -err_hwinit: -iounmap (tmio->fcr); -err_iomap_fcr: -iounmap (tmio->ccr); -err_iomap_ccr: -kfree (tmio); -err_kzalloc:return retval; }
@@ -471,12 +456,7 @@ static int tmio_remove(struct platform_device *dev)struct tmio_nand *tmio =platform_get_drvdata (dev);nand_release (&tmio->mtd); -if (tmio->irq) -free_irq (tmio->irq, tmio);tmio_hw_stop (dev, tmio); -iounmap (tmio->fcr); -iounmap (tmio->ccr); -kfree (tmio);return 0 ; }
Signature · 1 line
1.7.10.4
Re: [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc()
In reply to Jingoo Handrivers/mtd/maps/lantiq-flash.c ltq_mtd_probe(struct platform_device *pdev) · line 184
Quoted 8 lines · Jingoo Han
err_destroy: map_destroy(ltq_mtd->mtd); err_free:drivers/mtd/maps/lantiq-flash.c +0
-2-kfree (ltq_mtd->map); err_out: -kfree (ltq_mtd);return err; }
Hi,
after the cleanup only err_destroy is needed. the other 2 jump marks can be removed aswell.
John
Re: [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc()
Quoted 12 lines · John Crispin
drivers/mtd/maps/lantiq-flash.c ltq_mtd_probe(struct platform_device *pdev) · line 184
Quoted 8 lines · Jingoo Han
err_destroy: map_destroy(ltq_mtd->mtd); err_free:drivers/mtd/maps/lantiq-flash.c +0
-2-kfree (ltq_mtd->map); err_out: -kfree (ltq_mtd);return err; }Hi,
Quoted 2 lines
after the cleanup only
err_destroyis needed. the other 2 jump marks can be removed aswell.
Hi John Crispin,
I see. You're right.
I will remove unnecessary goto labels such as err_free, err_out. Thank you for your comment. :-)
Best regards,
Jingoo Han
Re: [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
In reply to Jingoo HanQuoted 20 lines · Jingoo Han
drivers/mtd/nand/plat_nand.c +2
-7@@ -52,25 +52,16 @@ static int plat_nand_probe(struct platform_device *pdev)return -ENXIO ;/* Allocate memory for the device structure (and zero it) */ - data =kzalloc (sizeof (struct plat_nand_data ),GFP_KERNEL ); + data =devm_kzalloc (&pdev->dev,sizeof (struct plat_nand_data ), +GFP_KERNEL );if (!data) {dev_err (&pdev->dev,"failed to allocate device structure.\n" );return -ENOMEM ; } -if (!request_mem_region (res->start,resource_size (res), -dev_name (&pdev->dev))) { -dev_err (&pdev->dev,"request_mem_region failed\n" ); - err = -EBUSY ; - goto out_free; - }
drivers/mtd/nand/plat_nand.c static int plat_nand_probe(struct platform_device *pdev) · line 64
Quoted 10 lines
drivers/mtd/nand/plat_nand.c +3
-7- - data->io_base =ioremap (res->start,resource_size (res)); -if (data->io_base ==NULL ) { -dev_err (&pdev->dev,"ioremap failed\n" ); - err = -EIO ; - goto out_release_io; - } + data->io_base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (data->io_base)) +return PTR_ERR (data->io_base);
This gives me a few errors:
drivers/mtd/nand/plat_nand.c: In function 'plat_nand_probe':drivers/mtd/nand/plat_nand.c:61:2: error: implicit declaration of function 'IS_ERR' [-Werror=implicit-function-declaration] drivers/mtd/nand/plat_nand.c:62:3: error: implicit declaration of function 'PTR_ERR' [-Werror=implicit-function-declaration] make[4]: *** [drivers/mtd/nand/plat_nand.o] Error 1
You probably need to #include <linux/err.h>. I guess you don't compile-test your changes? It would help if you can catch these mistakes before they get to the maintainer.
drivers/mtd/nand/plat_nand.c static int plat_nand_probe(struct platform_device *pdev) · line 67
Quoted 3 lines
drivers/mtd/nand/plat_nand.c +0
-0data->chip.priv = &data; data->mtd.priv = &data->chip;
Brian
Re: [PATCH 2/8] mtd: ixp4xx: Use devm_*() functions
In reply to Jingoo HanQuoted 13 lines · Jingoo Han
drivers/mtd/maps/ixp4xx.c +0
-7@@ -220,20 +214,9 @@ static int ixp4xx_flash_probe(struct platform_device *dev) info->map.write = ixp4xx_probe_write16; info->map.copy_from = ixp4xx_copy_from; - info->res =request_mem_region (dev->resource->start, -resource_size (dev->resource), -"IXP4XXFlash" ); -if (!info->res) { -printk (KERN_ERR "IXP4XXFlash: Could not reserve memory region\n" ); - err = -ENOMEM ; - goto Error;
drivers/mtd/maps/ixp4xx.c static int ixp4xx_flash_probe(struct platform_device *dev) · line 219
Quoted 10 lines
drivers/mtd/maps/ixp4xx.c +3
-7- } - - info->map.virt =ioremap (dev->resource->start, -resource_size (dev->resource)); -if (!info->map.virt) { -printk (KERN_ERR "IXP4XXFlash: Failed to ioremap region\n" ); - err = -EIO ; + info->map.virt =devm_ioremap_resource (&dev->dev, dev->resource); +if (IS_ERR (info->map.virt)) { + err =PTR_ERR (info->map.virt);
I don't have a defconfig on hand for compiling this one yet, but I assume this has the same problem as the plat_nand one (missing <linux/err.h>), so I'm not taking it yet.
drivers/mtd/maps/ixp4xx.c static int ixp4xx_flash_probe(struct platform_device *dev) · line 222
Quoted 3 lines
drivers/mtd/maps/ixp4xx.c +0
-0goto Error; }
Brian
Re: [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
In reply to Brian NorrisQuoted 6 lines · Brian Norris
drivers/mtd/nand/plat_nand.c static int plat_nand_probe(struct platform_device *pdev) · line 64
Quoted 2 lines · Jingoo Han
drivers/mtd/nand/plat_nand.c +2
-0+if (IS_ERR (data->io_base)) +return PTR_ERR (data->io_base);This gives me a few errors:
Quoted 12 lines
drivers/mtd/nand/plat_nand.c: In function 'plat_nand_probe':drivers/mtd/nand/plat_nand.c:61:2: error: implicit declaration of function 'IS_ERR' [-Werror=implicit-function-declaration]drivers/mtd/nand/plat_nand.c:62:3: error: implicit declaration of function 'PTR_ERR' [-Werror=implicit-function-declaration] make[4]: *** [drivers/mtd/nand/plat_nand.o] Error 1You probably need to #include <
linux/err.h>. I guess you don't compile-test your changes? It would help if you can catch these mistakes before they get to the maintainer.Quoted 3 lines
data->chip.priv = &data; data->mtd.priv = &data->chip;
Sorry, I replied to the v1, but I was actually testing v3. My comments apply to either version though.
Brian
Re: [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
In reply to Brian NorrisQuoted 41 lines · Jingoo Han
Quoted 20 lines · Jingoo Han
drivers/mtd/nand/plat_nand.c +2
-7@@ -52,25 +52,16 @@ static int plat_nand_probe(struct platform_device *pdev)return -ENXIO ;/* Allocate memory for the device structure (and zero it) */ - data =kzalloc (sizeof (struct plat_nand_data ),GFP_KERNEL ); + data =devm_kzalloc (&pdev->dev,sizeof (struct plat_nand_data ), +GFP_KERNEL );if (!data) {dev_err (&pdev->dev,"failed to allocate device structure.\n" );return -ENOMEM ; } -if (!request_mem_region (res->start,resource_size (res), -dev_name (&pdev->dev))) { -dev_err (&pdev->dev,"request_mem_region failed\n" ); - err = -EBUSY ; - goto out_free; - }drivers/mtd/nand/plat_nand.c static int plat_nand_probe(struct platform_device *pdev) · line 64
Quoted 10 lines
drivers/mtd/nand/plat_nand.c +3
-7- - data->io_base =ioremap (res->start,resource_size (res)); -if (data->io_base ==NULL ) { -dev_err (&pdev->dev,"ioremap failed\n" ); - err = -EIO ; - goto out_release_io; - } + data->io_base =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (data->io_base)) +return PTR_ERR (data->io_base);This gives me a few errors:
drivers/mtd/nand/plat_nand.c: In function 'plat_nand_probe':drivers/mtd/nand/plat_nand.c:61:2: error: implicit declaration of function 'IS_ERR' [-Werror=implicit- function-declaration]drivers/mtd/nand/plat_nand.c:62:3: error: implicit declaration of function 'PTR_ERR' [- Werror=implicit-function-declaration]
make[4]: *** [drivers/mtd/nand/plat_nand.o] Error 1
Quoted 3 lines
You probably need to #include <
linux/err.h>. I guess you don't compile-test your changes? It would help if you can catch these mistakes before they get to the maintainer.
Hi Norris,
I did compile all patches. However, I cannot understand why the build error happens. Anyway, I will check it and add '#include <linux/err.h' if needed.
Thank you for your comment. :-)
Happy new year!
Best regards,
Jingoo Han
Re: [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
Quoted 1 line · Jingoo Han
On Friday, January 03, 2014 10:18 AM, Jingoo Han wrote:
^^^ Huh? It looks like you quoted me, but your mailer says you're quoting yourself! You might want to fix that :)
Quoted 9 lines
Quoted 9 lines
This gives me a few errors:
drivers/mtd/nand/plat_nand.c: In function 'plat_nand_probe':drivers/mtd/nand/plat_nand.c:61:2: error: implicit declaration of function 'IS_ERR' [-Werror=implicit- function-declaration]drivers/mtd/nand/plat_nand.c:62:3: error: implicit declaration of function 'PTR_ERR' [- Werror=implicit-function-declaration]
make[4]: *** [drivers/mtd/nand/plat_nand.o] Error 1
Quoted 8 lines
Quoted 3 lines
You probably need to #include <
linux/err.h>. I guess you don't compile-test your changes? It would help if you can catch these mistakes before they get to the maintainer.Hi Norris,
I did compile all patches. However, I cannot understand why the build error happens.
I guess you were relying on an implicit #include via some other explicitly-included header, and maybe this implicit inclusion is different for different ARCHes, so that this only fails to compile under certain configurations.
Quoted 2 lines
Anyway, I will check it and add '#include <
linux/err.h' if needed.
Yes, that is the right thing. Standard practice is to explicitly include any required headers, so that changes in unrelated headers don't break things.
Quoted 2 lines
Thank you for your comment. :-)
Happy new year!
Yes, happy 2014!
Brian