diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 15:04:06 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:43 -0400 |
commit | e43d5fefa7fe4e5d0999033753c15e1f30e06ff6 (patch) | |
tree | b896d1667c980b3aca4fb549b092f5c119736bcf /drivers/hwmon | |
parent | a0d44cbcc0b92d1dbec5dda3a5b7ea929c05d522 (diff) |
hwmon: (smsc47b397) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code.
Cc: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/smsc47b397.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index c5f6be478bad..65b07de11a0f 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -231,13 +231,9 @@ static const struct attribute_group smsc47b397_group = { | |||
231 | static int __devexit smsc47b397_remove(struct platform_device *pdev) | 231 | static int __devexit smsc47b397_remove(struct platform_device *pdev) |
232 | { | 232 | { |
233 | struct smsc47b397_data *data = platform_get_drvdata(pdev); | 233 | struct smsc47b397_data *data = platform_get_drvdata(pdev); |
234 | struct resource *res; | ||
235 | 234 | ||
236 | hwmon_device_unregister(data->hwmon_dev); | 235 | hwmon_device_unregister(data->hwmon_dev); |
237 | sysfs_remove_group(&pdev->dev.kobj, &smsc47b397_group); | 236 | sysfs_remove_group(&pdev->dev.kobj, &smsc47b397_group); |
238 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
239 | release_region(res->start, SMSC_EXTENT); | ||
240 | kfree(data); | ||
241 | 237 | ||
242 | return 0; | 238 | return 0; |
243 | } | 239 | } |
@@ -261,19 +257,17 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) | |||
261 | int err = 0; | 257 | int err = 0; |
262 | 258 | ||
263 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 259 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
264 | if (!request_region(res->start, SMSC_EXTENT, | 260 | if (!devm_request_region(dev, res->start, SMSC_EXTENT, |
265 | smsc47b397_driver.driver.name)) { | 261 | smsc47b397_driver.driver.name)) { |
266 | dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", | 262 | dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", |
267 | (unsigned long)res->start, | 263 | (unsigned long)res->start, |
268 | (unsigned long)res->start + SMSC_EXTENT - 1); | 264 | (unsigned long)res->start + SMSC_EXTENT - 1); |
269 | return -EBUSY; | 265 | return -EBUSY; |
270 | } | 266 | } |
271 | 267 | ||
272 | data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL); | 268 | data = devm_kzalloc(dev, sizeof(struct smsc47b397_data), GFP_KERNEL); |
273 | if (!data) { | 269 | if (!data) |
274 | err = -ENOMEM; | 270 | return -ENOMEM; |
275 | goto error_release; | ||
276 | } | ||
277 | 271 | ||
278 | data->addr = res->start; | 272 | data->addr = res->start; |
279 | data->name = "smsc47b397"; | 273 | data->name = "smsc47b397"; |
@@ -283,7 +277,7 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) | |||
283 | 277 | ||
284 | err = sysfs_create_group(&dev->kobj, &smsc47b397_group); | 278 | err = sysfs_create_group(&dev->kobj, &smsc47b397_group); |
285 | if (err) | 279 | if (err) |
286 | goto error_free; | 280 | return err; |
287 | 281 | ||
288 | data->hwmon_dev = hwmon_device_register(dev); | 282 | data->hwmon_dev = hwmon_device_register(dev); |
289 | if (IS_ERR(data->hwmon_dev)) { | 283 | if (IS_ERR(data->hwmon_dev)) { |
@@ -295,10 +289,6 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) | |||
295 | 289 | ||
296 | error_remove: | 290 | error_remove: |
297 | sysfs_remove_group(&dev->kobj, &smsc47b397_group); | 291 | sysfs_remove_group(&dev->kobj, &smsc47b397_group); |
298 | error_free: | ||
299 | kfree(data); | ||
300 | error_release: | ||
301 | release_region(res->start, SMSC_EXTENT); | ||
302 | return err; | 292 | return err; |
303 | } | 293 | } |
304 | 294 | ||