diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 12:57:57 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-09-24 00:08:29 -0400 |
commit | 0fee6591b7f82bb293de7949297fc8db59b31f0d (patch) | |
tree | ece9293d8fd82fbf86ad144929e2ad76d71bf986 /drivers/hwmon/ad7414.c | |
parent | be92304034220ee94a34df379101f14570db331b (diff) |
hwmon: (ad7414) 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>
Diffstat (limited to 'drivers/hwmon/ad7414.c')
-rw-r--r-- | drivers/hwmon/ad7414.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/hwmon/ad7414.c b/drivers/hwmon/ad7414.c index 06d2d60d1fd0..b420fb3f3a71 100644 --- a/drivers/hwmon/ad7414.c +++ b/drivers/hwmon/ad7414.c | |||
@@ -185,16 +185,13 @@ static int ad7414_probe(struct i2c_client *client, | |||
185 | int err; | 185 | int err; |
186 | 186 | ||
187 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 187 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
188 | I2C_FUNC_SMBUS_READ_WORD_DATA)) { | 188 | I2C_FUNC_SMBUS_READ_WORD_DATA)) |
189 | err = -EOPNOTSUPP; | 189 | return -EOPNOTSUPP; |
190 | goto exit; | ||
191 | } | ||
192 | 190 | ||
193 | data = kzalloc(sizeof(struct ad7414_data), GFP_KERNEL); | 191 | data = devm_kzalloc(&client->dev, sizeof(struct ad7414_data), |
194 | if (!data) { | 192 | GFP_KERNEL); |
195 | err = -ENOMEM; | 193 | if (!data) |
196 | goto exit; | 194 | return -ENOMEM; |
197 | } | ||
198 | 195 | ||
199 | i2c_set_clientdata(client, data); | 196 | i2c_set_clientdata(client, data); |
200 | mutex_init(&data->lock); | 197 | mutex_init(&data->lock); |
@@ -214,7 +211,7 @@ static int ad7414_probe(struct i2c_client *client, | |||
214 | /* Register sysfs hooks */ | 211 | /* Register sysfs hooks */ |
215 | err = sysfs_create_group(&client->dev.kobj, &ad7414_group); | 212 | err = sysfs_create_group(&client->dev.kobj, &ad7414_group); |
216 | if (err) | 213 | if (err) |
217 | goto exit_free; | 214 | return err; |
218 | 215 | ||
219 | data->hwmon_dev = hwmon_device_register(&client->dev); | 216 | data->hwmon_dev = hwmon_device_register(&client->dev); |
220 | if (IS_ERR(data->hwmon_dev)) { | 217 | if (IS_ERR(data->hwmon_dev)) { |
@@ -226,9 +223,6 @@ static int ad7414_probe(struct i2c_client *client, | |||
226 | 223 | ||
227 | exit_remove: | 224 | exit_remove: |
228 | sysfs_remove_group(&client->dev.kobj, &ad7414_group); | 225 | sysfs_remove_group(&client->dev.kobj, &ad7414_group); |
229 | exit_free: | ||
230 | kfree(data); | ||
231 | exit: | ||
232 | return err; | 226 | return err; |
233 | } | 227 | } |
234 | 228 | ||
@@ -238,7 +232,6 @@ static int __devexit ad7414_remove(struct i2c_client *client) | |||
238 | 232 | ||
239 | hwmon_device_unregister(data->hwmon_dev); | 233 | hwmon_device_unregister(data->hwmon_dev); |
240 | sysfs_remove_group(&client->dev.kobj, &ad7414_group); | 234 | sysfs_remove_group(&client->dev.kobj, &ad7414_group); |
241 | kfree(data); | ||
242 | return 0; | 235 | return 0; |
243 | } | 236 | } |
244 | 237 | ||