aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:03 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:39 -0400
commitd466a353052582ea784d9f5352c822d828d00244 (patch)
treefbfe41df558a6176190a1ea671135f5f411462d7
parente5ebb772c697540f42a4b74f3d14fae6ecd4de24 (diff)
hwmon: (atxp1) 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/atxp1.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index 58af6aa93530..aecb9ea7beb5 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -345,11 +345,10 @@ static int atxp1_probe(struct i2c_client *new_client,
345 struct atxp1_data *data; 345 struct atxp1_data *data;
346 int err; 346 int err;
347 347
348 data = kzalloc(sizeof(struct atxp1_data), GFP_KERNEL); 348 data = devm_kzalloc(&new_client->dev, sizeof(struct atxp1_data),
349 if (!data) { 349 GFP_KERNEL);
350 err = -ENOMEM; 350 if (!data)
351 goto exit; 351 return -ENOMEM;
352 }
353 352
354 /* Get VRM */ 353 /* Get VRM */
355 data->vrm = vid_which_vrm(); 354 data->vrm = vid_which_vrm();
@@ -362,7 +361,7 @@ static int atxp1_probe(struct i2c_client *new_client,
362 /* Register sysfs hooks */ 361 /* Register sysfs hooks */
363 err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group); 362 err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group);
364 if (err) 363 if (err)
365 goto exit_free; 364 return err;
366 365
367 data->hwmon_dev = hwmon_device_register(&new_client->dev); 366 data->hwmon_dev = hwmon_device_register(&new_client->dev);
368 if (IS_ERR(data->hwmon_dev)) { 367 if (IS_ERR(data->hwmon_dev)) {
@@ -377,9 +376,6 @@ static int atxp1_probe(struct i2c_client *new_client,
377 376
378exit_remove_files: 377exit_remove_files:
379 sysfs_remove_group(&new_client->dev.kobj, &atxp1_group); 378 sysfs_remove_group(&new_client->dev.kobj, &atxp1_group);
380exit_free:
381 kfree(data);
382exit:
383 return err; 379 return err;
384}; 380};
385 381
@@ -390,8 +386,6 @@ static int atxp1_remove(struct i2c_client *client)
390 hwmon_device_unregister(data->hwmon_dev); 386 hwmon_device_unregister(data->hwmon_dev);
391 sysfs_remove_group(&client->dev.kobj, &atxp1_group); 387 sysfs_remove_group(&client->dev.kobj, &atxp1_group);
392 388
393 kfree(data);
394
395 return 0; 389 return 0;
396}; 390};
397 391