提交 2b0b5e2d 编写于 作者: L Lee Jones 提交者: Samuel Ortiz

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

Signed-off-by: NLee Jones <lee.jones@linaro.org>
Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
上级 58645b36
...@@ -514,8 +514,8 @@ static int htcpld_setup_chips(struct platform_device *pdev) ...@@ -514,8 +514,8 @@ static int htcpld_setup_chips(struct platform_device *pdev)
/* Setup each chip's output GPIOs */ /* Setup each chip's output GPIOs */
htcpld->nchips = pdata->num_chip; htcpld->nchips = pdata->num_chip;
htcpld->chip = kzalloc(sizeof(struct htcpld_chip) * htcpld->nchips, htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips,
GFP_KERNEL); GFP_KERNEL);
if (!htcpld->chip) { if (!htcpld->chip) {
dev_warn(dev, "Unable to allocate memory for chips\n"); dev_warn(dev, "Unable to allocate memory for chips\n");
return -ENOMEM; return -ENOMEM;
...@@ -580,12 +580,11 @@ static int htcpld_core_probe(struct platform_device *pdev) ...@@ -580,12 +580,11 @@ static int htcpld_core_probe(struct platform_device *pdev)
return -ENXIO; return -ENXIO;
} }
htcpld = kzalloc(sizeof(struct htcpld_data), GFP_KERNEL); htcpld = devm_kzalloc(dev, sizeof(struct htcpld_data), GFP_KERNEL);
if (!htcpld) if (!htcpld)
return -ENOMEM; return -ENOMEM;
/* Find chained irq */ /* Find chained irq */
ret = -EINVAL;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res) { if (res) {
int flags; int flags;
...@@ -598,7 +597,7 @@ static int htcpld_core_probe(struct platform_device *pdev) ...@@ -598,7 +597,7 @@ static int htcpld_core_probe(struct platform_device *pdev)
flags, pdev->name, htcpld); flags, pdev->name, htcpld);
if (ret) { if (ret) {
dev_warn(dev, "Unable to setup chained irq handler: %d\n", ret); dev_warn(dev, "Unable to setup chained irq handler: %d\n", ret);
goto fail; return ret;
} else } else
device_init_wakeup(dev, 0); device_init_wakeup(dev, 0);
} }
...@@ -609,7 +608,7 @@ static int htcpld_core_probe(struct platform_device *pdev) ...@@ -609,7 +608,7 @@ static int htcpld_core_probe(struct platform_device *pdev)
/* Setup the htcpld chips */ /* Setup the htcpld chips */
ret = htcpld_setup_chips(pdev); ret = htcpld_setup_chips(pdev);
if (ret) if (ret)
goto fail; return ret;
/* Request the GPIO(s) for the int reset and set them up */ /* Request the GPIO(s) for the int reset and set them up */
if (pdata->int_reset_gpio_hi) { if (pdata->int_reset_gpio_hi) {
...@@ -644,10 +643,6 @@ static int htcpld_core_probe(struct platform_device *pdev) ...@@ -644,10 +643,6 @@ static int htcpld_core_probe(struct platform_device *pdev)
dev_info(dev, "Initialized successfully\n"); dev_info(dev, "Initialized successfully\n");
return 0; return 0;
fail:
kfree(htcpld);
return ret;
} }
/* The I2C Driver -- used internally */ /* The I2C Driver -- used internally */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册