diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-16 21:24:02 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:40 -0400 |
commit | 52714c04df4b12ca308a1d792d50681df43365c2 (patch) | |
tree | e40f230a13530514c59e4d7d06abff9c55e005a6 | |
parent | efd2d117aeb5f01cc9c90e56fff29d4a5f535580 (diff) |
hwmon: (lm77) 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>
Acked-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r-- | drivers/hwmon/lm77.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 3ccc23a0c7f5..f82acf67acf5 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -343,11 +343,9 @@ static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
343 | struct lm77_data *data; | 343 | struct lm77_data *data; |
344 | int err; | 344 | int err; |
345 | 345 | ||
346 | data = kzalloc(sizeof(struct lm77_data), GFP_KERNEL); | 346 | data = devm_kzalloc(dev, sizeof(struct lm77_data), GFP_KERNEL); |
347 | if (!data) { | 347 | if (!data) |
348 | err = -ENOMEM; | 348 | return -ENOMEM; |
349 | goto exit; | ||
350 | } | ||
351 | 349 | ||
352 | i2c_set_clientdata(client, data); | 350 | i2c_set_clientdata(client, data); |
353 | data->valid = 0; | 351 | data->valid = 0; |
@@ -359,7 +357,7 @@ static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
359 | /* Register sysfs hooks */ | 357 | /* Register sysfs hooks */ |
360 | err = sysfs_create_group(&dev->kobj, &lm77_group); | 358 | err = sysfs_create_group(&dev->kobj, &lm77_group); |
361 | if (err) | 359 | if (err) |
362 | goto exit_free; | 360 | return err; |
363 | 361 | ||
364 | data->hwmon_dev = hwmon_device_register(dev); | 362 | data->hwmon_dev = hwmon_device_register(dev); |
365 | if (IS_ERR(data->hwmon_dev)) { | 363 | if (IS_ERR(data->hwmon_dev)) { |
@@ -371,9 +369,6 @@ static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
371 | 369 | ||
372 | exit_remove: | 370 | exit_remove: |
373 | sysfs_remove_group(&dev->kobj, &lm77_group); | 371 | sysfs_remove_group(&dev->kobj, &lm77_group); |
374 | exit_free: | ||
375 | kfree(data); | ||
376 | exit: | ||
377 | return err; | 372 | return err; |
378 | } | 373 | } |
379 | 374 | ||
@@ -382,7 +377,6 @@ static int lm77_remove(struct i2c_client *client) | |||
382 | struct lm77_data *data = i2c_get_clientdata(client); | 377 | struct lm77_data *data = i2c_get_clientdata(client); |
383 | hwmon_device_unregister(data->hwmon_dev); | 378 | hwmon_device_unregister(data->hwmon_dev); |
384 | sysfs_remove_group(&client->dev.kobj, &lm77_group); | 379 | sysfs_remove_group(&client->dev.kobj, &lm77_group); |
385 | kfree(data); | ||
386 | return 0; | 380 | return 0; |
387 | } | 381 | } |
388 | 382 | ||