Skip to contentSkip to conversation

hwmon: (lm85) Convert to use devm_ functions

PATCH Superseded Guenter Roeck 2 participants 2 messages Jun 15, 2012 – Jun 16, 2012 Hardware monitoring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 49/95 hwmon: (lm85) Convert to use devm_ functions

Convert to use devm_ functions to reduce code size and simplify the code.

---
 drivers/hwmon/lm85.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/hwmon/lm85.c +2 -5
index 864c7d9..9f2dd77 100644
@@ -1387,7 +1387,7 @@ static int lm85_probe(struct i2c_client *client,
 	struct lm85_data *data;
 	int err;
 
-	data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL);
+	data = devm_kzalloc(&client->dev, sizeof(struct lm85_data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
@@ -1419,7 +1419,7 @@ static int lm85_probe(struct i2c_client *client,
 	/* Register sysfs hooks */
 	err = sysfs_create_group(&client->dev.kobj, &lm85_group);
 	if (err)
-		goto err_kfree;
+		return err;
 
 	/* minctl and temp_off exist on all chips except emc6d103s */
 	if (data->type != emc6d103s) {
@@ -1466,8 +1466,6 @@ static int lm85_probe(struct i2c_client *client,
 	/* Error out and cleanup code */
  err_remove_files:
 	lm85_remove_files(client, data);
- err_kfree:
-	kfree(data);
 	return err;
 }
 
@@ -1476,7 +1474,6 @@ static int lm85_remove(struct i2c_client *client)
 	struct lm85_data *data = i2c_get_clientdata(client);
 	hwmon_device_unregister(data->hwmon_dev);
 	lm85_remove_files(client, data);
-	kfree(data);
 	return 0;
 }
 
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v1 49/95
#1 lore raw
Quoted 6 lines · Guenter Roeck

Convert to use devm_ functions to reduce code size and simplify the code.

---
 drivers/hwmon/lm85.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors