diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 14:20:22 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-09-24 00:08:32 -0400 |
commit | a844af19b9a8c3bcd1169f60916b0f7c40b6295f (patch) | |
tree | 380b8c64d12d949835b66862a0e4240c6a2f1f15 /drivers/hwmon/sht21.c | |
parent | 38fe7560a391cba81ec7fc5b169b764819632060 (diff) |
hwmon: (sht21) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code.
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Cc: Urs Fleisch <urs.fleisch@sensirion.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/sht21.c')
-rw-r--r-- | drivers/hwmon/sht21.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/hwmon/sht21.c b/drivers/hwmon/sht21.c index 6c2dede4b8e7..c2565d04cd4a 100644 --- a/drivers/hwmon/sht21.c +++ b/drivers/hwmon/sht21.c | |||
@@ -199,11 +199,10 @@ static int __devinit sht21_probe(struct i2c_client *client, | |||
199 | return -ENODEV; | 199 | return -ENODEV; |
200 | } | 200 | } |
201 | 201 | ||
202 | sht21 = kzalloc(sizeof(*sht21), GFP_KERNEL); | 202 | sht21 = devm_kzalloc(&client->dev, sizeof(*sht21), GFP_KERNEL); |
203 | if (!sht21) { | 203 | if (!sht21) |
204 | dev_dbg(&client->dev, "kzalloc failed\n"); | ||
205 | return -ENOMEM; | 204 | return -ENOMEM; |
206 | } | 205 | |
207 | i2c_set_clientdata(client, sht21); | 206 | i2c_set_clientdata(client, sht21); |
208 | 207 | ||
209 | mutex_init(&sht21->lock); | 208 | mutex_init(&sht21->lock); |
@@ -211,7 +210,7 @@ static int __devinit sht21_probe(struct i2c_client *client, | |||
211 | err = sysfs_create_group(&client->dev.kobj, &sht21_attr_group); | 210 | err = sysfs_create_group(&client->dev.kobj, &sht21_attr_group); |
212 | if (err) { | 211 | if (err) { |
213 | dev_dbg(&client->dev, "could not create sysfs files\n"); | 212 | dev_dbg(&client->dev, "could not create sysfs files\n"); |
214 | goto fail_free; | 213 | return err; |
215 | } | 214 | } |
216 | sht21->hwmon_dev = hwmon_device_register(&client->dev); | 215 | sht21->hwmon_dev = hwmon_device_register(&client->dev); |
217 | if (IS_ERR(sht21->hwmon_dev)) { | 216 | if (IS_ERR(sht21->hwmon_dev)) { |
@@ -226,9 +225,6 @@ static int __devinit sht21_probe(struct i2c_client *client, | |||
226 | 225 | ||
227 | fail_remove_sysfs: | 226 | fail_remove_sysfs: |
228 | sysfs_remove_group(&client->dev.kobj, &sht21_attr_group); | 227 | sysfs_remove_group(&client->dev.kobj, &sht21_attr_group); |
229 | fail_free: | ||
230 | kfree(sht21); | ||
231 | |||
232 | return err; | 228 | return err; |
233 | } | 229 | } |
234 | 230 | ||
@@ -242,7 +238,6 @@ static int __devexit sht21_remove(struct i2c_client *client) | |||
242 | 238 | ||
243 | hwmon_device_unregister(sht21->hwmon_dev); | 239 | hwmon_device_unregister(sht21->hwmon_dev); |
244 | sysfs_remove_group(&client->dev.kobj, &sht21_attr_group); | 240 | sysfs_remove_group(&client->dev.kobj, &sht21_attr_group); |
245 | kfree(sht21); | ||
246 | 241 | ||
247 | return 0; | 242 | return 0; |
248 | } | 243 | } |