Commit f7b5e849 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Brian Norris

mtd: sh_flctl: use devm_* managed allocators

This simplifies error and cleanup code paths.

Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 82ae816e
...@@ -1094,38 +1094,32 @@ static int flctl_probe(struct platform_device *pdev) ...@@ -1094,38 +1094,32 @@ static int flctl_probe(struct platform_device *pdev)
struct mtd_info *flctl_mtd; struct mtd_info *flctl_mtd;
struct nand_chip *nand; struct nand_chip *nand;
struct sh_flctl_platform_data *pdata; struct sh_flctl_platform_data *pdata;
int ret = -ENXIO; int ret;
int irq; int irq;
struct mtd_part_parser_data ppdata = {}; struct mtd_part_parser_data ppdata = {};
flctl = kzalloc(sizeof(struct sh_flctl), GFP_KERNEL); flctl = devm_kzalloc(&pdev->dev, sizeof(struct sh_flctl), GFP_KERNEL);
if (!flctl) { if (!flctl) {
dev_err(&pdev->dev, "failed to allocate driver data\n"); dev_err(&pdev->dev, "failed to allocate driver data\n");
return -ENOMEM; return -ENOMEM;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { flctl->reg = devm_ioremap_resource(&pdev->dev, res);
dev_err(&pdev->dev, "failed to get I/O memory\n"); if (IS_ERR(flctl->reg))
goto err_iomap; return PTR_ERR(flctl->reg);
}
flctl->reg = ioremap(res->start, resource_size(res));
if (flctl->reg == NULL) {
dev_err(&pdev->dev, "failed to remap I/O memory\n");
goto err_iomap;
}
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(&pdev->dev, "failed to get flste irq data\n"); dev_err(&pdev->dev, "failed to get flste irq data\n");
goto err_flste; return -ENXIO;
} }
ret = request_irq(irq, flctl_handle_flste, IRQF_SHARED, "flste", flctl); ret = devm_request_irq(&pdev->dev, irq, flctl_handle_flste, IRQF_SHARED,
"flste", flctl);
if (ret) { if (ret) {
dev_err(&pdev->dev, "request interrupt failed.\n"); dev_err(&pdev->dev, "request interrupt failed.\n");
goto err_flste; return ret;
} }
if (pdev->dev.of_node) if (pdev->dev.of_node)
...@@ -1135,8 +1129,7 @@ static int flctl_probe(struct platform_device *pdev) ...@@ -1135,8 +1129,7 @@ static int flctl_probe(struct platform_device *pdev)
if (!pdata) { if (!pdata) {
dev_err(&pdev->dev, "no setup data defined\n"); dev_err(&pdev->dev, "no setup data defined\n");
ret = -EINVAL; return -EINVAL;
goto err_pdata;
} }
platform_set_drvdata(pdev, flctl); platform_set_drvdata(pdev, flctl);
...@@ -1190,12 +1183,6 @@ static int flctl_probe(struct platform_device *pdev) ...@@ -1190,12 +1183,6 @@ static int flctl_probe(struct platform_device *pdev)
err_chip: err_chip:
flctl_release_dma(flctl); flctl_release_dma(flctl);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_pdata:
free_irq(irq, flctl);
err_flste:
iounmap(flctl->reg);
err_iomap:
kfree(flctl);
return ret; return ret;
} }
...@@ -1206,9 +1193,6 @@ static int flctl_remove(struct platform_device *pdev) ...@@ -1206,9 +1193,6 @@ static int flctl_remove(struct platform_device *pdev)
flctl_release_dma(flctl); flctl_release_dma(flctl);
nand_release(&flctl->mtd); nand_release(&flctl->mtd);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
free_irq(platform_get_irq(pdev, 0), flctl);
iounmap(flctl->reg);
kfree(flctl);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment