Skip to contentSkip to conversation

hwmon: (lm85) Use function to remove

PATCH Superseded Guenter Roeck 2 participants 2 messages Feb 25, 2011 Hardware monitoring

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/4 hwmon: (lm85) Use function to remove

---
 drivers/hwmon/lm85.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
drivers/hwmon/lm85.c +11 -8
index 12edd5f..1a9540a 100644
@@ -1282,6 +1282,15 @@ static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info)
 	return 0;
 }
 
+static void lm85_remove_files(struct lm85_data *data, struct i2c_client *client)
+{
+	sysfs_remove_group(&client->dev.kobj, &lm85_group);
+	if (!vid5_configured(data))
+		sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
+	if (data->type = emc6d100)
+		sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
+}
+
 static int lm85_probe(struct i2c_client *client,
 		      const struct i2c_device_id *id)
 {
@@ -1345,10 +1354,7 @@ static int lm85_probe(struct i2c_client *client,
 
 	/* Error out and cleanup code */
  err_remove_files:
-	sysfs_remove_group(&client->dev.kobj, &lm85_group);
-	sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
-	if (data->type = emc6d100)
-		sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
+	lm85_remove_files(data, client);
  err_kfree:
 	kfree(data);
 	return err;
@@ -1358,10 +1364,7 @@ static int lm85_remove(struct i2c_client *client)
 {
 	struct lm85_data *data = i2c_get_clientdata(client);
 	hwmon_device_unregister(data->hwmon_dev);
-	sysfs_remove_group(&client->dev.kobj, &lm85_group);
-	sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
-	if (data->type = emc6d100)
-		sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
+	lm85_remove_files(data, client);
 	kfree(data);
 	return 0;
 }
Signature · 7 lines
1.7.3.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v3 2/4
#1 lore raw

Re: [lm-sensors] [PATCH v3 2/4] hwmon: (lm85) Use function to

Quoted 10 lines · Guenter Roeck
---
 drivers/hwmon/lm85.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
drivers/hwmon/lm85.c +0 -0
index 12edd5f..1a9540a 100644

drivers/hwmon/lm85.c static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info) · line 1285

Quoted 4 lines
drivers/hwmon/lm85.c +1 -0
@@ -1282,6 +1282,15 @@ static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info)
 	return 0;
 }
 
+static void lm85_remove_files(struct lm85_data *data, struct i2c_client *client)

It would be more usual to pass the client first and the data second.

Other than this:

Quoted 35 lines
drivers/hwmon/lm85.c +10 -8
+{
+	sysfs_remove_group(&client->dev.kobj, &lm85_group);
+	if (!vid5_configured(data))
+		sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
+	if (data->type = emc6d100)
+		sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
+}
+
 static int lm85_probe(struct i2c_client *client,
 		      const struct i2c_device_id *id)
 {
@@ -1345,10 +1354,7 @@ static int lm85_probe(struct i2c_client *client,
 
 	/* Error out and cleanup code */
  err_remove_files:
-	sysfs_remove_group(&client->dev.kobj, &lm85_group);
-	sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
-	if (data->type = emc6d100)
-		sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
+	lm85_remove_files(data, client);
  err_kfree:
 	kfree(data);
 	return err;
@@ -1358,10 +1364,7 @@ static int lm85_remove(struct i2c_client *client)
 {
 	struct lm85_data *data = i2c_get_clientdata(client);
 	hwmon_device_unregister(data->hwmon_dev);
-	sysfs_remove_group(&client->dev.kobj, &lm85_group);
-	sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
-	if (data->type = emc6d100)
-		sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
+	lm85_remove_files(data, client);
 	kfree(data);
 	return 0;
 }
Signature · 6 lines
Jean Delvare

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