diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 12:58:00 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-09-24 00:08:30 -0400 |
commit | 33fd2b84c94f978e661c20267548b736d84f4645 (patch) | |
tree | 6ae296549c84ef3f9660fea546ad2937c7b97e4d /drivers/hwmon/ads7871.c | |
parent | 34e3f7f5a283c5520e0e1a409931a632f4d2662e (diff) |
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.c | 21 |
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) | |||
198 | * because there is no other error checking on an SPI bus | 198 | * because there is no other error checking on an SPI bus |
199 | * we need to make sure we really have a chip | 199 | * we need to make sure we really have a chip |
200 | */ | 200 | */ |
201 | if (val != ret) { | 201 | if (val != ret) |
202 | err = -ENODEV; | 202 | return -ENODEV; |
203 | goto exit; | ||
204 | } | ||
205 | 203 | ||
206 | pdata = kzalloc(sizeof(struct ads7871_data), GFP_KERNEL); | 204 | pdata = devm_kzalloc(&spi->dev, sizeof(struct ads7871_data), |
207 | if (!pdata) { | 205 | GFP_KERNEL); |
208 | err = -ENOMEM; | 206 | if (!pdata) |
209 | goto exit; | 207 | return -ENOMEM; |
210 | } | ||
211 | 208 | ||
212 | err = sysfs_create_group(&spi->dev.kobj, &ads7871_group); | 209 | err = sysfs_create_group(&spi->dev.kobj, &ads7871_group); |
213 | if (err < 0) | 210 | if (err < 0) |
214 | goto error_free; | 211 | return err; |
215 | 212 | ||
216 | spi_set_drvdata(spi, pdata); | 213 | spi_set_drvdata(spi, pdata); |
217 | 214 | ||
@@ -225,9 +222,6 @@ static int __devinit ads7871_probe(struct spi_device *spi) | |||
225 | 222 | ||
226 | error_remove: | 223 | error_remove: |
227 | sysfs_remove_group(&spi->dev.kobj, &ads7871_group); | 224 | sysfs_remove_group(&spi->dev.kobj, &ads7871_group); |
228 | error_free: | ||
229 | kfree(pdata); | ||
230 | exit: | ||
231 | return err; | 225 | return err; |
232 | } | 226 | } |
233 | 227 | ||
@@ -237,7 +231,6 @@ static int __devexit ads7871_remove(struct spi_device *spi) | |||
237 | 231 | ||
238 | hwmon_device_unregister(pdata->hwmon_dev); | 232 | hwmon_device_unregister(pdata->hwmon_dev); |
239 | sysfs_remove_group(&spi->dev.kobj, &ads7871_group); | 233 | sysfs_remove_group(&spi->dev.kobj, &ads7871_group); |
240 | kfree(pdata); | ||
241 | return 0; | 234 | return 0; |
242 | } | 235 | } |
243 | 236 | ||