* [PATCH 1/8] mtd: docg3: Use devm_*() functions
@ 2013-12-20 4:53 Jingoo Han
2013-12-20 4:56 ` [PATCH 2/8] mtd: ixp4xx: " Jingoo Han
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 4:53 UTC (permalink / raw)
To: 'Brian Norris'
Cc: linux-mtd, 'Robert Jarzmik', 'Jingoo Han',
'David Woodhouse'
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/devices/docg3.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index 4f091c1..dd5e101 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/8] mtd: ixp4xx: Use devm_*() functions
2013-12-20 4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
@ 2013-12-20 4:56 ` Jingoo Han
2014-01-03 1:19 ` Brian Norris
2013-12-20 4:58 ` [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc() Jingoo Han
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 4:56 UTC (permalink / raw)
To: 'Brian Norris'
Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
'Marc Kleine-Budde'
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/maps/ixp4xx.c | 27 +++++----------------------
1 file changed, 5 insertions(+), 22 deletions(-)
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 10debfe..5f42916 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc()
2013-12-20 4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
2013-12-20 4:56 ` [PATCH 2/8] mtd: ixp4xx: " Jingoo Han
@ 2013-12-20 4:58 ` Jingoo Han
2013-12-20 6:03 ` John Crispin
2013-12-20 5:00 ` [PATCH 4/8] mtd: denali_dt: Use devm_clk_get() Jingoo Han
` (4 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 4:58 UTC (permalink / raw)
To: 'Brian Norris'
Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
'John Crispin', 'Thomas Langer'
Use devm_kzalloc() to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/maps/lantiq-flash.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c
index d7ac65d..4b197c6 100644
--- a/drivers/mtd/maps/lantiq-flash.c
+++ b/drivers/mtd/maps/lantiq-flash.c
@@ -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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 4/8] mtd: denali_dt: Use devm_clk_get()
2013-12-20 4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
2013-12-20 4:56 ` [PATCH 2/8] mtd: ixp4xx: " Jingoo Han
2013-12-20 4:58 ` [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc() Jingoo Han
@ 2013-12-20 5:00 ` Jingoo Han
2013-12-20 5:01 ` [PATCH 5/8] mtd: lpc32xx_slc: Use devm_*() functions Jingoo Han
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 5:00 UTC (permalink / raw)
To: 'Brian Norris'
Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
'Dinh Nguyen'
Use devm_clk_get() to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/nand/denali_dt.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c
index 9253024..babb02c 100644
--- a/drivers/mtd/nand/denali_dt.c
+++ b/drivers/mtd/nand/denali_dt.c
@@ -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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 5/8] mtd: lpc32xx_slc: Use devm_*() functions
2013-12-20 4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
` (2 preceding siblings ...)
2013-12-20 5:00 ` [PATCH 4/8] mtd: denali_dt: Use devm_clk_get() Jingoo Han
@ 2013-12-20 5:01 ` Jingoo Han
2013-12-20 5:02 ` [PATCH 6/8] mtd: nuc900_nand: " Jingoo Han
` (2 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 5:01 UTC (permalink / raw)
To: 'Brian Norris'
Cc: 'Roland Stigge', linux-mtd, 'Jingoo Han',
'David Woodhouse'
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/nand/lpc32xx_slc.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
index 23e6974..5f20394 100644
--- a/drivers/mtd/nand/lpc32xx_slc.c
+++ b/drivers/mtd/nand/lpc32xx_slc.c
@@ -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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 6/8] mtd: nuc900_nand: Use devm_*() functions
2013-12-20 4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
` (3 preceding siblings ...)
2013-12-20 5:01 ` [PATCH 5/8] mtd: lpc32xx_slc: Use devm_*() functions Jingoo Han
@ 2013-12-20 5:02 ` Jingoo Han
2013-12-20 5:04 ` [PATCH 7/8] mtd: plat_nand: " Jingoo Han
2013-12-20 5:05 ` [PATCH 8/8] mtd: tmio_nand: " Jingoo Han
6 siblings, 0 replies; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 5:02 UTC (permalink / raw)
To: 'Brian Norris'
Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
'Wan ZongShun'
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/nand/nuc900_nand.c | 55 ++++++++++------------------------------
1 file changed, 13 insertions(+), 42 deletions(-)
diff --git a/drivers/mtd/nand/nuc900_nand.c b/drivers/mtd/nand/nuc900_nand.c
index 5211515..661fd14 100644
--- a/drivers/mtd/nand/nuc900_nand.c
+++ b/drivers/mtd/nand/nuc900_nand.c
@@ -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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
2013-12-20 4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
` (4 preceding siblings ...)
2013-12-20 5:02 ` [PATCH 6/8] mtd: nuc900_nand: " Jingoo Han
@ 2013-12-20 5:04 ` Jingoo Han
2014-01-03 1:17 ` Brian Norris
2013-12-20 5:05 ` [PATCH 8/8] mtd: tmio_nand: " Jingoo Han
6 siblings, 1 reply; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 5:04 UTC (permalink / raw)
To: 'Brian Norris'
Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
'Vitaly Wool'
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/nand/plat_nand.c | 30 +++++-------------------------
1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index cad4cdc..7734f0e 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 8/8] mtd: tmio_nand: Use devm_*() functions
2013-12-20 4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
` (5 preceding siblings ...)
2013-12-20 5:04 ` [PATCH 7/8] mtd: plat_nand: " Jingoo Han
@ 2013-12-20 5:05 ` Jingoo Han
6 siblings, 0 replies; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 5:05 UTC (permalink / raw)
To: 'Brian Norris'
Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
'Ian Molton'
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
drivers/mtd/nand/tmio_nand.c | 46 ++++++++++++------------------------------
1 file changed, 13 insertions(+), 33 deletions(-)
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c
index a3747c9..fb8fd35 100644
--- a/drivers/mtd/nand/tmio_nand.c
+++ b/drivers/mtd/nand/tmio_nand.c
@@ -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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc()
2013-12-20 4:58 ` [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc() Jingoo Han
@ 2013-12-20 6:03 ` John Crispin
2013-12-20 7:14 ` Jingoo Han
0 siblings, 1 reply; 15+ messages in thread
From: John Crispin @ 2013-12-20 6:03 UTC (permalink / raw)
To: Jingoo Han
Cc: linux-mtd, 'Brian Norris', 'David Woodhouse',
'Thomas Langer'
On 20/12/13 05:58, Jingoo Han wrote:
> err_destroy:
> map_destroy(ltq_mtd->mtd);
> err_free:
> - 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc()
2013-12-20 6:03 ` John Crispin
@ 2013-12-20 7:14 ` Jingoo Han
0 siblings, 0 replies; 15+ messages in thread
From: Jingoo Han @ 2013-12-20 7:14 UTC (permalink / raw)
To: 'John Crispin'
Cc: 'Jingoo Han', linux-mtd, 'Brian Norris',
'David Woodhouse', 'Thomas Langer'
On Friday, December 20, 2013 3:04 PM, John Crispin wrote:
> On 20/12/13 05:58, Jingoo Han wrote:
> > err_destroy:
> > map_destroy(ltq_mtd->mtd);
> > err_free:
> > - 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.
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
2013-12-20 5:04 ` [PATCH 7/8] mtd: plat_nand: " Jingoo Han
@ 2014-01-03 1:17 ` Brian Norris
2014-01-03 1:21 ` Brian Norris
2014-01-03 1:27 ` Jingoo Han
0 siblings, 2 replies; 15+ messages in thread
From: Brian Norris @ 2014-01-03 1:17 UTC (permalink / raw)
To: Jingoo Han; +Cc: linux-mtd, 'David Woodhouse', 'Vitaly Wool'
On Fri, Dec 20, 2013 at 02:04:29PM +0900, Jingoo Han wrote:
> --- a/drivers/mtd/nand/plat_nand.c
> +++ b/drivers/mtd/nand/plat_nand.c
> @@ -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);
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.
>
> data->chip.priv = &data;
> data->mtd.priv = &data->chip;
Brian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/8] mtd: ixp4xx: Use devm_*() functions
2013-12-20 4:56 ` [PATCH 2/8] mtd: ixp4xx: " Jingoo Han
@ 2014-01-03 1:19 ` Brian Norris
0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2014-01-03 1:19 UTC (permalink / raw)
To: Jingoo Han
Cc: linux-mtd, 'David Woodhouse', 'Marc Kleine-Budde'
On Fri, Dec 20, 2013 at 01:56:58PM +0900, Jingoo Han wrote:
> --- a/drivers/mtd/maps/ixp4xx.c
> +++ b/drivers/mtd/maps/ixp4xx.c
> @@ -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);
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.
> goto Error;
> }
>
Brian
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
2014-01-03 1:17 ` Brian Norris
@ 2014-01-03 1:21 ` Brian Norris
2014-01-03 1:27 ` Jingoo Han
1 sibling, 0 replies; 15+ messages in thread
From: Brian Norris @ 2014-01-03 1:21 UTC (permalink / raw)
To: Jingoo Han; +Cc: linux-mtd, David Woodhouse, Vitaly Wool
On Thu, Jan 2, 2014 at 5:17 PM, Brian Norris
<computersforpeace@gmail.com> wrote:
> On Fri, Dec 20, 2013 at 02:04:29PM +0900, Jingoo Han wrote:
>> + 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.
>
>>
>> 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
2014-01-03 1:17 ` Brian Norris
2014-01-03 1:21 ` Brian Norris
@ 2014-01-03 1:27 ` Jingoo Han
2014-01-03 18:16 ` Brian Norris
1 sibling, 1 reply; 15+ messages in thread
From: Jingoo Han @ 2014-01-03 1:27 UTC (permalink / raw)
To: 'Brian Norris'
Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
'Vitaly Wool'
On Friday, January 03, 2014 10:18 AM, Jingoo Han wrote:
> On Fri, Dec 20, 2013 at 02:04:29PM +0900, Jingoo Han wrote:
> > --- a/drivers/mtd/nand/plat_nand.c
> > +++ b/drivers/mtd/nand/plat_nand.c
> > @@ -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);
>
> 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.
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 7/8] mtd: plat_nand: Use devm_*() functions
2014-01-03 1:27 ` Jingoo Han
@ 2014-01-03 18:16 ` Brian Norris
0 siblings, 0 replies; 15+ messages in thread
From: Brian Norris @ 2014-01-03 18:16 UTC (permalink / raw)
To: Jingoo Han; +Cc: linux-mtd, 'David Woodhouse', 'Vitaly Wool'
On Fri, Jan 03, 2014 at 10:27:53AM +0900, Jingoo Han wrote:
> 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 :)
> > 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.
>
> 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.
> 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.
> Thank you for your comment. :-)
> Happy new year!
Yes, happy 2014!
Brian
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2014-01-03 18:16 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-20 4:53 [PATCH 1/8] mtd: docg3: Use devm_*() functions Jingoo Han
2013-12-20 4:56 ` [PATCH 2/8] mtd: ixp4xx: " Jingoo Han
2014-01-03 1:19 ` Brian Norris
2013-12-20 4:58 ` [PATCH 3/8] mtd: lantiq-flash: Use devm_kzalloc() Jingoo Han
2013-12-20 6:03 ` John Crispin
2013-12-20 7:14 ` Jingoo Han
2013-12-20 5:00 ` [PATCH 4/8] mtd: denali_dt: Use devm_clk_get() Jingoo Han
2013-12-20 5:01 ` [PATCH 5/8] mtd: lpc32xx_slc: Use devm_*() functions Jingoo Han
2013-12-20 5:02 ` [PATCH 6/8] mtd: nuc900_nand: " Jingoo Han
2013-12-20 5:04 ` [PATCH 7/8] mtd: plat_nand: " Jingoo Han
2014-01-03 1:17 ` Brian Norris
2014-01-03 1:21 ` Brian Norris
2014-01-03 1:27 ` Jingoo Han
2014-01-03 18:16 ` Brian Norris
2013-12-20 5:05 ` [PATCH 8/8] mtd: tmio_nand: " Jingoo Han
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.