Commit f760bf29 authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal

mtd: rawnand: fsl_upm: Allocate the fsl_upm_nand object using devm_kzalloc()

This simplifies the init error path and remove function.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200603134922.1352340-4-boris.brezillon@collabora.com
parent 5290833c
...@@ -205,36 +205,34 @@ static int fun_probe(struct platform_device *ofdev) ...@@ -205,36 +205,34 @@ static int fun_probe(struct platform_device *ofdev)
int size; int size;
int i; int i;
fun = kzalloc(sizeof(*fun), GFP_KERNEL); fun = devm_kzalloc(&ofdev->dev, sizeof(*fun), GFP_KERNEL);
if (!fun) if (!fun)
return -ENOMEM; return -ENOMEM;
ret = of_address_to_resource(ofdev->dev.of_node, 0, &io_res); ret = of_address_to_resource(ofdev->dev.of_node, 0, &io_res);
if (ret) { if (ret) {
dev_err(&ofdev->dev, "can't get IO base\n"); dev_err(&ofdev->dev, "can't get IO base\n");
goto err1; return ret;
} }
ret = fsl_upm_find(io_res.start, &fun->upm); ret = fsl_upm_find(io_res.start, &fun->upm);
if (ret) { if (ret) {
dev_err(&ofdev->dev, "can't find UPM\n"); dev_err(&ofdev->dev, "can't find UPM\n");
goto err1; return ret;
} }
prop = of_get_property(ofdev->dev.of_node, "fsl,upm-addr-offset", prop = of_get_property(ofdev->dev.of_node, "fsl,upm-addr-offset",
&size); &size);
if (!prop || size != sizeof(uint32_t)) { if (!prop || size != sizeof(uint32_t)) {
dev_err(&ofdev->dev, "can't get UPM address offset\n"); dev_err(&ofdev->dev, "can't get UPM address offset\n");
ret = -EINVAL; return -EINVAL;
goto err1;
} }
fun->upm_addr_offset = *prop; fun->upm_addr_offset = *prop;
prop = of_get_property(ofdev->dev.of_node, "fsl,upm-cmd-offset", &size); prop = of_get_property(ofdev->dev.of_node, "fsl,upm-cmd-offset", &size);
if (!prop || size != sizeof(uint32_t)) { if (!prop || size != sizeof(uint32_t)) {
dev_err(&ofdev->dev, "can't get UPM command offset\n"); dev_err(&ofdev->dev, "can't get UPM command offset\n");
ret = -EINVAL; return -EINVAL;
goto err1;
} }
fun->upm_cmd_offset = *prop; fun->upm_cmd_offset = *prop;
...@@ -244,7 +242,7 @@ static int fun_probe(struct platform_device *ofdev) ...@@ -244,7 +242,7 @@ static int fun_probe(struct platform_device *ofdev)
fun->mchip_count = size / sizeof(uint32_t); fun->mchip_count = size / sizeof(uint32_t);
if (fun->mchip_count >= NAND_MAX_CHIPS) { if (fun->mchip_count >= NAND_MAX_CHIPS) {
dev_err(&ofdev->dev, "too much multiple chips\n"); dev_err(&ofdev->dev, "too much multiple chips\n");
goto err1; return -EINVAL;
} }
for (i = 0; i < fun->mchip_count; i++) for (i = 0; i < fun->mchip_count; i++)
fun->mchip_offsets[i] = be32_to_cpu(prop[i]); fun->mchip_offsets[i] = be32_to_cpu(prop[i]);
...@@ -306,8 +304,6 @@ static int fun_probe(struct platform_device *ofdev) ...@@ -306,8 +304,6 @@ static int fun_probe(struct platform_device *ofdev)
break; break;
gpio_free(fun->rnb_gpio[i]); gpio_free(fun->rnb_gpio[i]);
} }
err1:
kfree(fun);
return ret; return ret;
} }
...@@ -330,8 +326,6 @@ static int fun_remove(struct platform_device *ofdev) ...@@ -330,8 +326,6 @@ static int fun_remove(struct platform_device *ofdev)
gpio_free(fun->rnb_gpio[i]); gpio_free(fun->rnb_gpio[i]);
} }
kfree(fun);
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