summaryrefslogtreecommitdiff
path: root/drivers/mfd/htc-i2cpld.c
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-05-23 16:25:13 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-13 12:11:43 +0200
commit2b0b5e2dfe663f53bd07eafa01df9809edf6327e (patch)
treedb414f32af47669c0b4c848014966ea277bb1356 /drivers/mfd/htc-i2cpld.c
parent58645b36b2ce0a3468e4fd445578227797c56d81 (diff)
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>
Diffstat (limited to 'drivers/mfd/htc-i2cpld.c')
-rw-r--r--drivers/mfd/htc-i2cpld.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c
index 324187c0c124..c9dfce6ae0c2 100644
--- a/drivers/mfd/htc-i2cpld.c
+++ b/drivers/mfd/htc-i2cpld.c
@@ -514,8 +514,8 @@ static int htcpld_setup_chips(struct platform_device *pdev)
/* Setup each chip's output GPIOs */
htcpld->nchips = pdata->num_chip;
- htcpld->chip = kzalloc(sizeof(struct htcpld_chip) * htcpld->nchips,
- GFP_KERNEL);
+ htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips,
+ GFP_KERNEL);
if (!htcpld->chip) {
dev_warn(dev, "Unable to allocate memory for chips\n");
return -ENOMEM;
@@ -580,12 +580,11 @@ static int htcpld_core_probe(struct platform_device *pdev)
return -ENXIO;
}
- htcpld = kzalloc(sizeof(struct htcpld_data), GFP_KERNEL);
+ htcpld = devm_kzalloc(dev, sizeof(struct htcpld_data), GFP_KERNEL);
if (!htcpld)
return -ENOMEM;
/* Find chained irq */
- ret = -EINVAL;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res) {
int flags;
@@ -598,7 +597,7 @@ static int htcpld_core_probe(struct platform_device *pdev)
flags, pdev->name, htcpld);
if (ret) {
dev_warn(dev, "Unable to setup chained irq handler: %d\n", ret);
- goto fail;
+ return ret;
} else
device_init_wakeup(dev, 0);
}
@@ -609,7 +608,7 @@ static int htcpld_core_probe(struct platform_device *pdev)
/* Setup the htcpld chips */
ret = htcpld_setup_chips(pdev);
if (ret)
- goto fail;
+ return ret;
/* Request the GPIO(s) for the int reset and set them up */
if (pdata->int_reset_gpio_hi) {
@@ -644,10 +643,6 @@ static int htcpld_core_probe(struct platform_device *pdev)
dev_info(dev, "Initialized successfully\n");
return 0;
-
-fail:
- kfree(htcpld);
- return ret;
}
/* The I2C Driver -- used internally */