aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Kushwaha <akkushwaha9896@gmail.com>2016-12-06 13:19:48 -0500
committerGuenter Roeck <linux@roeck-us.net>2016-12-16 09:53:55 -0500
commitb6621df5c87603310c3f94903bb30adbfeb9aa69 (patch)
tree8c7fb64a26c3e6fb6137910786f97f6c934cbe19
parent72106c1894aa4e26ab403282cc7617fcb07d3d4d (diff)
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>
-rw-r--r--drivers/watchdog/cpwd.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c
index 71ee07950e63..3d43775548e5 100644
--- a/drivers/watchdog/cpwd.c
+++ b/drivers/watchdog/cpwd.c
@@ -538,12 +538,9 @@ static int cpwd_probe(struct platform_device *op)
538 if (cpwd_device) 538 if (cpwd_device)
539 return -EINVAL; 539 return -EINVAL;
540 540
541 p = kzalloc(sizeof(*p), GFP_KERNEL); 541 p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL);
542 err = -ENOMEM; 542 if (!p)
543 if (!p) { 543 return -ENOMEM;
544 pr_err("Unable to allocate struct cpwd\n");
545 goto out;
546 }
547 544
548 p->irq = op->archdata.irqs[0]; 545 p->irq = op->archdata.irqs[0];
549 546
@@ -553,12 +550,12 @@ static int cpwd_probe(struct platform_device *op)
553 4 * WD_TIMER_REGSZ, DRIVER_NAME); 550 4 * WD_TIMER_REGSZ, DRIVER_NAME);
554 if (!p->regs) { 551 if (!p->regs) {
555 pr_err("Unable to map registers\n"); 552 pr_err("Unable to map registers\n");
556 goto out_free; 553 return -ENOMEM;
557 } 554 }
558 555
559 options = of_find_node_by_path("/options"); 556 options = of_find_node_by_path("/options");
560 err = -ENODEV;
561 if (!options) { 557 if (!options) {
558 err = -ENODEV;
562 pr_err("Unable to find /options node\n"); 559 pr_err("Unable to find /options node\n");
563 goto out_iounmap; 560 goto out_iounmap;
564 } 561 }
@@ -620,10 +617,7 @@ static int cpwd_probe(struct platform_device *op)
620 617
621 platform_set_drvdata(op, p); 618 platform_set_drvdata(op, p);
622 cpwd_device = p; 619 cpwd_device = p;
623 err = 0; 620 return 0;
624
625out:
626 return err;
627 621
628out_unregister: 622out_unregister:
629 for (i--; i >= 0; i--) 623 for (i--; i >= 0; i--)
@@ -632,9 +626,7 @@ out_unregister:
632out_iounmap: 626out_iounmap:
633 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); 627 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ);
634 628
635out_free: 629 return err;
636 kfree(p);
637 goto out;
638} 630}
639 631
640static int cpwd_remove(struct platform_device *op) 632static int cpwd_remove(struct platform_device *op)
@@ -659,7 +651,6 @@ static int cpwd_remove(struct platform_device *op)
659 free_irq(p->irq, p); 651 free_irq(p->irq, p);
660 652
661 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); 653 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ);
662 kfree(p);
663 654
664 cpwd_device = NULL; 655 cpwd_device = NULL;
665 656