diff options
-rw-r--r-- | Documentation/hwmon/it87 | 10 | ||||
-rw-r--r-- | drivers/hwmon/adm1021.c | 70 | ||||
-rw-r--r-- | drivers/hwmon/asc7621.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/atxp1.c | 2 | ||||
-rw-r--r-- | drivers/hwmon/f71805f.c | 2 | ||||
-rw-r--r-- | drivers/hwmon/it87.c | 9 | ||||
-rw-r--r-- | drivers/hwmon/lm63.c | 157 | ||||
-rw-r--r-- | drivers/hwmon/lm77.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/lm80.c | 70 | ||||
-rw-r--r-- | drivers/hwmon/lm83.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/lm87.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/lm90.c | 111 | ||||
-rw-r--r-- | drivers/hwmon/lm92.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/lm93.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/max1619.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/pc87360.c | 12 | ||||
-rw-r--r-- | drivers/hwmon/w83792d.c | 1 | ||||
-rw-r--r-- | drivers/hwmon/w83l785ts.c | 4 |
18 files changed, 173 insertions, 282 deletions
diff --git a/Documentation/hwmon/it87 b/Documentation/hwmon/it87 index 0c1635082c99..fe80e9adebfa 100644 --- a/Documentation/hwmon/it87 +++ b/Documentation/hwmon/it87 | |||
@@ -2,7 +2,7 @@ Kernel driver it87 | |||
2 | ================== | 2 | ================== |
3 | 3 | ||
4 | Supported chips: | 4 | Supported chips: |
5 | * IT8603E | 5 | * IT8603E/IT8623E |
6 | Prefix: 'it8603' | 6 | Prefix: 'it8603' |
7 | Addresses scanned: from Super I/O config space (8 I/O ports) | 7 | Addresses scanned: from Super I/O config space (8 I/O ports) |
8 | Datasheet: Not publicly available | 8 | Datasheet: Not publicly available |
@@ -94,9 +94,9 @@ motherboard models. | |||
94 | Description | 94 | Description |
95 | ----------- | 95 | ----------- |
96 | 96 | ||
97 | This driver implements support for the IT8603E, IT8705F, IT8712F, IT8716F, | 97 | This driver implements support for the IT8603E, IT8623E, IT8705F, IT8712F, |
98 | IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8758E, IT8771E, IT8772E, | 98 | IT8716F, IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8758E, IT8771E, |
99 | IT8782F, IT8783E/F, and SiS950 chips. | 99 | IT8772E, IT8782F, IT8783E/F, and SiS950 chips. |
100 | 100 | ||
101 | These chips are 'Super I/O chips', supporting floppy disks, infrared ports, | 101 | These chips are 'Super I/O chips', supporting floppy disks, infrared ports, |
102 | joysticks and other miscellaneous stuff. For hardware monitoring, they | 102 | joysticks and other miscellaneous stuff. For hardware monitoring, they |
@@ -133,7 +133,7 @@ to userspace applications. | |||
133 | The IT8728F, IT8771E, and IT8772E are considered compatible with the IT8721F, | 133 | The IT8728F, IT8771E, and IT8772E are considered compatible with the IT8721F, |
134 | until a datasheet becomes available (hopefully.) | 134 | until a datasheet becomes available (hopefully.) |
135 | 135 | ||
136 | The IT8603E is a custom design, hardware monitoring part is similar to | 136 | The IT8603E/IT8623E is a custom design, hardware monitoring part is similar to |
137 | IT8728F. It only supports 16-bit fan mode, the full speed mode of the | 137 | IT8728F. It only supports 16-bit fan mode, the full speed mode of the |
138 | fan is not supported (value 0 of pwmX_enable). | 138 | fan is not supported (value 0 of pwmX_enable). |
139 | 139 | ||
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 29dd9f746dfa..3eb4281689b5 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -79,9 +79,11 @@ enum chips { | |||
79 | 79 | ||
80 | /* Each client has this additional data */ | 80 | /* Each client has this additional data */ |
81 | struct adm1021_data { | 81 | struct adm1021_data { |
82 | struct device *hwmon_dev; | 82 | struct i2c_client *client; |
83 | enum chips type; | 83 | enum chips type; |
84 | 84 | ||
85 | const struct attribute_group *groups[3]; | ||
86 | |||
85 | struct mutex update_lock; | 87 | struct mutex update_lock; |
86 | char valid; /* !=0 if following fields are valid */ | 88 | char valid; /* !=0 if following fields are valid */ |
87 | char low_power; /* !=0 if device in low power mode */ | 89 | char low_power; /* !=0 if device in low power mode */ |
@@ -101,7 +103,6 @@ static int adm1021_probe(struct i2c_client *client, | |||
101 | static int adm1021_detect(struct i2c_client *client, | 103 | static int adm1021_detect(struct i2c_client *client, |
102 | struct i2c_board_info *info); | 104 | struct i2c_board_info *info); |
103 | static void adm1021_init_client(struct i2c_client *client); | 105 | static void adm1021_init_client(struct i2c_client *client); |
104 | static int adm1021_remove(struct i2c_client *client); | ||
105 | static struct adm1021_data *adm1021_update_device(struct device *dev); | 106 | static struct adm1021_data *adm1021_update_device(struct device *dev); |
106 | 107 | ||
107 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ | 108 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ |
@@ -128,7 +129,6 @@ static struct i2c_driver adm1021_driver = { | |||
128 | .name = "adm1021", | 129 | .name = "adm1021", |
129 | }, | 130 | }, |
130 | .probe = adm1021_probe, | 131 | .probe = adm1021_probe, |
131 | .remove = adm1021_remove, | ||
132 | .id_table = adm1021_id, | 132 | .id_table = adm1021_id, |
133 | .detect = adm1021_detect, | 133 | .detect = adm1021_detect, |
134 | .address_list = normal_i2c, | 134 | .address_list = normal_i2c, |
@@ -182,8 +182,8 @@ static ssize_t set_temp_max(struct device *dev, | |||
182 | const char *buf, size_t count) | 182 | const char *buf, size_t count) |
183 | { | 183 | { |
184 | int index = to_sensor_dev_attr(devattr)->index; | 184 | int index = to_sensor_dev_attr(devattr)->index; |
185 | struct i2c_client *client = to_i2c_client(dev); | 185 | struct adm1021_data *data = dev_get_drvdata(dev); |
186 | struct adm1021_data *data = i2c_get_clientdata(client); | 186 | struct i2c_client *client = data->client; |
187 | long temp; | 187 | long temp; |
188 | int err; | 188 | int err; |
189 | 189 | ||
@@ -207,8 +207,8 @@ static ssize_t set_temp_min(struct device *dev, | |||
207 | const char *buf, size_t count) | 207 | const char *buf, size_t count) |
208 | { | 208 | { |
209 | int index = to_sensor_dev_attr(devattr)->index; | 209 | int index = to_sensor_dev_attr(devattr)->index; |
210 | struct i2c_client *client = to_i2c_client(dev); | 210 | struct adm1021_data *data = dev_get_drvdata(dev); |
211 | struct adm1021_data *data = i2c_get_clientdata(client); | 211 | struct i2c_client *client = data->client; |
212 | long temp; | 212 | long temp; |
213 | int err; | 213 | int err; |
214 | 214 | ||
@@ -238,8 +238,8 @@ static ssize_t set_low_power(struct device *dev, | |||
238 | struct device_attribute *devattr, | 238 | struct device_attribute *devattr, |
239 | const char *buf, size_t count) | 239 | const char *buf, size_t count) |
240 | { | 240 | { |
241 | struct i2c_client *client = to_i2c_client(dev); | 241 | struct adm1021_data *data = dev_get_drvdata(dev); |
242 | struct adm1021_data *data = i2c_get_clientdata(client); | 242 | struct i2c_client *client = data->client; |
243 | char low_power; | 243 | char low_power; |
244 | unsigned long val; | 244 | unsigned long val; |
245 | int err; | 245 | int err; |
@@ -412,15 +412,15 @@ static int adm1021_detect(struct i2c_client *client, | |||
412 | static int adm1021_probe(struct i2c_client *client, | 412 | static int adm1021_probe(struct i2c_client *client, |
413 | const struct i2c_device_id *id) | 413 | const struct i2c_device_id *id) |
414 | { | 414 | { |
415 | struct device *dev = &client->dev; | ||
415 | struct adm1021_data *data; | 416 | struct adm1021_data *data; |
416 | int err; | 417 | struct device *hwmon_dev; |
417 | 418 | ||
418 | data = devm_kzalloc(&client->dev, sizeof(struct adm1021_data), | 419 | data = devm_kzalloc(dev, sizeof(struct adm1021_data), GFP_KERNEL); |
419 | GFP_KERNEL); | ||
420 | if (!data) | 420 | if (!data) |
421 | return -ENOMEM; | 421 | return -ENOMEM; |
422 | 422 | ||
423 | i2c_set_clientdata(client, data); | 423 | data->client = client; |
424 | data->type = id->driver_data; | 424 | data->type = id->driver_data; |
425 | mutex_init(&data->update_lock); | 425 | mutex_init(&data->update_lock); |
426 | 426 | ||
@@ -428,29 +428,14 @@ static int adm1021_probe(struct i2c_client *client, | |||
428 | if (data->type != lm84 && !read_only) | 428 | if (data->type != lm84 && !read_only) |
429 | adm1021_init_client(client); | 429 | adm1021_init_client(client); |
430 | 430 | ||
431 | /* Register sysfs hooks */ | 431 | data->groups[0] = &adm1021_group; |
432 | err = sysfs_create_group(&client->dev.kobj, &adm1021_group); | 432 | if (data->type != lm84) |
433 | if (err) | 433 | data->groups[1] = &adm1021_min_group; |
434 | return err; | ||
435 | |||
436 | if (data->type != lm84) { | ||
437 | err = sysfs_create_group(&client->dev.kobj, &adm1021_min_group); | ||
438 | if (err) | ||
439 | goto error; | ||
440 | } | ||
441 | 434 | ||
442 | data->hwmon_dev = hwmon_device_register(&client->dev); | 435 | hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, |
443 | if (IS_ERR(data->hwmon_dev)) { | 436 | data, data->groups); |
444 | err = PTR_ERR(data->hwmon_dev); | ||
445 | goto error; | ||
446 | } | ||
447 | 437 | ||
448 | return 0; | 438 | return PTR_ERR_OR_ZERO(hwmon_dev); |
449 | |||
450 | error: | ||
451 | sysfs_remove_group(&client->dev.kobj, &adm1021_min_group); | ||
452 | sysfs_remove_group(&client->dev.kobj, &adm1021_group); | ||
453 | return err; | ||
454 | } | 439 | } |
455 | 440 | ||
456 | static void adm1021_init_client(struct i2c_client *client) | 441 | static void adm1021_init_client(struct i2c_client *client) |
@@ -462,21 +447,10 @@ static void adm1021_init_client(struct i2c_client *client) | |||
462 | i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04); | 447 | i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04); |
463 | } | 448 | } |
464 | 449 | ||
465 | static int adm1021_remove(struct i2c_client *client) | ||
466 | { | ||
467 | struct adm1021_data *data = i2c_get_clientdata(client); | ||
468 | |||
469 | hwmon_device_unregister(data->hwmon_dev); | ||
470 | sysfs_remove_group(&client->dev.kobj, &adm1021_min_group); | ||
471 | sysfs_remove_group(&client->dev.kobj, &adm1021_group); | ||
472 | |||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | static struct adm1021_data *adm1021_update_device(struct device *dev) | 450 | static struct adm1021_data *adm1021_update_device(struct device *dev) |
477 | { | 451 | { |
478 | struct i2c_client *client = to_i2c_client(dev); | 452 | struct adm1021_data *data = dev_get_drvdata(dev); |
479 | struct adm1021_data *data = i2c_get_clientdata(client); | 453 | struct i2c_client *client = data->client; |
480 | 454 | ||
481 | mutex_lock(&data->update_lock); | 455 | mutex_lock(&data->update_lock); |
482 | 456 | ||
@@ -484,7 +458,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
484 | || !data->valid) { | 458 | || !data->valid) { |
485 | int i; | 459 | int i; |
486 | 460 | ||
487 | dev_dbg(&client->dev, "Starting adm1021 update\n"); | 461 | dev_dbg(dev, "Starting adm1021 update\n"); |
488 | 462 | ||
489 | for (i = 0; i < 2; i++) { | 463 | for (i = 0; i < 2; i++) { |
490 | data->temp[i] = 1000 * | 464 | data->temp[i] = 1000 * |
diff --git a/drivers/hwmon/asc7621.c b/drivers/hwmon/asc7621.c index 8d9f2a0e8efe..71463689d163 100644 --- a/drivers/hwmon/asc7621.c +++ b/drivers/hwmon/asc7621.c | |||
@@ -1115,7 +1115,6 @@ asc7621_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1115 | return -ENOMEM; | 1115 | return -ENOMEM; |
1116 | 1116 | ||
1117 | i2c_set_clientdata(client, data); | 1117 | i2c_set_clientdata(client, data); |
1118 | data->valid = 0; | ||
1119 | mutex_init(&data->update_lock); | 1118 | mutex_init(&data->update_lock); |
1120 | 1119 | ||
1121 | /* Initialize the asc7621 chip */ | 1120 | /* Initialize the asc7621 chip */ |
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index ddff02e3e66f..6edce42c61d5 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -353,8 +353,6 @@ static int atxp1_probe(struct i2c_client *new_client, | |||
353 | data->vrm = vid_which_vrm(); | 353 | data->vrm = vid_which_vrm(); |
354 | 354 | ||
355 | i2c_set_clientdata(new_client, data); | 355 | i2c_set_clientdata(new_client, data); |
356 | data->valid = 0; | ||
357 | |||
358 | mutex_init(&data->update_lock); | 356 | mutex_init(&data->update_lock); |
359 | 357 | ||
360 | /* Register sysfs hooks */ | 358 | /* Register sysfs hooks */ |
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index 1a8aa1265262..32f5132c4652 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -1648,7 +1648,7 @@ static void __exit f71805f_exit(void) | |||
1648 | platform_driver_unregister(&f71805f_driver); | 1648 | platform_driver_unregister(&f71805f_driver); |
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr>"); | 1651 | MODULE_AUTHOR("Jean Delvare <jdelvare@suse.de>"); |
1652 | MODULE_LICENSE("GPL"); | 1652 | MODULE_LICENSE("GPL"); |
1653 | MODULE_DESCRIPTION("F71805F/F71872F hardware monitoring driver"); | 1653 | MODULE_DESCRIPTION("F71805F/F71872F hardware monitoring driver"); |
1654 | 1654 | ||
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 70749fc15a4f..a327fd3402a7 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -11,6 +11,7 @@ | |||
11 | * similar parts. The other devices are supported by different drivers. | 11 | * similar parts. The other devices are supported by different drivers. |
12 | * | 12 | * |
13 | * Supports: IT8603E Super I/O chip w/LPC interface | 13 | * Supports: IT8603E Super I/O chip w/LPC interface |
14 | * IT8623E Super I/O chip w/LPC interface | ||
14 | * IT8705F Super I/O chip w/LPC interface | 15 | * IT8705F Super I/O chip w/LPC interface |
15 | * IT8712F Super I/O chip w/LPC interface | 16 | * IT8712F Super I/O chip w/LPC interface |
16 | * IT8716F Super I/O chip w/LPC interface | 17 | * IT8716F Super I/O chip w/LPC interface |
@@ -147,7 +148,8 @@ static inline void superio_exit(void) | |||
147 | #define IT8772E_DEVID 0x8772 | 148 | #define IT8772E_DEVID 0x8772 |
148 | #define IT8782F_DEVID 0x8782 | 149 | #define IT8782F_DEVID 0x8782 |
149 | #define IT8783E_DEVID 0x8783 | 150 | #define IT8783E_DEVID 0x8783 |
150 | #define IT8306E_DEVID 0x8603 | 151 | #define IT8603E_DEVID 0x8603 |
152 | #define IT8623E_DEVID 0x8623 | ||
151 | #define IT87_ACT_REG 0x30 | 153 | #define IT87_ACT_REG 0x30 |
152 | #define IT87_BASE_REG 0x60 | 154 | #define IT87_BASE_REG 0x60 |
153 | 155 | ||
@@ -1431,7 +1433,7 @@ static ssize_t show_label(struct device *dev, struct device_attribute *attr, | |||
1431 | static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 0); | 1433 | static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 0); |
1432 | static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 1); | 1434 | static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 1); |
1433 | static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 2); | 1435 | static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 2); |
1434 | /* special AVCC3 IT8306E in9 */ | 1436 | /* special AVCC3 IT8603E in9 */ |
1435 | static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 0); | 1437 | static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 0); |
1436 | 1438 | ||
1437 | static ssize_t show_name(struct device *dev, struct device_attribute | 1439 | static ssize_t show_name(struct device *dev, struct device_attribute |
@@ -1766,7 +1768,8 @@ static int __init it87_find(unsigned short *address, | |||
1766 | case IT8783E_DEVID: | 1768 | case IT8783E_DEVID: |
1767 | sio_data->type = it8783; | 1769 | sio_data->type = it8783; |
1768 | break; | 1770 | break; |
1769 | case IT8306E_DEVID: | 1771 | case IT8603E_DEVID: |
1772 | case IT8623E_DEVID: | ||
1770 | sio_data->type = it8603; | 1773 | sio_data->type = it8603; |
1771 | break; | 1774 | break; |
1772 | case 0xffff: /* No device at all */ | 1775 | case 0xffff: /* No device at all */ |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index b4ad598feb6c..848b9611151f 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -155,8 +155,9 @@ enum chips { lm63, lm64, lm96163 }; | |||
155 | */ | 155 | */ |
156 | 156 | ||
157 | struct lm63_data { | 157 | struct lm63_data { |
158 | struct device *hwmon_dev; | 158 | struct i2c_client *client; |
159 | struct mutex update_lock; | 159 | struct mutex update_lock; |
160 | const struct attribute_group *groups[5]; | ||
160 | char valid; /* zero until following fields are valid */ | 161 | char valid; /* zero until following fields are valid */ |
161 | char lut_valid; /* zero until lut fields are valid */ | 162 | char lut_valid; /* zero until lut fields are valid */ |
162 | unsigned long last_updated; /* in jiffies */ | 163 | unsigned long last_updated; /* in jiffies */ |
@@ -218,9 +219,9 @@ static inline int lut_temp_to_reg(struct lm63_data *data, long val) | |||
218 | * Update the lookup table register cache. | 219 | * Update the lookup table register cache. |
219 | * client->update_lock must be held when calling this function. | 220 | * client->update_lock must be held when calling this function. |
220 | */ | 221 | */ |
221 | static void lm63_update_lut(struct i2c_client *client) | 222 | static void lm63_update_lut(struct lm63_data *data) |
222 | { | 223 | { |
223 | struct lm63_data *data = i2c_get_clientdata(client); | 224 | struct i2c_client *client = data->client; |
224 | int i; | 225 | int i; |
225 | 226 | ||
226 | if (time_after(jiffies, data->lut_last_updated + 5 * HZ) || | 227 | if (time_after(jiffies, data->lut_last_updated + 5 * HZ) || |
@@ -241,8 +242,8 @@ static void lm63_update_lut(struct i2c_client *client) | |||
241 | 242 | ||
242 | static struct lm63_data *lm63_update_device(struct device *dev) | 243 | static struct lm63_data *lm63_update_device(struct device *dev) |
243 | { | 244 | { |
244 | struct i2c_client *client = to_i2c_client(dev); | 245 | struct lm63_data *data = dev_get_drvdata(dev); |
245 | struct lm63_data *data = i2c_get_clientdata(client); | 246 | struct i2c_client *client = data->client; |
246 | unsigned long next_update; | 247 | unsigned long next_update; |
247 | 248 | ||
248 | mutex_lock(&data->update_lock); | 249 | mutex_lock(&data->update_lock); |
@@ -310,7 +311,7 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
310 | data->valid = 1; | 311 | data->valid = 1; |
311 | } | 312 | } |
312 | 313 | ||
313 | lm63_update_lut(client); | 314 | lm63_update_lut(data); |
314 | 315 | ||
315 | mutex_unlock(&data->update_lock); | 316 | mutex_unlock(&data->update_lock); |
316 | 317 | ||
@@ -321,18 +322,17 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
321 | * Trip points in the lookup table should be in ascending order for both | 322 | * Trip points in the lookup table should be in ascending order for both |
322 | * temperatures and PWM output values. | 323 | * temperatures and PWM output values. |
323 | */ | 324 | */ |
324 | static int lm63_lut_looks_bad(struct i2c_client *client) | 325 | static int lm63_lut_looks_bad(struct device *dev, struct lm63_data *data) |
325 | { | 326 | { |
326 | struct lm63_data *data = i2c_get_clientdata(client); | ||
327 | int i; | 327 | int i; |
328 | 328 | ||
329 | mutex_lock(&data->update_lock); | 329 | mutex_lock(&data->update_lock); |
330 | lm63_update_lut(client); | 330 | lm63_update_lut(data); |
331 | 331 | ||
332 | for (i = 1; i < data->lut_size; i++) { | 332 | for (i = 1; i < data->lut_size; i++) { |
333 | if (data->pwm1[1 + i - 1] > data->pwm1[1 + i] | 333 | if (data->pwm1[1 + i - 1] > data->pwm1[1 + i] |
334 | || data->temp8[3 + i - 1] > data->temp8[3 + i]) { | 334 | || data->temp8[3 + i - 1] > data->temp8[3 + i]) { |
335 | dev_warn(&client->dev, | 335 | dev_warn(dev, |
336 | "Lookup table doesn't look sane (check entries %d and %d)\n", | 336 | "Lookup table doesn't look sane (check entries %d and %d)\n", |
337 | i, i + 1); | 337 | i, i + 1); |
338 | break; | 338 | break; |
@@ -358,8 +358,8 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, | |||
358 | static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, | 358 | static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, |
359 | const char *buf, size_t count) | 359 | const char *buf, size_t count) |
360 | { | 360 | { |
361 | struct i2c_client *client = to_i2c_client(dev); | 361 | struct lm63_data *data = dev_get_drvdata(dev); |
362 | struct lm63_data *data = i2c_get_clientdata(client); | 362 | struct i2c_client *client = data->client; |
363 | unsigned long val; | 363 | unsigned long val; |
364 | int err; | 364 | int err; |
365 | 365 | ||
@@ -399,8 +399,8 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *devattr, | |||
399 | const char *buf, size_t count) | 399 | const char *buf, size_t count) |
400 | { | 400 | { |
401 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 401 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
402 | struct i2c_client *client = to_i2c_client(dev); | 402 | struct lm63_data *data = dev_get_drvdata(dev); |
403 | struct lm63_data *data = i2c_get_clientdata(client); | 403 | struct i2c_client *client = data->client; |
404 | int nr = attr->index; | 404 | int nr = attr->index; |
405 | unsigned long val; | 405 | unsigned long val; |
406 | int err; | 406 | int err; |
@@ -435,8 +435,8 @@ static ssize_t set_pwm1_enable(struct device *dev, | |||
435 | struct device_attribute *dummy, | 435 | struct device_attribute *dummy, |
436 | const char *buf, size_t count) | 436 | const char *buf, size_t count) |
437 | { | 437 | { |
438 | struct i2c_client *client = to_i2c_client(dev); | 438 | struct lm63_data *data = dev_get_drvdata(dev); |
439 | struct lm63_data *data = i2c_get_clientdata(client); | 439 | struct i2c_client *client = data->client; |
440 | unsigned long val; | 440 | unsigned long val; |
441 | int err; | 441 | int err; |
442 | 442 | ||
@@ -450,7 +450,7 @@ static ssize_t set_pwm1_enable(struct device *dev, | |||
450 | * Only let the user switch to automatic mode if the lookup table | 450 | * Only let the user switch to automatic mode if the lookup table |
451 | * looks sane. | 451 | * looks sane. |
452 | */ | 452 | */ |
453 | if (val == 2 && lm63_lut_looks_bad(client)) | 453 | if (val == 2 && lm63_lut_looks_bad(dev, data)) |
454 | return -EPERM; | 454 | return -EPERM; |
455 | 455 | ||
456 | mutex_lock(&data->update_lock); | 456 | mutex_lock(&data->update_lock); |
@@ -461,7 +461,7 @@ static ssize_t set_pwm1_enable(struct device *dev, | |||
461 | else | 461 | else |
462 | data->config_fan &= ~0x20; | 462 | data->config_fan &= ~0x20; |
463 | i2c_smbus_write_byte_data(client, LM63_REG_CONFIG_FAN, | 463 | i2c_smbus_write_byte_data(client, LM63_REG_CONFIG_FAN, |
464 | data->config_fan); | 464 | data->config_fan); |
465 | mutex_unlock(&data->update_lock); | 465 | mutex_unlock(&data->update_lock); |
466 | return count; | 466 | return count; |
467 | } | 467 | } |
@@ -505,8 +505,8 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | |||
505 | const char *buf, size_t count) | 505 | const char *buf, size_t count) |
506 | { | 506 | { |
507 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 507 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
508 | struct i2c_client *client = to_i2c_client(dev); | 508 | struct lm63_data *data = dev_get_drvdata(dev); |
509 | struct lm63_data *data = i2c_get_clientdata(client); | 509 | struct i2c_client *client = data->client; |
510 | int nr = attr->index; | 510 | int nr = attr->index; |
511 | long val; | 511 | long val; |
512 | int err; | 512 | int err; |
@@ -579,8 +579,8 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
579 | }; | 579 | }; |
580 | 580 | ||
581 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 581 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
582 | struct i2c_client *client = to_i2c_client(dev); | 582 | struct lm63_data *data = dev_get_drvdata(dev); |
583 | struct lm63_data *data = i2c_get_clientdata(client); | 583 | struct i2c_client *client = data->client; |
584 | long val; | 584 | long val; |
585 | int err; | 585 | int err; |
586 | int nr = attr->index; | 586 | int nr = attr->index; |
@@ -635,8 +635,8 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, | |||
635 | struct device_attribute *dummy, | 635 | struct device_attribute *dummy, |
636 | const char *buf, size_t count) | 636 | const char *buf, size_t count) |
637 | { | 637 | { |
638 | struct i2c_client *client = to_i2c_client(dev); | 638 | struct lm63_data *data = dev_get_drvdata(dev); |
639 | struct lm63_data *data = i2c_get_clientdata(client); | 639 | struct i2c_client *client = data->client; |
640 | long val; | 640 | long val; |
641 | int err; | 641 | int err; |
642 | long hyst; | 642 | long hyst; |
@@ -657,11 +657,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, | |||
657 | * Set conversion rate. | 657 | * Set conversion rate. |
658 | * client->update_lock must be held when calling this function. | 658 | * client->update_lock must be held when calling this function. |
659 | */ | 659 | */ |
660 | static void lm63_set_convrate(struct i2c_client *client, struct lm63_data *data, | 660 | static void lm63_set_convrate(struct lm63_data *data, unsigned int interval) |
661 | unsigned int interval) | ||
662 | { | 661 | { |
663 | int i; | 662 | struct i2c_client *client = data->client; |
664 | unsigned int update_interval; | 663 | unsigned int update_interval; |
664 | int i; | ||
665 | 665 | ||
666 | /* Shift calculations to avoid rounding errors */ | 666 | /* Shift calculations to avoid rounding errors */ |
667 | interval <<= 6; | 667 | interval <<= 6; |
@@ -689,8 +689,7 @@ static ssize_t set_update_interval(struct device *dev, | |||
689 | struct device_attribute *attr, | 689 | struct device_attribute *attr, |
690 | const char *buf, size_t count) | 690 | const char *buf, size_t count) |
691 | { | 691 | { |
692 | struct i2c_client *client = to_i2c_client(dev); | 692 | struct lm63_data *data = dev_get_drvdata(dev); |
693 | struct lm63_data *data = i2c_get_clientdata(client); | ||
694 | unsigned long val; | 693 | unsigned long val; |
695 | int err; | 694 | int err; |
696 | 695 | ||
@@ -699,7 +698,7 @@ static ssize_t set_update_interval(struct device *dev, | |||
699 | return err; | 698 | return err; |
700 | 699 | ||
701 | mutex_lock(&data->update_lock); | 700 | mutex_lock(&data->update_lock); |
702 | lm63_set_convrate(client, data, clamp_val(val, 0, 100000)); | 701 | lm63_set_convrate(data, clamp_val(val, 0, 100000)); |
703 | mutex_unlock(&data->update_lock); | 702 | mutex_unlock(&data->update_lock); |
704 | 703 | ||
705 | return count; | 704 | return count; |
@@ -708,8 +707,7 @@ static ssize_t set_update_interval(struct device *dev, | |||
708 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, | 707 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, |
709 | char *buf) | 708 | char *buf) |
710 | { | 709 | { |
711 | struct i2c_client *client = to_i2c_client(dev); | 710 | struct lm63_data *data = dev_get_drvdata(dev); |
712 | struct lm63_data *data = i2c_get_clientdata(client); | ||
713 | 711 | ||
714 | return sprintf(buf, data->trutherm ? "1\n" : "2\n"); | 712 | return sprintf(buf, data->trutherm ? "1\n" : "2\n"); |
715 | } | 713 | } |
@@ -717,8 +715,8 @@ static ssize_t show_type(struct device *dev, struct device_attribute *attr, | |||
717 | static ssize_t set_type(struct device *dev, struct device_attribute *attr, | 715 | static ssize_t set_type(struct device *dev, struct device_attribute *attr, |
718 | const char *buf, size_t count) | 716 | const char *buf, size_t count) |
719 | { | 717 | { |
720 | struct i2c_client *client = to_i2c_client(dev); | 718 | struct lm63_data *data = dev_get_drvdata(dev); |
721 | struct lm63_data *data = i2c_get_clientdata(client); | 719 | struct i2c_client *client = data->client; |
722 | unsigned long val; | 720 | unsigned long val; |
723 | int ret; | 721 | int ret; |
724 | u8 reg; | 722 | u8 reg; |
@@ -915,6 +913,15 @@ static struct attribute *lm63_attributes[] = { | |||
915 | NULL | 913 | NULL |
916 | }; | 914 | }; |
917 | 915 | ||
916 | static struct attribute *lm63_attributes_temp2_type[] = { | ||
917 | &dev_attr_temp2_type.attr, | ||
918 | NULL | ||
919 | }; | ||
920 | |||
921 | static const struct attribute_group lm63_group_temp2_type = { | ||
922 | .attrs = lm63_attributes_temp2_type, | ||
923 | }; | ||
924 | |||
918 | static struct attribute *lm63_attributes_extra_lut[] = { | 925 | static struct attribute *lm63_attributes_extra_lut[] = { |
919 | &sensor_dev_attr_pwm1_auto_point9_pwm.dev_attr.attr, | 926 | &sensor_dev_attr_pwm1_auto_point9_pwm.dev_attr.attr, |
920 | &sensor_dev_attr_pwm1_auto_point9_temp.dev_attr.attr, | 927 | &sensor_dev_attr_pwm1_auto_point9_temp.dev_attr.attr, |
@@ -946,8 +953,7 @@ static umode_t lm63_attribute_mode(struct kobject *kobj, | |||
946 | struct attribute *attr, int index) | 953 | struct attribute *attr, int index) |
947 | { | 954 | { |
948 | struct device *dev = container_of(kobj, struct device, kobj); | 955 | struct device *dev = container_of(kobj, struct device, kobj); |
949 | struct i2c_client *client = to_i2c_client(dev); | 956 | struct lm63_data *data = dev_get_drvdata(dev); |
950 | struct lm63_data *data = i2c_get_clientdata(client); | ||
951 | 957 | ||
952 | if (attr == &sensor_dev_attr_temp2_crit.dev_attr.attr | 958 | if (attr == &sensor_dev_attr_temp2_crit.dev_attr.attr |
953 | && (data->kind == lm64 || | 959 | && (data->kind == lm64 || |
@@ -1026,9 +1032,10 @@ static int lm63_detect(struct i2c_client *client, | |||
1026 | * Ideally we shouldn't have to initialize anything, since the BIOS | 1032 | * Ideally we shouldn't have to initialize anything, since the BIOS |
1027 | * should have taken care of everything | 1033 | * should have taken care of everything |
1028 | */ | 1034 | */ |
1029 | static void lm63_init_client(struct i2c_client *client) | 1035 | static void lm63_init_client(struct lm63_data *data) |
1030 | { | 1036 | { |
1031 | struct lm63_data *data = i2c_get_clientdata(client); | 1037 | struct i2c_client *client = data->client; |
1038 | struct device *dev = &client->dev; | ||
1032 | u8 convrate; | 1039 | u8 convrate; |
1033 | 1040 | ||
1034 | data->config = i2c_smbus_read_byte_data(client, LM63_REG_CONFIG1); | 1041 | data->config = i2c_smbus_read_byte_data(client, LM63_REG_CONFIG1); |
@@ -1037,7 +1044,7 @@ static void lm63_init_client(struct i2c_client *client) | |||
1037 | 1044 | ||
1038 | /* Start converting if needed */ | 1045 | /* Start converting if needed */ |
1039 | if (data->config & 0x40) { /* standby */ | 1046 | if (data->config & 0x40) { /* standby */ |
1040 | dev_dbg(&client->dev, "Switching to operational mode\n"); | 1047 | dev_dbg(dev, "Switching to operational mode\n"); |
1041 | data->config &= 0xA7; | 1048 | data->config &= 0xA7; |
1042 | i2c_smbus_write_byte_data(client, LM63_REG_CONFIG1, | 1049 | i2c_smbus_write_byte_data(client, LM63_REG_CONFIG1, |
1043 | data->config); | 1050 | data->config); |
@@ -1090,13 +1097,13 @@ static void lm63_init_client(struct i2c_client *client) | |||
1090 | 1097 | ||
1091 | /* Show some debug info about the LM63 configuration */ | 1098 | /* Show some debug info about the LM63 configuration */ |
1092 | if (data->kind == lm63) | 1099 | if (data->kind == lm63) |
1093 | dev_dbg(&client->dev, "Alert/tach pin configured for %s\n", | 1100 | dev_dbg(dev, "Alert/tach pin configured for %s\n", |
1094 | (data->config & 0x04) ? "tachometer input" : | 1101 | (data->config & 0x04) ? "tachometer input" : |
1095 | "alert output"); | 1102 | "alert output"); |
1096 | dev_dbg(&client->dev, "PWM clock %s kHz, output frequency %u Hz\n", | 1103 | dev_dbg(dev, "PWM clock %s kHz, output frequency %u Hz\n", |
1097 | (data->config_fan & 0x08) ? "1.4" : "360", | 1104 | (data->config_fan & 0x08) ? "1.4" : "360", |
1098 | ((data->config_fan & 0x08) ? 700 : 180000) / data->pwm1_freq); | 1105 | ((data->config_fan & 0x08) ? 700 : 180000) / data->pwm1_freq); |
1099 | dev_dbg(&client->dev, "PWM output active %s, %s mode\n", | 1106 | dev_dbg(dev, "PWM output active %s, %s mode\n", |
1100 | (data->config_fan & 0x10) ? "low" : "high", | 1107 | (data->config_fan & 0x10) ? "low" : "high", |
1101 | (data->config_fan & 0x20) ? "manual" : "auto"); | 1108 | (data->config_fan & 0x20) ? "manual" : "auto"); |
1102 | } | 1109 | } |
@@ -1104,15 +1111,16 @@ static void lm63_init_client(struct i2c_client *client) | |||
1104 | static int lm63_probe(struct i2c_client *client, | 1111 | static int lm63_probe(struct i2c_client *client, |
1105 | const struct i2c_device_id *id) | 1112 | const struct i2c_device_id *id) |
1106 | { | 1113 | { |
1114 | struct device *dev = &client->dev; | ||
1115 | struct device *hwmon_dev; | ||
1107 | struct lm63_data *data; | 1116 | struct lm63_data *data; |
1108 | int err; | 1117 | int groups = 0; |
1109 | 1118 | ||
1110 | data = devm_kzalloc(&client->dev, sizeof(struct lm63_data), GFP_KERNEL); | 1119 | data = devm_kzalloc(dev, sizeof(struct lm63_data), GFP_KERNEL); |
1111 | if (!data) | 1120 | if (!data) |
1112 | return -ENOMEM; | 1121 | return -ENOMEM; |
1113 | 1122 | ||
1114 | i2c_set_clientdata(client, data); | 1123 | data->client = client; |
1115 | data->valid = 0; | ||
1116 | mutex_init(&data->update_lock); | 1124 | mutex_init(&data->update_lock); |
1117 | 1125 | ||
1118 | /* Set the device type */ | 1126 | /* Set the device type */ |
@@ -1121,59 +1129,21 @@ static int lm63_probe(struct i2c_client *client, | |||
1121 | data->temp2_offset = 16000; | 1129 | data->temp2_offset = 16000; |
1122 | 1130 | ||
1123 | /* Initialize chip */ | 1131 | /* Initialize chip */ |
1124 | lm63_init_client(client); | 1132 | lm63_init_client(data); |
1125 | 1133 | ||
1126 | /* Register sysfs hooks */ | 1134 | /* Register sysfs hooks */ |
1127 | err = sysfs_create_group(&client->dev.kobj, &lm63_group); | 1135 | data->groups[groups++] = &lm63_group; |
1128 | if (err) | 1136 | if (data->config & 0x04) /* tachometer enabled */ |
1129 | return err; | 1137 | data->groups[groups++] = &lm63_group_fan1; |
1130 | if (data->config & 0x04) { /* tachometer enabled */ | ||
1131 | err = sysfs_create_group(&client->dev.kobj, &lm63_group_fan1); | ||
1132 | if (err) | ||
1133 | goto exit_remove_files; | ||
1134 | } | ||
1135 | if (data->kind == lm96163) { | ||
1136 | err = device_create_file(&client->dev, &dev_attr_temp2_type); | ||
1137 | if (err) | ||
1138 | goto exit_remove_files; | ||
1139 | |||
1140 | err = sysfs_create_group(&client->dev.kobj, | ||
1141 | &lm63_group_extra_lut); | ||
1142 | if (err) | ||
1143 | goto exit_remove_files; | ||
1144 | } | ||
1145 | |||
1146 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
1147 | if (IS_ERR(data->hwmon_dev)) { | ||
1148 | err = PTR_ERR(data->hwmon_dev); | ||
1149 | goto exit_remove_files; | ||
1150 | } | ||
1151 | 1138 | ||
1152 | return 0; | ||
1153 | |||
1154 | exit_remove_files: | ||
1155 | sysfs_remove_group(&client->dev.kobj, &lm63_group); | ||
1156 | sysfs_remove_group(&client->dev.kobj, &lm63_group_fan1); | ||
1157 | if (data->kind == lm96163) { | 1139 | if (data->kind == lm96163) { |
1158 | device_remove_file(&client->dev, &dev_attr_temp2_type); | 1140 | data->groups[groups++] = &lm63_group_temp2_type; |
1159 | sysfs_remove_group(&client->dev.kobj, &lm63_group_extra_lut); | 1141 | data->groups[groups++] = &lm63_group_extra_lut; |
1160 | } | 1142 | } |
1161 | return err; | ||
1162 | } | ||
1163 | |||
1164 | static int lm63_remove(struct i2c_client *client) | ||
1165 | { | ||
1166 | struct lm63_data *data = i2c_get_clientdata(client); | ||
1167 | 1143 | ||
1168 | hwmon_device_unregister(data->hwmon_dev); | 1144 | hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, |
1169 | sysfs_remove_group(&client->dev.kobj, &lm63_group); | 1145 | data, data->groups); |
1170 | sysfs_remove_group(&client->dev.kobj, &lm63_group_fan1); | 1146 | return PTR_ERR_OR_ZERO(hwmon_dev); |
1171 | if (data->kind == lm96163) { | ||
1172 | device_remove_file(&client->dev, &dev_attr_temp2_type); | ||
1173 | sysfs_remove_group(&client->dev.kobj, &lm63_group_extra_lut); | ||
1174 | } | ||
1175 | |||
1176 | return 0; | ||
1177 | } | 1147 | } |
1178 | 1148 | ||
1179 | /* | 1149 | /* |
@@ -1194,7 +1164,6 @@ static struct i2c_driver lm63_driver = { | |||
1194 | .name = "lm63", | 1164 | .name = "lm63", |
1195 | }, | 1165 | }, |
1196 | .probe = lm63_probe, | 1166 | .probe = lm63_probe, |
1197 | .remove = lm63_remove, | ||
1198 | .id_table = lm63_id, | 1167 | .id_table = lm63_id, |
1199 | .detect = lm63_detect, | 1168 | .detect = lm63_detect, |
1200 | .address_list = normal_i2c, | 1169 | .address_list = normal_i2c, |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index f17beb5e6dd6..502771c06fd9 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -348,7 +348,6 @@ static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
348 | return -ENOMEM; | 348 | return -ENOMEM; |
349 | 349 | ||
350 | i2c_set_clientdata(client, data); | 350 | i2c_set_clientdata(client, data); |
351 | data->valid = 0; | ||
352 | mutex_init(&data->update_lock); | 351 | mutex_init(&data->update_lock); |
353 | 352 | ||
354 | /* Initialize the LM77 chip */ | 353 | /* Initialize the LM77 chip */ |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index eba89aac3ece..bd0a1ebbf867 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -112,7 +112,7 @@ static inline long TEMP_FROM_REG(u16 temp) | |||
112 | */ | 112 | */ |
113 | 113 | ||
114 | struct lm80_data { | 114 | struct lm80_data { |
115 | struct device *hwmon_dev; | 115 | struct i2c_client *client; |
116 | struct mutex update_lock; | 116 | struct mutex update_lock; |
117 | char error; /* !=0 if error occurred during last update */ | 117 | char error; /* !=0 if error occurred during last update */ |
118 | char valid; /* !=0 if following fields are valid */ | 118 | char valid; /* !=0 if following fields are valid */ |
@@ -140,7 +140,6 @@ static int lm80_probe(struct i2c_client *client, | |||
140 | const struct i2c_device_id *id); | 140 | const struct i2c_device_id *id); |
141 | static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info); | 141 | static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info); |
142 | static void lm80_init_client(struct i2c_client *client); | 142 | static void lm80_init_client(struct i2c_client *client); |
143 | static int lm80_remove(struct i2c_client *client); | ||
144 | static struct lm80_data *lm80_update_device(struct device *dev); | 143 | static struct lm80_data *lm80_update_device(struct device *dev); |
145 | static int lm80_read_value(struct i2c_client *client, u8 reg); | 144 | static int lm80_read_value(struct i2c_client *client, u8 reg); |
146 | static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value); | 145 | static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value); |
@@ -162,7 +161,6 @@ static struct i2c_driver lm80_driver = { | |||
162 | .name = "lm80", | 161 | .name = "lm80", |
163 | }, | 162 | }, |
164 | .probe = lm80_probe, | 163 | .probe = lm80_probe, |
165 | .remove = lm80_remove, | ||
166 | .id_table = lm80_id, | 164 | .id_table = lm80_id, |
167 | .detect = lm80_detect, | 165 | .detect = lm80_detect, |
168 | .address_list = normal_i2c, | 166 | .address_list = normal_i2c, |
@@ -191,8 +189,8 @@ static ssize_t set_in_##suffix(struct device *dev, \ | |||
191 | struct device_attribute *attr, const char *buf, size_t count) \ | 189 | struct device_attribute *attr, const char *buf, size_t count) \ |
192 | { \ | 190 | { \ |
193 | int nr = to_sensor_dev_attr(attr)->index; \ | 191 | int nr = to_sensor_dev_attr(attr)->index; \ |
194 | struct i2c_client *client = to_i2c_client(dev); \ | 192 | struct lm80_data *data = dev_get_drvdata(dev); \ |
195 | struct lm80_data *data = i2c_get_clientdata(client); \ | 193 | struct i2c_client *client = data->client; \ |
196 | long val; \ | 194 | long val; \ |
197 | int err = kstrtol(buf, 10, &val); \ | 195 | int err = kstrtol(buf, 10, &val); \ |
198 | if (err < 0) \ | 196 | if (err < 0) \ |
@@ -235,8 +233,8 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
235 | const char *buf, size_t count) | 233 | const char *buf, size_t count) |
236 | { | 234 | { |
237 | int nr = to_sensor_dev_attr(attr)->index; | 235 | int nr = to_sensor_dev_attr(attr)->index; |
238 | struct i2c_client *client = to_i2c_client(dev); | 236 | struct lm80_data *data = dev_get_drvdata(dev); |
239 | struct lm80_data *data = i2c_get_clientdata(client); | 237 | struct i2c_client *client = data->client; |
240 | unsigned long val; | 238 | unsigned long val; |
241 | int err = kstrtoul(buf, 10, &val); | 239 | int err = kstrtoul(buf, 10, &val); |
242 | if (err < 0) | 240 | if (err < 0) |
@@ -259,8 +257,8 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
259 | const char *buf, size_t count) | 257 | const char *buf, size_t count) |
260 | { | 258 | { |
261 | int nr = to_sensor_dev_attr(attr)->index; | 259 | int nr = to_sensor_dev_attr(attr)->index; |
262 | struct i2c_client *client = to_i2c_client(dev); | 260 | struct lm80_data *data = dev_get_drvdata(dev); |
263 | struct lm80_data *data = i2c_get_clientdata(client); | 261 | struct i2c_client *client = data->client; |
264 | unsigned long min, val; | 262 | unsigned long min, val; |
265 | u8 reg; | 263 | u8 reg; |
266 | int err = kstrtoul(buf, 10, &val); | 264 | int err = kstrtoul(buf, 10, &val); |
@@ -286,7 +284,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
286 | data->fan_div[nr] = 3; | 284 | data->fan_div[nr] = 3; |
287 | break; | 285 | break; |
288 | default: | 286 | default: |
289 | dev_err(&client->dev, | 287 | dev_err(dev, |
290 | "fan_div value %ld not supported. Choose one of 1, 2, 4 or 8!\n", | 288 | "fan_div value %ld not supported. Choose one of 1, 2, 4 or 8!\n", |
291 | val); | 289 | val); |
292 | mutex_unlock(&data->update_lock); | 290 | mutex_unlock(&data->update_lock); |
@@ -332,8 +330,8 @@ show_temp(os_hyst, temp_os_hyst); | |||
332 | static ssize_t set_temp_##suffix(struct device *dev, \ | 330 | static ssize_t set_temp_##suffix(struct device *dev, \ |
333 | struct device_attribute *attr, const char *buf, size_t count) \ | 331 | struct device_attribute *attr, const char *buf, size_t count) \ |
334 | { \ | 332 | { \ |
335 | struct i2c_client *client = to_i2c_client(dev); \ | 333 | struct lm80_data *data = dev_get_drvdata(dev); \ |
336 | struct lm80_data *data = i2c_get_clientdata(client); \ | 334 | struct i2c_client *client = data->client; \ |
337 | long val; \ | 335 | long val; \ |
338 | int err = kstrtol(buf, 10, &val); \ | 336 | int err = kstrtol(buf, 10, &val); \ |
339 | if (err < 0) \ | 337 | if (err < 0) \ |
@@ -440,7 +438,7 @@ static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 13); | |||
440 | * Real code | 438 | * Real code |
441 | */ | 439 | */ |
442 | 440 | ||
443 | static struct attribute *lm80_attributes[] = { | 441 | static struct attribute *lm80_attrs[] = { |
444 | &sensor_dev_attr_in0_min.dev_attr.attr, | 442 | &sensor_dev_attr_in0_min.dev_attr.attr, |
445 | &sensor_dev_attr_in1_min.dev_attr.attr, | 443 | &sensor_dev_attr_in1_min.dev_attr.attr, |
446 | &sensor_dev_attr_in2_min.dev_attr.attr, | 444 | &sensor_dev_attr_in2_min.dev_attr.attr, |
@@ -487,10 +485,7 @@ static struct attribute *lm80_attributes[] = { | |||
487 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, | 485 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, |
488 | NULL | 486 | NULL |
489 | }; | 487 | }; |
490 | 488 | ATTRIBUTE_GROUPS(lm80); | |
491 | static const struct attribute_group lm80_group = { | ||
492 | .attrs = lm80_attributes, | ||
493 | }; | ||
494 | 489 | ||
495 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 490 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
496 | static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info) | 491 | static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info) |
@@ -541,14 +536,15 @@ static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info) | |||
541 | static int lm80_probe(struct i2c_client *client, | 536 | static int lm80_probe(struct i2c_client *client, |
542 | const struct i2c_device_id *id) | 537 | const struct i2c_device_id *id) |
543 | { | 538 | { |
539 | struct device *dev = &client->dev; | ||
540 | struct device *hwmon_dev; | ||
544 | struct lm80_data *data; | 541 | struct lm80_data *data; |
545 | int err; | ||
546 | 542 | ||
547 | data = devm_kzalloc(&client->dev, sizeof(struct lm80_data), GFP_KERNEL); | 543 | data = devm_kzalloc(dev, sizeof(struct lm80_data), GFP_KERNEL); |
548 | if (!data) | 544 | if (!data) |
549 | return -ENOMEM; | 545 | return -ENOMEM; |
550 | 546 | ||
551 | i2c_set_clientdata(client, data); | 547 | data->client = client; |
552 | mutex_init(&data->update_lock); | 548 | mutex_init(&data->update_lock); |
553 | 549 | ||
554 | /* Initialize the LM80 chip */ | 550 | /* Initialize the LM80 chip */ |
@@ -558,32 +554,10 @@ static int lm80_probe(struct i2c_client *client, | |||
558 | data->fan_min[0] = lm80_read_value(client, LM80_REG_FAN_MIN(1)); | 554 | data->fan_min[0] = lm80_read_value(client, LM80_REG_FAN_MIN(1)); |
559 | data->fan_min[1] = lm80_read_value(client, LM80_REG_FAN_MIN(2)); | 555 | data->fan_min[1] = lm80_read_value(client, LM80_REG_FAN_MIN(2)); |
560 | 556 | ||
561 | /* Register sysfs hooks */ | 557 | hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, |
562 | err = sysfs_create_group(&client->dev.kobj, &lm80_group); | 558 | data, lm80_groups); |
563 | if (err) | ||
564 | return err; | ||
565 | |||
566 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
567 | if (IS_ERR(data->hwmon_dev)) { | ||
568 | err = PTR_ERR(data->hwmon_dev); | ||
569 | goto error_remove; | ||
570 | } | ||
571 | 559 | ||
572 | return 0; | 560 | return PTR_ERR_OR_ZERO(hwmon_dev); |
573 | |||
574 | error_remove: | ||
575 | sysfs_remove_group(&client->dev.kobj, &lm80_group); | ||
576 | return err; | ||
577 | } | ||
578 | |||
579 | static int lm80_remove(struct i2c_client *client) | ||
580 | { | ||
581 | struct lm80_data *data = i2c_get_clientdata(client); | ||
582 | |||
583 | hwmon_device_unregister(data->hwmon_dev); | ||
584 | sysfs_remove_group(&client->dev.kobj, &lm80_group); | ||
585 | |||
586 | return 0; | ||
587 | } | 561 | } |
588 | 562 | ||
589 | static int lm80_read_value(struct i2c_client *client, u8 reg) | 563 | static int lm80_read_value(struct i2c_client *client, u8 reg) |
@@ -614,8 +588,8 @@ static void lm80_init_client(struct i2c_client *client) | |||
614 | 588 | ||
615 | static struct lm80_data *lm80_update_device(struct device *dev) | 589 | static struct lm80_data *lm80_update_device(struct device *dev) |
616 | { | 590 | { |
617 | struct i2c_client *client = to_i2c_client(dev); | 591 | struct lm80_data *data = dev_get_drvdata(dev); |
618 | struct lm80_data *data = i2c_get_clientdata(client); | 592 | struct i2c_client *client = data->client; |
619 | int i; | 593 | int i; |
620 | int rv; | 594 | int rv; |
621 | int prev_rv; | 595 | int prev_rv; |
@@ -627,7 +601,7 @@ static struct lm80_data *lm80_update_device(struct device *dev) | |||
627 | lm80_init_client(client); | 601 | lm80_init_client(client); |
628 | 602 | ||
629 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { | 603 | if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { |
630 | dev_dbg(&client->dev, "Starting lm80 update\n"); | 604 | dev_dbg(dev, "Starting lm80 update\n"); |
631 | for (i = 0; i <= 6; i++) { | 605 | for (i = 0; i <= 6; i++) { |
632 | rv = lm80_read_value(client, LM80_REG_IN(i)); | 606 | rv = lm80_read_value(client, LM80_REG_IN(i)); |
633 | if (rv < 0) | 607 | if (rv < 0) |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index abd270243ba7..be02155788c3 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -349,7 +349,6 @@ static int lm83_probe(struct i2c_client *new_client, | |||
349 | return -ENOMEM; | 349 | return -ENOMEM; |
350 | 350 | ||
351 | i2c_set_clientdata(new_client, data); | 351 | i2c_set_clientdata(new_client, data); |
352 | data->valid = 0; | ||
353 | mutex_init(&data->update_lock); | 352 | mutex_init(&data->update_lock); |
354 | 353 | ||
355 | /* | 354 | /* |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 4c5f20231c1a..ba1d83d48056 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -903,7 +903,6 @@ static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
903 | return -ENOMEM; | 903 | return -ENOMEM; |
904 | 904 | ||
905 | i2c_set_clientdata(client, data); | 905 | i2c_set_clientdata(client, data); |
906 | data->valid = 0; | ||
907 | mutex_init(&data->update_lock); | 906 | mutex_init(&data->update_lock); |
908 | 907 | ||
909 | /* Initialize the LM87 chip */ | 908 | /* Initialize the LM87 chip */ |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 701e952ae523..c9ff08dbe10c 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -365,7 +365,9 @@ enum lm90_temp11_reg_index { | |||
365 | */ | 365 | */ |
366 | 366 | ||
367 | struct lm90_data { | 367 | struct lm90_data { |
368 | struct i2c_client *client; | ||
368 | struct device *hwmon_dev; | 369 | struct device *hwmon_dev; |
370 | const struct attribute_group *groups[6]; | ||
369 | struct mutex update_lock; | 371 | struct mutex update_lock; |
370 | struct regulator *regulator; | 372 | struct regulator *regulator; |
371 | char valid; /* zero until following fields are valid */ | 373 | char valid; /* zero until following fields are valid */ |
@@ -513,8 +515,8 @@ static void lm90_set_convrate(struct i2c_client *client, struct lm90_data *data, | |||
513 | 515 | ||
514 | static struct lm90_data *lm90_update_device(struct device *dev) | 516 | static struct lm90_data *lm90_update_device(struct device *dev) |
515 | { | 517 | { |
516 | struct i2c_client *client = to_i2c_client(dev); | 518 | struct lm90_data *data = dev_get_drvdata(dev); |
517 | struct lm90_data *data = i2c_get_clientdata(client); | 519 | struct i2c_client *client = data->client; |
518 | unsigned long next_update; | 520 | unsigned long next_update; |
519 | 521 | ||
520 | mutex_lock(&data->update_lock); | 522 | mutex_lock(&data->update_lock); |
@@ -793,8 +795,8 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | |||
793 | }; | 795 | }; |
794 | 796 | ||
795 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 797 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
796 | struct i2c_client *client = to_i2c_client(dev); | 798 | struct lm90_data *data = dev_get_drvdata(dev); |
797 | struct lm90_data *data = i2c_get_clientdata(client); | 799 | struct i2c_client *client = data->client; |
798 | int nr = attr->index; | 800 | int nr = attr->index; |
799 | long val; | 801 | long val; |
800 | int err; | 802 | int err; |
@@ -860,8 +862,8 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
860 | }; | 862 | }; |
861 | 863 | ||
862 | struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); | 864 | struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); |
863 | struct i2c_client *client = to_i2c_client(dev); | 865 | struct lm90_data *data = dev_get_drvdata(dev); |
864 | struct lm90_data *data = i2c_get_clientdata(client); | 866 | struct i2c_client *client = data->client; |
865 | int nr = attr->nr; | 867 | int nr = attr->nr; |
866 | int index = attr->index; | 868 | int index = attr->index; |
867 | long val; | 869 | long val; |
@@ -922,8 +924,8 @@ static ssize_t show_temphyst(struct device *dev, | |||
922 | static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, | 924 | static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, |
923 | const char *buf, size_t count) | 925 | const char *buf, size_t count) |
924 | { | 926 | { |
925 | struct i2c_client *client = to_i2c_client(dev); | 927 | struct lm90_data *data = dev_get_drvdata(dev); |
926 | struct lm90_data *data = i2c_get_clientdata(client); | 928 | struct i2c_client *client = data->client; |
927 | long val; | 929 | long val; |
928 | int err; | 930 | int err; |
929 | int temp; | 931 | int temp; |
@@ -976,8 +978,8 @@ static ssize_t set_update_interval(struct device *dev, | |||
976 | struct device_attribute *attr, | 978 | struct device_attribute *attr, |
977 | const char *buf, size_t count) | 979 | const char *buf, size_t count) |
978 | { | 980 | { |
979 | struct i2c_client *client = to_i2c_client(dev); | 981 | struct lm90_data *data = dev_get_drvdata(dev); |
980 | struct lm90_data *data = i2c_get_clientdata(client); | 982 | struct i2c_client *client = data->client; |
981 | unsigned long val; | 983 | unsigned long val; |
982 | int err; | 984 | int err; |
983 | 985 | ||
@@ -1057,6 +1059,15 @@ static const struct attribute_group lm90_group = { | |||
1057 | .attrs = lm90_attributes, | 1059 | .attrs = lm90_attributes, |
1058 | }; | 1060 | }; |
1059 | 1061 | ||
1062 | static struct attribute *lm90_temp2_offset_attributes[] = { | ||
1063 | &sensor_dev_attr_temp2_offset.dev_attr.attr, | ||
1064 | NULL | ||
1065 | }; | ||
1066 | |||
1067 | static const struct attribute_group lm90_temp2_offset_group = { | ||
1068 | .attrs = lm90_temp2_offset_attributes, | ||
1069 | }; | ||
1070 | |||
1060 | /* | 1071 | /* |
1061 | * Additional attributes for devices with emergency sensors | 1072 | * Additional attributes for devices with emergency sensors |
1062 | */ | 1073 | */ |
@@ -1393,22 +1404,6 @@ static int lm90_detect(struct i2c_client *client, | |||
1393 | return 0; | 1404 | return 0; |
1394 | } | 1405 | } |
1395 | 1406 | ||
1396 | static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data) | ||
1397 | { | ||
1398 | struct device *dev = &client->dev; | ||
1399 | |||
1400 | if (data->flags & LM90_HAVE_TEMP3) | ||
1401 | sysfs_remove_group(&dev->kobj, &lm90_temp3_group); | ||
1402 | if (data->flags & LM90_HAVE_EMERGENCY_ALARM) | ||
1403 | sysfs_remove_group(&dev->kobj, &lm90_emergency_alarm_group); | ||
1404 | if (data->flags & LM90_HAVE_EMERGENCY) | ||
1405 | sysfs_remove_group(&dev->kobj, &lm90_emergency_group); | ||
1406 | if (data->flags & LM90_HAVE_OFFSET) | ||
1407 | device_remove_file(dev, &sensor_dev_attr_temp2_offset.dev_attr); | ||
1408 | device_remove_file(dev, &dev_attr_pec); | ||
1409 | sysfs_remove_group(&dev->kobj, &lm90_group); | ||
1410 | } | ||
1411 | |||
1412 | static void lm90_restore_conf(struct i2c_client *client, struct lm90_data *data) | 1407 | static void lm90_restore_conf(struct i2c_client *client, struct lm90_data *data) |
1413 | { | 1408 | { |
1414 | /* Restore initial configuration */ | 1409 | /* Restore initial configuration */ |
@@ -1418,10 +1413,9 @@ static void lm90_restore_conf(struct i2c_client *client, struct lm90_data *data) | |||
1418 | data->config_orig); | 1413 | data->config_orig); |
1419 | } | 1414 | } |
1420 | 1415 | ||
1421 | static void lm90_init_client(struct i2c_client *client) | 1416 | static void lm90_init_client(struct i2c_client *client, struct lm90_data *data) |
1422 | { | 1417 | { |
1423 | u8 config, convrate; | 1418 | u8 config, convrate; |
1424 | struct lm90_data *data = i2c_get_clientdata(client); | ||
1425 | 1419 | ||
1426 | if (lm90_read_reg(client, LM90_REG_R_CONVRATE, &convrate) < 0) { | 1420 | if (lm90_read_reg(client, LM90_REG_R_CONVRATE, &convrate) < 0) { |
1427 | dev_warn(&client->dev, "Failed to read convrate register!\n"); | 1421 | dev_warn(&client->dev, "Failed to read convrate register!\n"); |
@@ -1519,6 +1513,7 @@ static int lm90_probe(struct i2c_client *client, | |||
1519 | struct i2c_adapter *adapter = to_i2c_adapter(dev->parent); | 1513 | struct i2c_adapter *adapter = to_i2c_adapter(dev->parent); |
1520 | struct lm90_data *data; | 1514 | struct lm90_data *data; |
1521 | struct regulator *regulator; | 1515 | struct regulator *regulator; |
1516 | int groups = 0; | ||
1522 | int err; | 1517 | int err; |
1523 | 1518 | ||
1524 | regulator = devm_regulator_get(dev, "vcc"); | 1519 | regulator = devm_regulator_get(dev, "vcc"); |
@@ -1527,15 +1522,15 @@ static int lm90_probe(struct i2c_client *client, | |||
1527 | 1522 | ||
1528 | err = regulator_enable(regulator); | 1523 | err = regulator_enable(regulator); |
1529 | if (err < 0) { | 1524 | if (err < 0) { |
1530 | dev_err(&client->dev, | 1525 | dev_err(dev, "Failed to enable regulator: %d\n", err); |
1531 | "Failed to enable regulator: %d\n", err); | ||
1532 | return err; | 1526 | return err; |
1533 | } | 1527 | } |
1534 | 1528 | ||
1535 | data = devm_kzalloc(&client->dev, sizeof(struct lm90_data), GFP_KERNEL); | 1529 | data = devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL); |
1536 | if (!data) | 1530 | if (!data) |
1537 | return -ENOMEM; | 1531 | return -ENOMEM; |
1538 | 1532 | ||
1533 | data->client = client; | ||
1539 | i2c_set_clientdata(client, data); | 1534 | i2c_set_clientdata(client, data); |
1540 | mutex_init(&data->update_lock); | 1535 | mutex_init(&data->update_lock); |
1541 | 1536 | ||
@@ -1562,44 +1557,34 @@ static int lm90_probe(struct i2c_client *client, | |||
1562 | data->max_convrate = lm90_params[data->kind].max_convrate; | 1557 | data->max_convrate = lm90_params[data->kind].max_convrate; |
1563 | 1558 | ||
1564 | /* Initialize the LM90 chip */ | 1559 | /* Initialize the LM90 chip */ |
1565 | lm90_init_client(client); | 1560 | lm90_init_client(client, data); |
1566 | 1561 | ||
1567 | /* Register sysfs hooks */ | 1562 | /* Register sysfs hooks */ |
1568 | err = sysfs_create_group(&dev->kobj, &lm90_group); | 1563 | data->groups[groups++] = &lm90_group; |
1569 | if (err) | 1564 | |
1570 | goto exit_restore; | 1565 | if (data->flags & LM90_HAVE_OFFSET) |
1566 | data->groups[groups++] = &lm90_temp2_offset_group; | ||
1567 | |||
1568 | if (data->flags & LM90_HAVE_EMERGENCY) | ||
1569 | data->groups[groups++] = &lm90_emergency_group; | ||
1570 | |||
1571 | if (data->flags & LM90_HAVE_EMERGENCY_ALARM) | ||
1572 | data->groups[groups++] = &lm90_emergency_alarm_group; | ||
1573 | |||
1574 | if (data->flags & LM90_HAVE_TEMP3) | ||
1575 | data->groups[groups++] = &lm90_temp3_group; | ||
1576 | |||
1571 | if (client->flags & I2C_CLIENT_PEC) { | 1577 | if (client->flags & I2C_CLIENT_PEC) { |
1572 | err = device_create_file(dev, &dev_attr_pec); | 1578 | err = device_create_file(dev, &dev_attr_pec); |
1573 | if (err) | 1579 | if (err) |
1574 | goto exit_remove_files; | 1580 | goto exit_restore; |
1575 | } | ||
1576 | if (data->flags & LM90_HAVE_OFFSET) { | ||
1577 | err = device_create_file(dev, | ||
1578 | &sensor_dev_attr_temp2_offset.dev_attr); | ||
1579 | if (err) | ||
1580 | goto exit_remove_files; | ||
1581 | } | ||
1582 | if (data->flags & LM90_HAVE_EMERGENCY) { | ||
1583 | err = sysfs_create_group(&dev->kobj, &lm90_emergency_group); | ||
1584 | if (err) | ||
1585 | goto exit_remove_files; | ||
1586 | } | ||
1587 | if (data->flags & LM90_HAVE_EMERGENCY_ALARM) { | ||
1588 | err = sysfs_create_group(&dev->kobj, | ||
1589 | &lm90_emergency_alarm_group); | ||
1590 | if (err) | ||
1591 | goto exit_remove_files; | ||
1592 | } | ||
1593 | if (data->flags & LM90_HAVE_TEMP3) { | ||
1594 | err = sysfs_create_group(&dev->kobj, &lm90_temp3_group); | ||
1595 | if (err) | ||
1596 | goto exit_remove_files; | ||
1597 | } | 1581 | } |
1598 | 1582 | ||
1599 | data->hwmon_dev = hwmon_device_register(dev); | 1583 | data->hwmon_dev = hwmon_device_register_with_groups(dev, client->name, |
1584 | data, data->groups); | ||
1600 | if (IS_ERR(data->hwmon_dev)) { | 1585 | if (IS_ERR(data->hwmon_dev)) { |
1601 | err = PTR_ERR(data->hwmon_dev); | 1586 | err = PTR_ERR(data->hwmon_dev); |
1602 | goto exit_remove_files; | 1587 | goto exit_remove_pec; |
1603 | } | 1588 | } |
1604 | 1589 | ||
1605 | if (client->irq) { | 1590 | if (client->irq) { |
@@ -1618,8 +1603,8 @@ static int lm90_probe(struct i2c_client *client, | |||
1618 | 1603 | ||
1619 | exit_unregister: | 1604 | exit_unregister: |
1620 | hwmon_device_unregister(data->hwmon_dev); | 1605 | hwmon_device_unregister(data->hwmon_dev); |
1621 | exit_remove_files: | 1606 | exit_remove_pec: |
1622 | lm90_remove_files(client, data); | 1607 | device_remove_file(dev, &dev_attr_pec); |
1623 | exit_restore: | 1608 | exit_restore: |
1624 | lm90_restore_conf(client, data); | 1609 | lm90_restore_conf(client, data); |
1625 | regulator_disable(data->regulator); | 1610 | regulator_disable(data->regulator); |
@@ -1632,7 +1617,7 @@ static int lm90_remove(struct i2c_client *client) | |||
1632 | struct lm90_data *data = i2c_get_clientdata(client); | 1617 | struct lm90_data *data = i2c_get_clientdata(client); |
1633 | 1618 | ||
1634 | hwmon_device_unregister(data->hwmon_dev); | 1619 | hwmon_device_unregister(data->hwmon_dev); |
1635 | lm90_remove_files(client, data); | 1620 | device_remove_file(&client->dev, &dev_attr_pec); |
1636 | lm90_restore_conf(client, data); | 1621 | lm90_restore_conf(client, data); |
1637 | regulator_disable(data->regulator); | 1622 | regulator_disable(data->regulator); |
1638 | 1623 | ||
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 9d0e87a4f0cb..b9022db6511a 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -380,7 +380,6 @@ static int lm92_probe(struct i2c_client *new_client, | |||
380 | return -ENOMEM; | 380 | return -ENOMEM; |
381 | 381 | ||
382 | i2c_set_clientdata(new_client, data); | 382 | i2c_set_clientdata(new_client, data); |
383 | data->valid = 0; | ||
384 | mutex_init(&data->update_lock); | 383 | mutex_init(&data->update_lock); |
385 | 384 | ||
386 | /* Initialize the chipset */ | 385 | /* Initialize the chipset */ |
diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c index 6f1c6c0dbaf5..adf23165a6a7 100644 --- a/drivers/hwmon/lm93.c +++ b/drivers/hwmon/lm93.c | |||
@@ -2754,7 +2754,6 @@ static int lm93_probe(struct i2c_client *client, | |||
2754 | i2c_set_clientdata(client, data); | 2754 | i2c_set_clientdata(client, data); |
2755 | 2755 | ||
2756 | /* housekeeping */ | 2756 | /* housekeeping */ |
2757 | data->valid = 0; | ||
2758 | data->update = update; | 2757 | data->update = update; |
2759 | mutex_init(&data->update_lock); | 2758 | mutex_init(&data->update_lock); |
2760 | 2759 | ||
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 6638e997f83f..4c23afe113e2 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -273,7 +273,6 @@ static int max1619_probe(struct i2c_client *new_client, | |||
273 | return -ENOMEM; | 273 | return -ENOMEM; |
274 | 274 | ||
275 | i2c_set_clientdata(new_client, data); | 275 | i2c_set_clientdata(new_client, data); |
276 | data->valid = 0; | ||
277 | mutex_init(&data->update_lock); | 276 | mutex_init(&data->update_lock); |
278 | 277 | ||
279 | /* Initialize the MAX1619 chip */ | 278 | /* Initialize the MAX1619 chip */ |
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 330fe117e219..988181e4cfcd 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -1225,7 +1225,7 @@ static int pc87360_probe(struct platform_device *pdev) | |||
1225 | int i; | 1225 | int i; |
1226 | struct pc87360_data *data; | 1226 | struct pc87360_data *data; |
1227 | int err = 0; | 1227 | int err = 0; |
1228 | const char *name = "pc87360"; | 1228 | const char *name; |
1229 | int use_thermistors = 0; | 1229 | int use_thermistors = 0; |
1230 | struct device *dev = &pdev->dev; | 1230 | struct device *dev = &pdev->dev; |
1231 | 1231 | ||
@@ -1233,13 +1233,14 @@ static int pc87360_probe(struct platform_device *pdev) | |||
1233 | if (!data) | 1233 | if (!data) |
1234 | return -ENOMEM; | 1234 | return -ENOMEM; |
1235 | 1235 | ||
1236 | data->fannr = 2; | ||
1237 | data->innr = 0; | ||
1238 | data->tempnr = 0; | ||
1239 | |||
1240 | switch (devid) { | 1236 | switch (devid) { |
1237 | default: | ||
1238 | name = "pc87360"; | ||
1239 | data->fannr = 2; | ||
1240 | break; | ||
1241 | case 0xe8: | 1241 | case 0xe8: |
1242 | name = "pc87363"; | 1242 | name = "pc87363"; |
1243 | data->fannr = 2; | ||
1243 | break; | 1244 | break; |
1244 | case 0xe4: | 1245 | case 0xe4: |
1245 | name = "pc87364"; | 1246 | name = "pc87364"; |
@@ -1260,7 +1261,6 @@ static int pc87360_probe(struct platform_device *pdev) | |||
1260 | } | 1261 | } |
1261 | 1262 | ||
1262 | data->name = name; | 1263 | data->name = name; |
1263 | data->valid = 0; | ||
1264 | mutex_init(&data->lock); | 1264 | mutex_init(&data->lock); |
1265 | mutex_init(&data->update_lock); | 1265 | mutex_init(&data->update_lock); |
1266 | platform_set_drvdata(pdev, data); | 1266 | platform_set_drvdata(pdev, data); |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index df585808adb6..4068db4d9580 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -1376,7 +1376,6 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1376 | return -ENOMEM; | 1376 | return -ENOMEM; |
1377 | 1377 | ||
1378 | i2c_set_clientdata(client, data); | 1378 | i2c_set_clientdata(client, data); |
1379 | data->valid = 0; | ||
1380 | mutex_init(&data->update_lock); | 1379 | mutex_init(&data->update_lock); |
1381 | 1380 | ||
1382 | err = w83792d_detect_subclients(client); | 1381 | err = w83792d_detect_subclients(client); |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 6384b268f590..ac3043122011 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -188,12 +188,8 @@ static int w83l785ts_probe(struct i2c_client *client, | |||
188 | return -ENOMEM; | 188 | return -ENOMEM; |
189 | 189 | ||
190 | i2c_set_clientdata(client, data); | 190 | i2c_set_clientdata(client, data); |
191 | data->valid = 0; | ||
192 | mutex_init(&data->update_lock); | 191 | mutex_init(&data->update_lock); |
193 | 192 | ||
194 | /* Default values in case the first read fails (unlikely). */ | ||
195 | data->temp[1] = data->temp[0] = 0; | ||
196 | |||
197 | /* | 193 | /* |
198 | * Initialize the W83L785TS chip | 194 | * Initialize the W83L785TS chip |
199 | * Nothing yet, assume it is already started. | 195 | * Nothing yet, assume it is already started. |