diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-10-28 14:31:49 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2010-10-28 14:31:49 -0400 |
commit | 4275fcd65d3b4a504b7779e532c81a927afd28c0 (patch) | |
tree | 292e76b31cb801621ae578fde62c1a88b9c4bba5 /drivers | |
parent | 24377101023d3c66136123bd8b20441814da6a90 (diff) |
hwmon: (pcf8591) Register as a hwmon device
Register PCF8591 devices as hwmon devices. There's little point in
implementing the standard sysfs interface if we don't register it in
a way libsensors will pick it.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Reviewed-by: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/pcf8591.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/hwmon/pcf8591.c b/drivers/hwmon/pcf8591.c index d44787949851..d7df0e6c1ef4 100644 --- a/drivers/hwmon/pcf8591.c +++ b/drivers/hwmon/pcf8591.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/err.h> | ||
27 | #include <linux/hwmon.h> | ||
26 | 28 | ||
27 | /* Addresses to scan */ | 29 | /* Addresses to scan */ |
28 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | 30 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
@@ -71,6 +73,7 @@ MODULE_PARM_DESC(input_mode, | |||
71 | #define REG_TO_SIGNED(reg) (((reg) & 0x80)?((reg) - 256):(reg)) | 73 | #define REG_TO_SIGNED(reg) (((reg) & 0x80)?((reg) - 256):(reg)) |
72 | 74 | ||
73 | struct pcf8591_data { | 75 | struct pcf8591_data { |
76 | struct device *hwmon_dev; | ||
74 | struct mutex update_lock; | 77 | struct mutex update_lock; |
75 | 78 | ||
76 | u8 control; | 79 | u8 control; |
@@ -221,6 +224,12 @@ static int pcf8591_probe(struct i2c_client *client, | |||
221 | goto exit_sysfs_remove; | 224 | goto exit_sysfs_remove; |
222 | } | 225 | } |
223 | 226 | ||
227 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
228 | if (IS_ERR(data->hwmon_dev)) { | ||
229 | err = PTR_ERR(data->hwmon_dev); | ||
230 | goto exit_sysfs_remove; | ||
231 | } | ||
232 | |||
224 | return 0; | 233 | return 0; |
225 | 234 | ||
226 | exit_sysfs_remove: | 235 | exit_sysfs_remove: |
@@ -234,6 +243,9 @@ exit: | |||
234 | 243 | ||
235 | static int pcf8591_remove(struct i2c_client *client) | 244 | static int pcf8591_remove(struct i2c_client *client) |
236 | { | 245 | { |
246 | struct pcf8591_data *data = i2c_get_clientdata(client); | ||
247 | |||
248 | hwmon_device_unregister(data->hwmon_dev); | ||
237 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); | 249 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); |
238 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); | 250 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); |
239 | kfree(i2c_get_clientdata(client)); | 251 | kfree(i2c_get_clientdata(client)); |