Skip to contentSkip to conversation

hwmon: (adt7475) Convert to use devm_ functions

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

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 20/95 hwmon: (adt7475) Convert to use devm_ functions

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

---
 drivers/hwmon/adt7475.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/hwmon/adt7475.c +2 -5
index df29d13..861c756 100644
@@ -1260,7 +1260,7 @@ static int adt7475_probe(struct i2c_client *client,
 	int i, ret = 0, revision;
 	u8 config2, config3;
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
 	if (data = NULL)
 		return -ENOMEM;
 
@@ -1344,7 +1344,7 @@ static int adt7475_probe(struct i2c_client *client,
 
 	ret = sysfs_create_group(&client->dev.kobj, &adt7475_attr_group);
 	if (ret)
-		goto efree;
+		return ret;
 
 	/* Features that can be disabled individually */
 	if (data->has_fan4) {
@@ -1410,8 +1410,6 @@ static int adt7475_probe(struct i2c_client *client,
 
 eremove:
 	adt7475_remove_files(client, data);
-efree:
-	kfree(data);
 	return ret;
 }
 
@@ -1421,7 +1419,6 @@ static int adt7475_remove(struct i2c_client *client)
 
 	hwmon_device_unregister(data->hwmon_dev);
 	adt7475_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 20/95
#1 lore raw
Quoted 7 lines · Guenter Roeck

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

---
 drivers/hwmon/adt7475.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