aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:06 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 00:08:31 -0400
commita81b0f73d10add406fca13c91c73e6a3cd505b46 (patch)
treed49670718825f01f97aebf250b769bb46876df1d /drivers
parent05639bcb4b0d509090026e836addaa3b28a14d14 (diff)
hwmon: (g760a) 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')
-rw-r--r--drivers/hwmon/g760a.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/hwmon/g760a.c b/drivers/hwmon/g760a.c
index ebcd2698e4dc..8b2106f60eda 100644
--- a/drivers/hwmon/g760a.c
+++ b/drivers/hwmon/g760a.c
@@ -207,7 +207,8 @@ static int g760a_probe(struct i2c_client *client,
207 I2C_FUNC_SMBUS_BYTE_DATA)) 207 I2C_FUNC_SMBUS_BYTE_DATA))
208 return -EIO; 208 return -EIO;
209 209
210 data = kzalloc(sizeof(struct g760a_data), GFP_KERNEL); 210 data = devm_kzalloc(&client->dev, sizeof(struct g760a_data),
211 GFP_KERNEL);
211 if (!data) 212 if (!data)
212 return -ENOMEM; 213 return -ENOMEM;
213 214
@@ -223,7 +224,7 @@ static int g760a_probe(struct i2c_client *client,
223 /* Register sysfs hooks */ 224 /* Register sysfs hooks */
224 err = sysfs_create_group(&client->dev.kobj, &g760a_group); 225 err = sysfs_create_group(&client->dev.kobj, &g760a_group);
225 if (err) 226 if (err)
226 goto error_sysfs_create_group; 227 return err;
227 228
228 data->hwmon_dev = hwmon_device_register(&client->dev); 229 data->hwmon_dev = hwmon_device_register(&client->dev);
229 if (IS_ERR(data->hwmon_dev)) { 230 if (IS_ERR(data->hwmon_dev)) {
@@ -235,9 +236,6 @@ static int g760a_probe(struct i2c_client *client,
235 236
236error_hwmon_device_register: 237error_hwmon_device_register:
237 sysfs_remove_group(&client->dev.kobj, &g760a_group); 238 sysfs_remove_group(&client->dev.kobj, &g760a_group);
238error_sysfs_create_group:
239 kfree(data);
240
241 return err; 239 return err;
242} 240}
243 241
@@ -246,8 +244,6 @@ static int g760a_remove(struct i2c_client *client)
246 struct g760a_data *data = i2c_get_clientdata(client); 244 struct g760a_data *data = i2c_get_clientdata(client);
247 hwmon_device_unregister(data->hwmon_dev); 245 hwmon_device_unregister(data->hwmon_dev);
248 sysfs_remove_group(&client->dev.kobj, &g760a_group); 246 sysfs_remove_group(&client->dev.kobj, &g760a_group);
249 kfree(data);
250
251 return 0; 247 return 0;
252} 248}
253 249