diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 14:20:20 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:41 -0400 |
commit | 60c2b5697560b0216ddbebaabebd1aac7abe3012 (patch) | |
tree | 49cb840c9b66e6a55a14667052d4c928ba287b71 /drivers/hwmon/pcf8591.c | |
parent | 96f316c24c0aea2984c90170966d9a2cb93d1094 (diff) |
hwmon: (pcf8591) 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>
Diffstat (limited to 'drivers/hwmon/pcf8591.c')
-rw-r--r-- | drivers/hwmon/pcf8591.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/hwmon/pcf8591.c b/drivers/hwmon/pcf8591.c index 4174c7463d70..825883d29002 100644 --- a/drivers/hwmon/pcf8591.c +++ b/drivers/hwmon/pcf8591.c | |||
@@ -200,11 +200,10 @@ static int pcf8591_probe(struct i2c_client *client, | |||
200 | struct pcf8591_data *data; | 200 | struct pcf8591_data *data; |
201 | int err; | 201 | int err; |
202 | 202 | ||
203 | data = kzalloc(sizeof(struct pcf8591_data), GFP_KERNEL); | 203 | data = devm_kzalloc(&client->dev, sizeof(struct pcf8591_data), |
204 | if (!data) { | 204 | GFP_KERNEL); |
205 | err = -ENOMEM; | 205 | if (!data) |
206 | goto exit; | 206 | return -ENOMEM; |
207 | } | ||
208 | 207 | ||
209 | i2c_set_clientdata(client, data); | 208 | i2c_set_clientdata(client, data); |
210 | mutex_init(&data->update_lock); | 209 | mutex_init(&data->update_lock); |
@@ -215,7 +214,7 @@ static int pcf8591_probe(struct i2c_client *client, | |||
215 | /* Register sysfs hooks */ | 214 | /* Register sysfs hooks */ |
216 | err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group); | 215 | err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group); |
217 | if (err) | 216 | if (err) |
218 | goto exit_kfree; | 217 | return err; |
219 | 218 | ||
220 | /* Register input2 if not in "two differential inputs" mode */ | 219 | /* Register input2 if not in "two differential inputs" mode */ |
221 | if (input_mode != 3) { | 220 | if (input_mode != 3) { |
@@ -242,9 +241,6 @@ static int pcf8591_probe(struct i2c_client *client, | |||
242 | exit_sysfs_remove: | 241 | exit_sysfs_remove: |
243 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); | 242 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); |
244 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); | 243 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); |
245 | exit_kfree: | ||
246 | kfree(data); | ||
247 | exit: | ||
248 | return err; | 244 | return err; |
249 | } | 245 | } |
250 | 246 | ||
@@ -255,7 +251,6 @@ static int pcf8591_remove(struct i2c_client *client) | |||
255 | hwmon_device_unregister(data->hwmon_dev); | 251 | hwmon_device_unregister(data->hwmon_dev); |
256 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); | 252 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); |
257 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); | 253 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); |
258 | kfree(i2c_get_clientdata(client)); | ||
259 | return 0; | 254 | return 0; |
260 | } | 255 | } |
261 | 256 | ||