watchdog: cpwd: remove memory allocate failure message

Replaced goto with a return statement and dropped the kfree()
calls because memory allocated with devm_kzalloc() is
automatically freed on driver detach

Signed-off-by: Amit Kushwaha <akkushwaha9896@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Amit Kushwaha 2016-12-06 10:19:48 -08:00 committed by Guenter Roeck
parent 72106c1894
commit b6621df5c8

View file

@ -538,12 +538,9 @@ static int cpwd_probe(struct platform_device *op)
if (cpwd_device) if (cpwd_device)
return -EINVAL; return -EINVAL;
p = kzalloc(sizeof(*p), GFP_KERNEL); p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL);
err = -ENOMEM; if (!p)
if (!p) { return -ENOMEM;
pr_err("Unable to allocate struct cpwd\n");
goto out;
}
p->irq = op->archdata.irqs[0]; p->irq = op->archdata.irqs[0];
@ -553,12 +550,12 @@ static int cpwd_probe(struct platform_device *op)
4 * WD_TIMER_REGSZ, DRIVER_NAME); 4 * WD_TIMER_REGSZ, DRIVER_NAME);
if (!p->regs) { if (!p->regs) {
pr_err("Unable to map registers\n"); pr_err("Unable to map registers\n");
goto out_free; return -ENOMEM;
} }
options = of_find_node_by_path("/options"); options = of_find_node_by_path("/options");
err = -ENODEV;
if (!options) { if (!options) {
err = -ENODEV;
pr_err("Unable to find /options node\n"); pr_err("Unable to find /options node\n");
goto out_iounmap; goto out_iounmap;
} }
@ -620,10 +617,7 @@ static int cpwd_probe(struct platform_device *op)
platform_set_drvdata(op, p); platform_set_drvdata(op, p);
cpwd_device = p; cpwd_device = p;
err = 0; return 0;
out:
return err;
out_unregister: out_unregister:
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
@ -632,9 +626,7 @@ static int cpwd_probe(struct platform_device *op)
out_iounmap: out_iounmap:
of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ);
out_free: return err;
kfree(p);
goto out;
} }
static int cpwd_remove(struct platform_device *op) static int cpwd_remove(struct platform_device *op)
@ -659,7 +651,6 @@ static int cpwd_remove(struct platform_device *op)
free_irq(p->irq, p); free_irq(p->irq, p);
of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ);
kfree(p);
cpwd_device = NULL; cpwd_device = NULL;