diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 12:58:13 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:38 -0400 |
commit | b07405fbc38f2e7f2eef2f38fa724a7510ae14aa (patch) | |
tree | 4704468230046344824f81a189b7cbf354f93ff2 /drivers/hwmon/max6639.c | |
parent | 94cd52027aa52780e56e11fd08703d955f0ff91e (diff) |
hwmon: (max6639) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code.
Cc: Roland Stigge <stigge@antcom.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Roland Stigge <stigge@antcom.de>
Diffstat (limited to 'drivers/hwmon/max6639.c')
-rw-r--r-- | drivers/hwmon/max6639.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c index de8f7adaccbd..6e60036abfa7 100644 --- a/drivers/hwmon/max6639.c +++ b/drivers/hwmon/max6639.c | |||
@@ -548,11 +548,10 @@ static int max6639_probe(struct i2c_client *client, | |||
548 | struct max6639_data *data; | 548 | struct max6639_data *data; |
549 | int err; | 549 | int err; |
550 | 550 | ||
551 | data = kzalloc(sizeof(struct max6639_data), GFP_KERNEL); | 551 | data = devm_kzalloc(&client->dev, sizeof(struct max6639_data), |
552 | if (!data) { | 552 | GFP_KERNEL); |
553 | err = -ENOMEM; | 553 | if (!data) |
554 | goto exit; | 554 | return -ENOMEM; |
555 | } | ||
556 | 555 | ||
557 | i2c_set_clientdata(client, data); | 556 | i2c_set_clientdata(client, data); |
558 | mutex_init(&data->update_lock); | 557 | mutex_init(&data->update_lock); |
@@ -560,12 +559,12 @@ static int max6639_probe(struct i2c_client *client, | |||
560 | /* Initialize the max6639 chip */ | 559 | /* Initialize the max6639 chip */ |
561 | err = max6639_init_client(client); | 560 | err = max6639_init_client(client); |
562 | if (err < 0) | 561 | if (err < 0) |
563 | goto error_free; | 562 | return err; |
564 | 563 | ||
565 | /* Register sysfs hooks */ | 564 | /* Register sysfs hooks */ |
566 | err = sysfs_create_group(&client->dev.kobj, &max6639_group); | 565 | err = sysfs_create_group(&client->dev.kobj, &max6639_group); |
567 | if (err) | 566 | if (err) |
568 | goto error_free; | 567 | return err; |
569 | 568 | ||
570 | data->hwmon_dev = hwmon_device_register(&client->dev); | 569 | data->hwmon_dev = hwmon_device_register(&client->dev); |
571 | if (IS_ERR(data->hwmon_dev)) { | 570 | if (IS_ERR(data->hwmon_dev)) { |
@@ -579,9 +578,6 @@ static int max6639_probe(struct i2c_client *client, | |||
579 | 578 | ||
580 | error_remove: | 579 | error_remove: |
581 | sysfs_remove_group(&client->dev.kobj, &max6639_group); | 580 | sysfs_remove_group(&client->dev.kobj, &max6639_group); |
582 | error_free: | ||
583 | kfree(data); | ||
584 | exit: | ||
585 | return err; | 581 | return err; |
586 | } | 582 | } |
587 | 583 | ||
@@ -592,7 +588,6 @@ static int max6639_remove(struct i2c_client *client) | |||
592 | hwmon_device_unregister(data->hwmon_dev); | 588 | hwmon_device_unregister(data->hwmon_dev); |
593 | sysfs_remove_group(&client->dev.kobj, &max6639_group); | 589 | sysfs_remove_group(&client->dev.kobj, &max6639_group); |
594 | 590 | ||
595 | kfree(data); | ||
596 | return 0; | 591 | return 0; |
597 | } | 592 | } |
598 | 593 | ||