aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 14:52:24 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:43 -0400
commit6e13bb06f62f11797ceb5f28c392f703dc0aa548 (patch)
tree75afc8b49d45718424652a7fa195897ef31d8c97
parent140849e105fd0aadab035923f4cb454ce0518887 (diff)
hwmon: (w83791d) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Marc Hulsman <m.hulsman@tudelft.nl> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/hwmon/w83791d.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 2f446f92acf2..9ade4d4e2185 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -1384,18 +1384,17 @@ static int w83791d_probe(struct i2c_client *client,
1384 (val1 >> 5) & 0x07, (val1 >> 1) & 0x0f, val1); 1384 (val1 >> 5) & 0x07, (val1 >> 1) & 0x0f, val1);
1385#endif 1385#endif
1386 1386
1387 data = kzalloc(sizeof(struct w83791d_data), GFP_KERNEL); 1387 data = devm_kzalloc(&client->dev, sizeof(struct w83791d_data),
1388 if (!data) { 1388 GFP_KERNEL);
1389 err = -ENOMEM; 1389 if (!data)
1390 goto error0; 1390 return -ENOMEM;
1391 }
1392 1391
1393 i2c_set_clientdata(client, data); 1392 i2c_set_clientdata(client, data);
1394 mutex_init(&data->update_lock); 1393 mutex_init(&data->update_lock);
1395 1394
1396 err = w83791d_detect_subclients(client); 1395 err = w83791d_detect_subclients(client);
1397 if (err) 1396 if (err)
1398 goto error1; 1397 return err;
1399 1398
1400 /* Initialize the chip */ 1399 /* Initialize the chip */
1401 w83791d_init_client(client); 1400 w83791d_init_client(client);
@@ -1440,9 +1439,6 @@ error3:
1440 i2c_unregister_device(data->lm75[0]); 1439 i2c_unregister_device(data->lm75[0]);
1441 if (data->lm75[1] != NULL) 1440 if (data->lm75[1] != NULL)
1442 i2c_unregister_device(data->lm75[1]); 1441 i2c_unregister_device(data->lm75[1]);
1443error1:
1444 kfree(data);
1445error0:
1446 return err; 1442 return err;
1447} 1443}
1448 1444
@@ -1458,7 +1454,6 @@ static int w83791d_remove(struct i2c_client *client)
1458 if (data->lm75[1] != NULL) 1454 if (data->lm75[1] != NULL)
1459 i2c_unregister_device(data->lm75[1]); 1455 i2c_unregister_device(data->lm75[1]);
1460 1456
1461 kfree(data);
1462 return 0; 1457 return 0;
1463} 1458}
1464 1459