Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: htc-i2cpld: Convert to managed resources for allocating memory

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Lee Jones and committed by
Samuel Ortiz
2b0b5e2d 58645b36

+5 -10
+5 -10
drivers/mfd/htc-i2cpld.c
··· 514 514 515 515 /* Setup each chip's output GPIOs */ 516 516 htcpld->nchips = pdata->num_chip; 517 - htcpld->chip = kzalloc(sizeof(struct htcpld_chip) * htcpld->nchips, 518 - GFP_KERNEL); 517 + htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips, 518 + GFP_KERNEL); 519 519 if (!htcpld->chip) { 520 520 dev_warn(dev, "Unable to allocate memory for chips\n"); 521 521 return -ENOMEM; ··· 580 580 return -ENXIO; 581 581 } 582 582 583 - htcpld = kzalloc(sizeof(struct htcpld_data), GFP_KERNEL); 583 + htcpld = devm_kzalloc(dev, sizeof(struct htcpld_data), GFP_KERNEL); 584 584 if (!htcpld) 585 585 return -ENOMEM; 586 586 587 587 /* Find chained irq */ 588 - ret = -EINVAL; 589 588 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 590 589 if (res) { 591 590 int flags; ··· 597 598 flags, pdev->name, htcpld); 598 599 if (ret) { 599 600 dev_warn(dev, "Unable to setup chained irq handler: %d\n", ret); 600 - goto fail; 601 + return ret; 601 602 } else 602 603 device_init_wakeup(dev, 0); 603 604 } ··· 608 609 /* Setup the htcpld chips */ 609 610 ret = htcpld_setup_chips(pdev); 610 611 if (ret) 611 - goto fail; 612 + return ret; 612 613 613 614 /* Request the GPIO(s) for the int reset and set them up */ 614 615 if (pdata->int_reset_gpio_hi) { ··· 643 644 644 645 dev_info(dev, "Initialized successfully\n"); 645 646 return 0; 646 - 647 - fail: 648 - kfree(htcpld); 649 - return ret; 650 647 } 651 648 652 649 /* The I2C Driver -- used internally */