aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2010-10-28 14:31:43 -0400
committerJean Delvare <khali@endymion.delvare>2010-10-28 14:31:43 -0400
commitb6fc1bacc7eae99d276d096fe0c702b1e13e4499 (patch)
treed280816900fdad1262f7ca3d417d35e8b2ad33c8
parent88073bb1ba969d4e3c41dc5f35c902c6b7dab0a7 (diff)
hwmon: (lm90) Introduce function to delete sysfs files
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/hwmon/lm90.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index f628f2ae7e73..9b1d20515eba 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -815,6 +815,15 @@ static int lm90_detect(struct i2c_client *new_client,
815 return 0; 815 return 0;
816} 816}
817 817
818static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data)
819{
820 if (data->flags & LM90_HAVE_OFFSET)
821 device_remove_file(&client->dev,
822 &sensor_dev_attr_temp2_offset.dev_attr);
823 device_remove_file(&client->dev, &dev_attr_pec);
824 sysfs_remove_group(&client->dev.kobj, &lm90_group);
825}
826
818static int lm90_probe(struct i2c_client *new_client, 827static int lm90_probe(struct i2c_client *new_client,
819 const struct i2c_device_id *id) 828 const struct i2c_device_id *id)
820{ 829{
@@ -889,8 +898,7 @@ static int lm90_probe(struct i2c_client *new_client,
889 return 0; 898 return 0;
890 899
891exit_remove_files: 900exit_remove_files:
892 sysfs_remove_group(&new_client->dev.kobj, &lm90_group); 901 lm90_remove_files(new_client, data);
893 device_remove_file(&new_client->dev, &dev_attr_pec);
894exit_free: 902exit_free:
895 kfree(data); 903 kfree(data);
896exit: 904exit:
@@ -937,11 +945,7 @@ static int lm90_remove(struct i2c_client *client)
937 struct lm90_data *data = i2c_get_clientdata(client); 945 struct lm90_data *data = i2c_get_clientdata(client);
938 946
939 hwmon_device_unregister(data->hwmon_dev); 947 hwmon_device_unregister(data->hwmon_dev);
940 sysfs_remove_group(&client->dev.kobj, &lm90_group); 948 lm90_remove_files(client, data);
941 device_remove_file(&client->dev, &dev_attr_pec);
942 if (data->flags & LM90_HAVE_OFFSET)
943 device_remove_file(&client->dev,
944 &sensor_dev_attr_temp2_offset.dev_attr);
945 949
946 /* Restore initial configuration */ 950 /* Restore initial configuration */
947 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, 951 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,