summaryrefslogtreecommitdiff
path: root/drivers/uio
diff options
context:
space:
mode:
authorAlexandru Ardelean <alexandru.ardelean@analog.com>2020-11-11 13:22:41 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-13 16:37:06 +0100
commitcfd3443e2d32a655871a445b3509e5df96fa7581 (patch)
tree6a2ae47d639e801cb54af380de5c4edfdabdb6b7 /drivers/uio
parent439e8f6f1e5d1ca973da278499078e213dad63bb (diff)
uio: pruss: move simple allocations to dem_ equivalents
This change moves the simple allocations to their device-managed equivalents. This cleans up some error/exit paths. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Link: https://lore.kernel.org/r/20201111112242.62116-1-alexandru.ardelean@analog.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/uio')
-rw-r--r--drivers/uio/uio_pruss.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index 1cc175d3c25c..41470c4dba02 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -99,7 +99,6 @@ static void pruss_cleanup(struct device *dev, struct uio_pruss_dev *gdev)
for (cnt = 0; cnt < MAX_PRUSS_EVT; cnt++, p++) {
uio_unregister_device(p);
- kfree(p->name);
}
iounmap(gdev->prussio_vaddr);
if (gdev->ddr_vaddr) {
@@ -110,10 +109,8 @@ static void pruss_cleanup(struct device *dev, struct uio_pruss_dev *gdev)
gen_pool_free(gdev->sram_pool,
gdev->sram_vaddr,
sram_pool_sz);
- kfree(gdev->info);
clk_disable(gdev->pruss_clk);
clk_put(gdev->pruss_clk);
- kfree(gdev);
}
static int pruss_probe(struct platform_device *pdev)
@@ -125,22 +122,19 @@ static int pruss_probe(struct platform_device *pdev)
int ret, cnt, i, len;
struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
- gdev = kzalloc(sizeof(struct uio_pruss_dev), GFP_KERNEL);
+ gdev = devm_kzalloc(dev, sizeof(struct uio_pruss_dev), GFP_KERNEL);
if (!gdev)
return -ENOMEM;
- gdev->info = kcalloc(MAX_PRUSS_EVT, sizeof(*p), GFP_KERNEL);
- if (!gdev->info) {
- ret = -ENOMEM;
- goto err_free_gdev;
- }
+ gdev->info = devm_kcalloc(dev, MAX_PRUSS_EVT, sizeof(*p), GFP_KERNEL);
+ if (!gdev->info)
+ return -ENOMEM;
/* Power on PRU in case its not done as part of boot-loader */
gdev->pruss_clk = clk_get(dev, "pruss");
if (IS_ERR(gdev->pruss_clk)) {
dev_err(dev, "Failed to get clock\n");
- ret = PTR_ERR(gdev->pruss_clk);
- goto err_free_info;
+ return PTR_ERR(gdev->pruss_clk);
}
ret = clk_enable(gdev->pruss_clk);
@@ -206,7 +200,7 @@ static int pruss_probe(struct platform_device *pdev)
p->mem[2].size = extram_pool_sz;
p->mem[2].memtype = UIO_MEM_PHYS;
- p->name = kasprintf(GFP_KERNEL, "pruss_evt%d", cnt);
+ p->name = devm_kasprintf(dev, GFP_KERNEL, "pruss_evt%d", cnt);
p->version = DRV_VERSION;
/* Register PRUSS IRQ lines */
@@ -215,10 +209,8 @@ static int pruss_probe(struct platform_device *pdev)
p->priv = gdev;
ret = uio_register_device(dev, p);
- if (ret < 0) {
- kfree(p->name);
+ if (ret < 0)
goto err_unloop;
- }
}
platform_set_drvdata(pdev, gdev);
@@ -227,7 +219,6 @@ static int pruss_probe(struct platform_device *pdev)
err_unloop:
for (i = 0, p = gdev->info; i < cnt; i++, p++) {
uio_unregister_device(p);
- kfree(p->name);
}
iounmap(gdev->prussio_vaddr);
err_free_ddr_vaddr:
@@ -240,10 +231,6 @@ err_clk_disable:
clk_disable(gdev->pruss_clk);
err_clk_put:
clk_put(gdev->pruss_clk);
-err_free_info:
- kfree(gdev->info);
-err_free_gdev:
- kfree(gdev);
return ret;
}