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>

authored by Amit Kushwaha and committed by Guenter Roeck b6621df5 72106c18

+7 -16
+7 -16
drivers/watchdog/cpwd.c
··· 538 if (cpwd_device) 539 return -EINVAL; 540 541 - p = kzalloc(sizeof(*p), GFP_KERNEL); 542 - err = -ENOMEM; 543 - if (!p) { 544 - pr_err("Unable to allocate struct cpwd\n"); 545 - goto out; 546 - } 547 548 p->irq = op->archdata.irqs[0]; 549 ··· 550 4 * WD_TIMER_REGSZ, DRIVER_NAME); 551 if (!p->regs) { 552 pr_err("Unable to map registers\n"); 553 - goto out_free; 554 } 555 556 options = of_find_node_by_path("/options"); 557 - err = -ENODEV; 558 if (!options) { 559 pr_err("Unable to find /options node\n"); 560 goto out_iounmap; 561 } ··· 617 618 platform_set_drvdata(op, p); 619 cpwd_device = p; 620 - err = 0; 621 - 622 - out: 623 - return err; 624 625 out_unregister: 626 for (i--; i >= 0; i--) ··· 626 out_iounmap: 627 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); 628 629 - out_free: 630 - kfree(p); 631 - goto out; 632 } 633 634 static int cpwd_remove(struct platform_device *op) ··· 651 free_irq(p->irq, p); 652 653 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); 654 - kfree(p); 655 656 cpwd_device = NULL; 657
··· 538 if (cpwd_device) 539 return -EINVAL; 540 541 + p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL); 542 + if (!p) 543 + return -ENOMEM; 544 545 p->irq = op->archdata.irqs[0]; 546 ··· 553 4 * WD_TIMER_REGSZ, DRIVER_NAME); 554 if (!p->regs) { 555 pr_err("Unable to map registers\n"); 556 + return -ENOMEM; 557 } 558 559 options = of_find_node_by_path("/options"); 560 if (!options) { 561 + err = -ENODEV; 562 pr_err("Unable to find /options node\n"); 563 goto out_iounmap; 564 } ··· 620 621 platform_set_drvdata(op, p); 622 cpwd_device = p; 623 + return 0; 624 625 out_unregister: 626 for (i--; i >= 0; i--) ··· 632 out_iounmap: 633 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); 634 635 + return err; 636 } 637 638 static int cpwd_remove(struct platform_device *op) ··· 659 free_irq(p->irq, p); 660 661 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); 662 663 cpwd_device = NULL; 664