summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ads7871.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 18:58:00 +0200
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 06:08:30 +0200
commit33fd2b84c94f978e661c20267548b736d84f4645 (patch)
tree6ae296549c84ef3f9660fea546ad2937c7b97e4d /drivers/hwmon/ads7871.c
parenthwmon: (ads7828) Convert to use devm_ functions (diff)
downloadlinux-33fd2b84c94f978e661c20267548b736d84f4645.tar.xz
linux-33fd2b84c94f978e661c20267548b736d84f4645.zip
hwmon: (ads7871) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/ads7871.c')
-rw-r--r--drivers/hwmon/ads7871.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index 7bf4ce3d405e..1b53aa42b6db 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -198,20 +198,17 @@ static int __devinit ads7871_probe(struct spi_device *spi)
* because there is no other error checking on an SPI bus
* we need to make sure we really have a chip
*/
- if (val != ret) {
- err = -ENODEV;
- goto exit;
- }
+ if (val != ret)
+ return -ENODEV;
- pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL);
- if (!pdata) {
- err = -ENOMEM;
- goto exit;
- }
+ pdata = devm_kzalloc(&spi->dev, sizeof(struct ads7871_data),
+ GFP_KERNEL);
+ if (!pdata)
+ return -ENOMEM;
err = sysfs_create_group(&spi->dev.kobj, &ads7871_group);
if (err < 0)
- goto error_free;
+ return err;
spi_set_drvdata(spi, pdata);
@@ -225,9 +222,6 @@ static int __devinit ads7871_probe(struct spi_device *spi)
error_remove:
sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
-error_free:
- kfree(pdata);
-exit:
return err;
}
@@ -237,7 +231,6 @@ static int __devexit ads7871_remove(struct spi_device *spi)
hwmon_device_unregister(pdata->hwmon_dev);
sysfs_remove_group(&spi->dev.kobj, &ads7871_group);
- kfree(pdata);
return 0;
}