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