diff options
Diffstat (limited to 'drivers/hwmon/pcf8591.c')
-rw-r--r-- | drivers/hwmon/pcf8591.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/drivers/hwmon/pcf8591.c b/drivers/hwmon/pcf8591.c index d44787949851..dc7259d69812 100644 --- a/drivers/hwmon/pcf8591.c +++ b/drivers/hwmon/pcf8591.c | |||
@@ -23,10 +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 | 26 | #include <linux/err.h> | |
27 | /* Addresses to scan */ | 27 | #include <linux/hwmon.h> |
28 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | ||
29 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; | ||
30 | 28 | ||
31 | /* Insmod parameters */ | 29 | /* Insmod parameters */ |
32 | 30 | ||
@@ -71,6 +69,7 @@ MODULE_PARM_DESC(input_mode, | |||
71 | #define REG_TO_SIGNED(reg) (((reg) & 0x80)?((reg) - 256):(reg)) | 69 | #define REG_TO_SIGNED(reg) (((reg) & 0x80)?((reg) - 256):(reg)) |
72 | 70 | ||
73 | struct pcf8591_data { | 71 | struct pcf8591_data { |
72 | struct device *hwmon_dev; | ||
74 | struct mutex update_lock; | 73 | struct mutex update_lock; |
75 | 74 | ||
76 | u8 control; | 75 | u8 control; |
@@ -167,24 +166,6 @@ static const struct attribute_group pcf8591_attr_group_opt = { | |||
167 | * Real code | 166 | * Real code |
168 | */ | 167 | */ |
169 | 168 | ||
170 | /* Return 0 if detection is successful, -ENODEV otherwise */ | ||
171 | static int pcf8591_detect(struct i2c_client *client, | ||
172 | struct i2c_board_info *info) | ||
173 | { | ||
174 | struct i2c_adapter *adapter = client->adapter; | ||
175 | |||
176 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE | ||
177 | | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) | ||
178 | return -ENODEV; | ||
179 | |||
180 | /* Now, we would do the remaining detection. But the PCF8591 is plainly | ||
181 | impossible to detect! Stupid chip. */ | ||
182 | |||
183 | strlcpy(info->type, "pcf8591", I2C_NAME_SIZE); | ||
184 | |||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | static int pcf8591_probe(struct i2c_client *client, | 169 | static int pcf8591_probe(struct i2c_client *client, |
189 | const struct i2c_device_id *id) | 170 | const struct i2c_device_id *id) |
190 | { | 171 | { |
@@ -221,6 +202,12 @@ static int pcf8591_probe(struct i2c_client *client, | |||
221 | goto exit_sysfs_remove; | 202 | goto exit_sysfs_remove; |
222 | } | 203 | } |
223 | 204 | ||
205 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
206 | if (IS_ERR(data->hwmon_dev)) { | ||
207 | err = PTR_ERR(data->hwmon_dev); | ||
208 | goto exit_sysfs_remove; | ||
209 | } | ||
210 | |||
224 | return 0; | 211 | return 0; |
225 | 212 | ||
226 | exit_sysfs_remove: | 213 | exit_sysfs_remove: |
@@ -234,6 +221,9 @@ exit: | |||
234 | 221 | ||
235 | static int pcf8591_remove(struct i2c_client *client) | 222 | static int pcf8591_remove(struct i2c_client *client) |
236 | { | 223 | { |
224 | struct pcf8591_data *data = i2c_get_clientdata(client); | ||
225 | |||
226 | hwmon_device_unregister(data->hwmon_dev); | ||
237 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); | 227 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); |
238 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); | 228 | sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); |
239 | kfree(i2c_get_clientdata(client)); | 229 | kfree(i2c_get_clientdata(client)); |
@@ -295,10 +285,6 @@ static struct i2c_driver pcf8591_driver = { | |||
295 | .probe = pcf8591_probe, | 285 | .probe = pcf8591_probe, |
296 | .remove = pcf8591_remove, | 286 | .remove = pcf8591_remove, |
297 | .id_table = pcf8591_id, | 287 | .id_table = pcf8591_id, |
298 | |||
299 | .class = I2C_CLASS_HWMON, /* Nearest choice */ | ||
300 | .detect = pcf8591_detect, | ||
301 | .address_list = normal_i2c, | ||
302 | }; | 288 | }; |
303 | 289 | ||
304 | static int __init pcf8591_init(void) | 290 | static int __init pcf8591_init(void) |