diff options
Diffstat (limited to 'drivers/hwmon')
36 files changed, 469 insertions, 486 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index e928cdb041cb..8102876c7c3f 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -121,7 +121,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg, | |||
121 | static struct adm1021_data *adm1021_update_device(struct device *dev); | 121 | static struct adm1021_data *adm1021_update_device(struct device *dev); |
122 | 122 | ||
123 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ | 123 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ |
124 | static int read_only = 0; | 124 | static int read_only; |
125 | 125 | ||
126 | 126 | ||
127 | /* This is the driver that will be inserted */ | 127 | /* This is the driver that will be inserted */ |
@@ -204,11 +204,10 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
204 | client structure, even though we cannot fill it completely yet. | 204 | client structure, even though we cannot fill it completely yet. |
205 | But it allows us to access adm1021_{read,write}_value. */ | 205 | But it allows us to access adm1021_{read,write}_value. */ |
206 | 206 | ||
207 | if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { | 207 | if (!(data = kzalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { |
208 | err = -ENOMEM; | 208 | err = -ENOMEM; |
209 | goto error0; | 209 | goto error0; |
210 | } | 210 | } |
211 | memset(data, 0, sizeof(struct adm1021_data)); | ||
212 | 211 | ||
213 | new_client = &data->client; | 212 | new_client = &data->client; |
214 | i2c_set_clientdata(new_client, data); | 213 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 526b7ff179eb..3ec12421694f 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -331,11 +331,10 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
331 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 331 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
332 | goto exit; | 332 | goto exit; |
333 | 333 | ||
334 | if (!(data = kmalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { | 334 | if (!(data = kzalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { |
335 | err = -ENOMEM; | 335 | err = -ENOMEM; |
336 | goto exit; | 336 | goto exit; |
337 | } | 337 | } |
338 | memset(data, 0, sizeof(struct adm1025_data)); | ||
339 | 338 | ||
340 | /* The common I2C client data is placed right before the | 339 | /* The common I2C client data is placed right before the |
341 | ADM1025-specific data. */ | 340 | ADM1025-specific data. */ |
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 625158110fd4..e0f56549d1d8 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -315,7 +315,7 @@ static struct i2c_driver adm1026_driver = { | |||
315 | .detach_client = adm1026_detach_client, | 315 | .detach_client = adm1026_detach_client, |
316 | }; | 316 | }; |
317 | 317 | ||
318 | int adm1026_attach_adapter(struct i2c_adapter *adapter) | 318 | static int adm1026_attach_adapter(struct i2c_adapter *adapter) |
319 | { | 319 | { |
320 | if (!(adapter->class & I2C_CLASS_HWMON)) { | 320 | if (!(adapter->class & I2C_CLASS_HWMON)) { |
321 | return 0; | 321 | return 0; |
@@ -323,7 +323,7 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter) | |||
323 | return i2c_probe(adapter, &addr_data, adm1026_detect); | 323 | return i2c_probe(adapter, &addr_data, adm1026_detect); |
324 | } | 324 | } |
325 | 325 | ||
326 | int adm1026_detach_client(struct i2c_client *client) | 326 | static int adm1026_detach_client(struct i2c_client *client) |
327 | { | 327 | { |
328 | struct adm1026_data *data = i2c_get_clientdata(client); | 328 | struct adm1026_data *data = i2c_get_clientdata(client); |
329 | hwmon_device_unregister(data->class_dev); | 329 | hwmon_device_unregister(data->class_dev); |
@@ -332,7 +332,7 @@ int adm1026_detach_client(struct i2c_client *client) | |||
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | int adm1026_read_value(struct i2c_client *client, u8 reg) | 335 | static int adm1026_read_value(struct i2c_client *client, u8 reg) |
336 | { | 336 | { |
337 | int res; | 337 | int res; |
338 | 338 | ||
@@ -346,7 +346,7 @@ int adm1026_read_value(struct i2c_client *client, u8 reg) | |||
346 | return res; | 346 | return res; |
347 | } | 347 | } |
348 | 348 | ||
349 | int adm1026_write_value(struct i2c_client *client, u8 reg, int value) | 349 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value) |
350 | { | 350 | { |
351 | int res; | 351 | int res; |
352 | 352 | ||
@@ -360,7 +360,7 @@ int adm1026_write_value(struct i2c_client *client, u8 reg, int value) | |||
360 | return res; | 360 | return res; |
361 | } | 361 | } |
362 | 362 | ||
363 | void adm1026_init_client(struct i2c_client *client) | 363 | static void adm1026_init_client(struct i2c_client *client) |
364 | { | 364 | { |
365 | int value, i; | 365 | int value, i; |
366 | struct adm1026_data *data = i2c_get_clientdata(client); | 366 | struct adm1026_data *data = i2c_get_clientdata(client); |
@@ -460,7 +460,7 @@ void adm1026_init_client(struct i2c_client *client) | |||
460 | } | 460 | } |
461 | } | 461 | } |
462 | 462 | ||
463 | void adm1026_print_gpio(struct i2c_client *client) | 463 | static void adm1026_print_gpio(struct i2c_client *client) |
464 | { | 464 | { |
465 | struct adm1026_data *data = i2c_get_clientdata(client); | 465 | struct adm1026_data *data = i2c_get_clientdata(client); |
466 | int i; | 466 | int i; |
@@ -492,7 +492,7 @@ void adm1026_print_gpio(struct i2c_client *client) | |||
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | void adm1026_fixup_gpio(struct i2c_client *client) | 495 | static void adm1026_fixup_gpio(struct i2c_client *client) |
496 | { | 496 | { |
497 | struct adm1026_data *data = i2c_get_clientdata(client); | 497 | struct adm1026_data *data = i2c_get_clientdata(client); |
498 | int i; | 498 | int i; |
@@ -1452,8 +1452,8 @@ static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | |||
1452 | static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | 1452 | static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); |
1453 | static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | 1453 | static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); |
1454 | 1454 | ||
1455 | int adm1026_detect(struct i2c_adapter *adapter, int address, | 1455 | static int adm1026_detect(struct i2c_adapter *adapter, int address, |
1456 | int kind) | 1456 | int kind) |
1457 | { | 1457 | { |
1458 | int company, verstep; | 1458 | int company, verstep; |
1459 | struct i2c_client *new_client; | 1459 | struct i2c_client *new_client; |
@@ -1470,13 +1470,11 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1470 | client structure, even though we cannot fill it completely yet. | 1470 | client structure, even though we cannot fill it completely yet. |
1471 | But it allows us to access adm1026_{read,write}_value. */ | 1471 | But it allows us to access adm1026_{read,write}_value. */ |
1472 | 1472 | ||
1473 | if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { | 1473 | if (!(data = kzalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { |
1474 | err = -ENOMEM; | 1474 | err = -ENOMEM; |
1475 | goto exit; | 1475 | goto exit; |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | memset(data, 0, sizeof(struct adm1026_data)); | ||
1479 | |||
1480 | new_client = &data->client; | 1478 | new_client = &data->client; |
1481 | i2c_set_clientdata(new_client, data); | 1479 | i2c_set_clientdata(new_client, data); |
1482 | new_client->addr = address; | 1480 | new_client->addr = address; |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 58338ed7c8a1..7c545d5eee45 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -740,11 +740,10 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
740 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 740 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
741 | goto exit; | 741 | goto exit; |
742 | 742 | ||
743 | if (!(data = kmalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { | 743 | if (!(data = kzalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { |
744 | err = -ENOMEM; | 744 | err = -ENOMEM; |
745 | goto exit; | 745 | goto exit; |
746 | } | 746 | } |
747 | memset(data, 0, sizeof(struct adm1031_data)); | ||
748 | 747 | ||
749 | new_client = &data->client; | 748 | new_client = &data->client; |
750 | i2c_set_clientdata(new_client, data); | 749 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index bc7faef162f7..11dc95f8a17e 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
46 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
47 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
48 | #include <linux/hwmon-sysfs.h> | ||
48 | #include <linux/hwmon.h> | 49 | #include <linux/hwmon.h> |
49 | #include <linux/hwmon-vid.h> | 50 | #include <linux/hwmon-vid.h> |
50 | #include <linux/err.h> | 51 | #include <linux/err.h> |
@@ -69,8 +70,7 @@ I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81); | |||
69 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) | 70 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) |
70 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) | 71 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) |
71 | #define ADM9240_REG_TEMP 0x27 | 72 | #define ADM9240_REG_TEMP 0x27 |
72 | #define ADM9240_REG_TEMP_HIGH 0x39 | 73 | #define ADM9240_REG_TEMP_MAX(nr) (0x39 + (nr)) /* 0, 1 = high, hyst */ |
73 | #define ADM9240_REG_TEMP_HYST 0x3a | ||
74 | #define ADM9240_REG_ANALOG_OUT 0x19 | 74 | #define ADM9240_REG_ANALOG_OUT 0x19 |
75 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 | 75 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 |
76 | #define ADM9240_REG_VID_FAN_DIV 0x47 | 76 | #define ADM9240_REG_VID_FAN_DIV 0x47 |
@@ -162,177 +162,155 @@ struct adm9240_data { | |||
162 | u8 fan_min[2]; /* rw fan1_min */ | 162 | u8 fan_min[2]; /* rw fan1_min */ |
163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ | 163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ |
164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ | 164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ |
165 | s8 temp_high; /* rw temp1_max */ | 165 | s8 temp_max[2]; /* rw 0 -> temp_max, 1 -> temp_max_hyst */ |
166 | s8 temp_hyst; /* rw temp1_max_hyst */ | ||
167 | u16 alarms; /* ro alarms */ | 166 | u16 alarms; /* ro alarms */ |
168 | u8 aout; /* rw aout_output */ | 167 | u8 aout; /* rw aout_output */ |
169 | u8 vid; /* ro vid */ | 168 | u8 vid; /* ro vid */ |
170 | u8 vrm; /* -- vrm set on startup, no accessor */ | 169 | u8 vrm; /* -- vrm set on startup, no accessor */ |
171 | }; | 170 | }; |
172 | 171 | ||
173 | /* i2c byte read/write interface */ | 172 | /*** sysfs accessors ***/ |
174 | static int adm9240_read_value(struct i2c_client *client, u8 reg) | 173 | |
174 | /* temperature */ | ||
175 | static ssize_t show_temp(struct device *dev, struct device_attribute *dummy, | ||
176 | char *buf) | ||
175 | { | 177 | { |
176 | return i2c_smbus_read_byte_data(client, reg); | 178 | struct adm9240_data *data = adm9240_update_device(dev); |
179 | return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */ | ||
177 | } | 180 | } |
178 | 181 | ||
179 | static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) | 182 | static ssize_t show_max(struct device *dev, struct device_attribute *devattr, |
183 | char *buf) | ||
180 | { | 184 | { |
181 | return i2c_smbus_write_byte_data(client, reg, value); | 185 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
186 | struct adm9240_data *data = adm9240_update_device(dev); | ||
187 | return sprintf(buf, "%d\n", data->temp_max[attr->index] * 1000); | ||
182 | } | 188 | } |
183 | 189 | ||
184 | /*** sysfs accessors ***/ | 190 | static ssize_t set_max(struct device *dev, struct device_attribute *devattr, |
191 | const char *buf, size_t count) | ||
192 | { | ||
193 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
194 | struct i2c_client *client = to_i2c_client(dev); | ||
195 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
196 | long val = simple_strtol(buf, NULL, 10); | ||
197 | |||
198 | down(&data->update_lock); | ||
199 | data->temp_max[attr->index] = TEMP_TO_REG(val); | ||
200 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), | ||
201 | data->temp_max[attr->index]); | ||
202 | up(&data->update_lock); | ||
203 | return count; | ||
204 | } | ||
185 | 205 | ||
186 | /* temperature */ | ||
187 | #define show_temp(value, scale) \ | ||
188 | static ssize_t show_##value(struct device *dev, \ | ||
189 | struct device_attribute *attr, \ | ||
190 | char *buf) \ | ||
191 | { \ | ||
192 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
193 | return sprintf(buf, "%d\n", data->value * scale); \ | ||
194 | } | ||
195 | show_temp(temp_high, 1000); | ||
196 | show_temp(temp_hyst, 1000); | ||
197 | show_temp(temp, 500); /* 0.5'C per bit */ | ||
198 | |||
199 | #define set_temp(value, reg) \ | ||
200 | static ssize_t set_##value(struct device *dev, \ | ||
201 | struct device_attribute *attr, \ | ||
202 | const char *buf, size_t count) \ | ||
203 | { \ | ||
204 | struct i2c_client *client = to_i2c_client(dev); \ | ||
205 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
206 | long temp = simple_strtoul(buf, NULL, 10); \ | ||
207 | \ | ||
208 | down(&data->update_lock); \ | ||
209 | data->value = TEMP_TO_REG(temp); \ | ||
210 | adm9240_write_value(client, reg, data->value); \ | ||
211 | up(&data->update_lock); \ | ||
212 | return count; \ | ||
213 | } | ||
214 | |||
215 | set_temp(temp_high, ADM9240_REG_TEMP_HIGH); | ||
216 | set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); | ||
217 | |||
218 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
219 | show_temp_high, set_temp_high); | ||
220 | static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
221 | show_temp_hyst, set_temp_hyst); | ||
222 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | 206 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); |
207 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
208 | show_max, set_max, 0); | ||
209 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
210 | show_max, set_max, 1); | ||
223 | 211 | ||
224 | /* voltage */ | 212 | /* voltage */ |
225 | static ssize_t show_in(struct device *dev, char *buf, int nr) | 213 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
214 | char *buf) | ||
226 | { | 215 | { |
216 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
227 | struct adm9240_data *data = adm9240_update_device(dev); | 217 | struct adm9240_data *data = adm9240_update_device(dev); |
228 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); | 218 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[attr->index], |
219 | attr->index)); | ||
229 | } | 220 | } |
230 | 221 | ||
231 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | 222 | static ssize_t show_in_min(struct device *dev, |
223 | struct device_attribute *devattr, char *buf) | ||
232 | { | 224 | { |
225 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
233 | struct adm9240_data *data = adm9240_update_device(dev); | 226 | struct adm9240_data *data = adm9240_update_device(dev); |
234 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); | 227 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[attr->index], |
228 | attr->index)); | ||
235 | } | 229 | } |
236 | 230 | ||
237 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 231 | static ssize_t show_in_max(struct device *dev, |
232 | struct device_attribute *devattr, char *buf) | ||
238 | { | 233 | { |
234 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
239 | struct adm9240_data *data = adm9240_update_device(dev); | 235 | struct adm9240_data *data = adm9240_update_device(dev); |
240 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); | 236 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[attr->index], |
237 | attr->index)); | ||
241 | } | 238 | } |
242 | 239 | ||
243 | static ssize_t set_in_min(struct device *dev, const char *buf, | 240 | static ssize_t set_in_min(struct device *dev, |
244 | size_t count, int nr) | 241 | struct device_attribute *devattr, |
242 | const char *buf, size_t count) | ||
245 | { | 243 | { |
244 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
246 | struct i2c_client *client = to_i2c_client(dev); | 245 | struct i2c_client *client = to_i2c_client(dev); |
247 | struct adm9240_data *data = i2c_get_clientdata(client); | 246 | struct adm9240_data *data = i2c_get_clientdata(client); |
248 | unsigned long val = simple_strtoul(buf, NULL, 10); | 247 | unsigned long val = simple_strtoul(buf, NULL, 10); |
249 | 248 | ||
250 | down(&data->update_lock); | 249 | down(&data->update_lock); |
251 | data->in_min[nr] = IN_TO_REG(val, nr); | 250 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); |
252 | adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); | 251 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), |
252 | data->in_min[attr->index]); | ||
253 | up(&data->update_lock); | 253 | up(&data->update_lock); |
254 | return count; | 254 | return count; |
255 | } | 255 | } |
256 | 256 | ||
257 | static ssize_t set_in_max(struct device *dev, const char *buf, | 257 | static ssize_t set_in_max(struct device *dev, |
258 | size_t count, int nr) | 258 | struct device_attribute *devattr, |
259 | const char *buf, size_t count) | ||
259 | { | 260 | { |
261 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
260 | struct i2c_client *client = to_i2c_client(dev); | 262 | struct i2c_client *client = to_i2c_client(dev); |
261 | struct adm9240_data *data = i2c_get_clientdata(client); | 263 | struct adm9240_data *data = i2c_get_clientdata(client); |
262 | unsigned long val = simple_strtoul(buf, NULL, 10); | 264 | unsigned long val = simple_strtoul(buf, NULL, 10); |
263 | 265 | ||
264 | down(&data->update_lock); | 266 | down(&data->update_lock); |
265 | data->in_max[nr] = IN_TO_REG(val, nr); | 267 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); |
266 | adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); | 268 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), |
269 | data->in_max[attr->index]); | ||
267 | up(&data->update_lock); | 270 | up(&data->update_lock); |
268 | return count; | 271 | return count; |
269 | } | 272 | } |
270 | 273 | ||
271 | #define show_in_offset(offset) \ | 274 | #define vin(nr) \ |
272 | static ssize_t show_in##offset(struct device *dev, \ | 275 | static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \ |
273 | struct device_attribute *attr, \ | 276 | show_in, NULL, nr); \ |
274 | char *buf) \ | 277 | static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \ |
275 | { \ | 278 | show_in_min, set_in_min, nr); \ |
276 | return show_in(dev, buf, offset); \ | 279 | static SENSOR_DEVICE_ATTR(in##nr##_max, S_IRUGO | S_IWUSR, \ |
277 | } \ | 280 | show_in_max, set_in_max, nr); |
278 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ | 281 | |
279 | static ssize_t show_in##offset##_min(struct device *dev, \ | 282 | vin(0); |
280 | struct device_attribute *attr, \ | 283 | vin(1); |
281 | char *buf) \ | 284 | vin(2); |
282 | { \ | 285 | vin(3); |
283 | return show_in_min(dev, buf, offset); \ | 286 | vin(4); |
284 | } \ | 287 | vin(5); |
285 | static ssize_t show_in##offset##_max(struct device *dev, \ | ||
286 | struct device_attribute *attr, \ | ||
287 | char *buf) \ | ||
288 | { \ | ||
289 | return show_in_max(dev, buf, offset); \ | ||
290 | } \ | ||
291 | static ssize_t \ | ||
292 | set_in##offset##_min(struct device *dev, \ | ||
293 | struct device_attribute *attr, const char *buf, \ | ||
294 | size_t count) \ | ||
295 | { \ | ||
296 | return set_in_min(dev, buf, count, offset); \ | ||
297 | } \ | ||
298 | static ssize_t \ | ||
299 | set_in##offset##_max(struct device *dev, \ | ||
300 | struct device_attribute *attr, const char *buf, \ | ||
301 | size_t count) \ | ||
302 | { \ | ||
303 | return set_in_max(dev, buf, count, offset); \ | ||
304 | } \ | ||
305 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
306 | show_in##offset##_min, set_in##offset##_min); \ | ||
307 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
308 | show_in##offset##_max, set_in##offset##_max); | ||
309 | |||
310 | show_in_offset(0); | ||
311 | show_in_offset(1); | ||
312 | show_in_offset(2); | ||
313 | show_in_offset(3); | ||
314 | show_in_offset(4); | ||
315 | show_in_offset(5); | ||
316 | 288 | ||
317 | /* fans */ | 289 | /* fans */ |
318 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 290 | static ssize_t show_fan(struct device *dev, |
291 | struct device_attribute *devattr, char *buf) | ||
319 | { | 292 | { |
293 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
320 | struct adm9240_data *data = adm9240_update_device(dev); | 294 | struct adm9240_data *data = adm9240_update_device(dev); |
321 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | 295 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], |
322 | 1 << data->fan_div[nr])); | 296 | 1 << data->fan_div[attr->index])); |
323 | } | 297 | } |
324 | 298 | ||
325 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 299 | static ssize_t show_fan_min(struct device *dev, |
300 | struct device_attribute *devattr, char *buf) | ||
326 | { | 301 | { |
302 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
327 | struct adm9240_data *data = adm9240_update_device(dev); | 303 | struct adm9240_data *data = adm9240_update_device(dev); |
328 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | 304 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[attr->index], |
329 | 1 << data->fan_div[nr])); | 305 | 1 << data->fan_div[attr->index])); |
330 | } | 306 | } |
331 | 307 | ||
332 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 308 | static ssize_t show_fan_div(struct device *dev, |
309 | struct device_attribute *devattr, char *buf) | ||
333 | { | 310 | { |
311 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
334 | struct adm9240_data *data = adm9240_update_device(dev); | 312 | struct adm9240_data *data = adm9240_update_device(dev); |
335 | return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); | 313 | return sprintf(buf, "%d\n", 1 << data->fan_div[attr->index]); |
336 | } | 314 | } |
337 | 315 | ||
338 | /* write new fan div, callers must hold data->update_lock */ | 316 | /* write new fan div, callers must hold data->update_lock */ |
@@ -341,16 +319,16 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, | |||
341 | { | 319 | { |
342 | u8 reg, old, shift = (nr + 2) * 2; | 320 | u8 reg, old, shift = (nr + 2) * 2; |
343 | 321 | ||
344 | reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | 322 | reg = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); |
345 | old = (reg >> shift) & 3; | 323 | old = (reg >> shift) & 3; |
346 | reg &= ~(3 << shift); | 324 | reg &= ~(3 << shift); |
347 | reg |= (fan_div << shift); | 325 | reg |= (fan_div << shift); |
348 | adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); | 326 | i2c_smbus_write_byte_data(client, ADM9240_REG_VID_FAN_DIV, reg); |
349 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " | 327 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " |
350 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); | 328 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); |
351 | } | 329 | } |
352 | 330 | ||
353 | /* | 331 | /* |
354 | * set fan speed low limit: | 332 | * set fan speed low limit: |
355 | * | 333 | * |
356 | * - value is zero: disable fan speed low limit alarm | 334 | * - value is zero: disable fan speed low limit alarm |
@@ -361,12 +339,15 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, | |||
361 | * - otherwise: select fan clock divider to suit fan speed low limit, | 339 | * - otherwise: select fan clock divider to suit fan speed low limit, |
362 | * measurement code may adjust registers to ensure fan speed reading | 340 | * measurement code may adjust registers to ensure fan speed reading |
363 | */ | 341 | */ |
364 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 342 | static ssize_t set_fan_min(struct device *dev, |
365 | size_t count, int nr) | 343 | struct device_attribute *devattr, |
344 | const char *buf, size_t count) | ||
366 | { | 345 | { |
346 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
367 | struct i2c_client *client = to_i2c_client(dev); | 347 | struct i2c_client *client = to_i2c_client(dev); |
368 | struct adm9240_data *data = i2c_get_clientdata(client); | 348 | struct adm9240_data *data = i2c_get_clientdata(client); |
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | 349 | unsigned long val = simple_strtoul(buf, NULL, 10); |
350 | int nr = attr->index; | ||
370 | u8 new_div; | 351 | u8 new_div; |
371 | 352 | ||
372 | down(&data->update_lock); | 353 | down(&data->update_lock); |
@@ -406,50 +387,27 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
406 | data->fan_div[nr] = new_div; | 387 | data->fan_div[nr] = new_div; |
407 | adm9240_write_fan_div(client, nr, new_div); | 388 | adm9240_write_fan_div(client, nr, new_div); |
408 | } | 389 | } |
409 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), | 390 | i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr), |
410 | data->fan_min[nr]); | 391 | data->fan_min[nr]); |
411 | 392 | ||
412 | up(&data->update_lock); | 393 | up(&data->update_lock); |
413 | return count; | 394 | return count; |
414 | } | 395 | } |
415 | 396 | ||
416 | #define show_fan_offset(offset) \ | 397 | #define fan(nr) \ |
417 | static ssize_t show_fan_##offset (struct device *dev, \ | 398 | static SENSOR_DEVICE_ATTR(fan##nr##_input, S_IRUGO, \ |
418 | struct device_attribute *attr, \ | 399 | show_fan, NULL, nr - 1); \ |
419 | char *buf) \ | 400 | static SENSOR_DEVICE_ATTR(fan##nr##_div, S_IRUGO, \ |
420 | { \ | 401 | show_fan_div, NULL, nr - 1); \ |
421 | return show_fan(dev, buf, offset - 1); \ | 402 | static SENSOR_DEVICE_ATTR(fan##nr##_min, S_IRUGO | S_IWUSR, \ |
422 | } \ | 403 | show_fan_min, set_fan_min, nr - 1); |
423 | static ssize_t show_fan_##offset##_div (struct device *dev, \ | 404 | |
424 | struct device_attribute *attr, \ | 405 | fan(1); |
425 | char *buf) \ | 406 | fan(2); |
426 | { \ | ||
427 | return show_fan_div(dev, buf, offset - 1); \ | ||
428 | } \ | ||
429 | static ssize_t show_fan_##offset##_min (struct device *dev, \ | ||
430 | struct device_attribute *attr, \ | ||
431 | char *buf) \ | ||
432 | { \ | ||
433 | return show_fan_min(dev, buf, offset - 1); \ | ||
434 | } \ | ||
435 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
436 | struct device_attribute *attr, \ | ||
437 | const char *buf, size_t count) \ | ||
438 | { \ | ||
439 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
440 | } \ | ||
441 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
442 | show_fan_##offset, NULL); \ | ||
443 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
444 | show_fan_##offset##_div, NULL); \ | ||
445 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
446 | show_fan_##offset##_min, set_fan_##offset##_min); | ||
447 | |||
448 | show_fan_offset(1); | ||
449 | show_fan_offset(2); | ||
450 | 407 | ||
451 | /* alarms */ | 408 | /* alarms */ |
452 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 409 | static ssize_t show_alarms(struct device *dev, |
410 | struct device_attribute *attr, char *buf) | ||
453 | { | 411 | { |
454 | struct adm9240_data *data = adm9240_update_device(dev); | 412 | struct adm9240_data *data = adm9240_update_device(dev); |
455 | return sprintf(buf, "%u\n", data->alarms); | 413 | return sprintf(buf, "%u\n", data->alarms); |
@@ -457,7 +415,8 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
457 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 415 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
458 | 416 | ||
459 | /* vid */ | 417 | /* vid */ |
460 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | 418 | static ssize_t show_vid(struct device *dev, |
419 | struct device_attribute *attr, char *buf) | ||
461 | { | 420 | { |
462 | struct adm9240_data *data = adm9240_update_device(dev); | 421 | struct adm9240_data *data = adm9240_update_device(dev); |
463 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | 422 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); |
@@ -465,13 +424,16 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char | |||
465 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | 424 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
466 | 425 | ||
467 | /* analog output */ | 426 | /* analog output */ |
468 | static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) | 427 | static ssize_t show_aout(struct device *dev, |
428 | struct device_attribute *attr, char *buf) | ||
469 | { | 429 | { |
470 | struct adm9240_data *data = adm9240_update_device(dev); | 430 | struct adm9240_data *data = adm9240_update_device(dev); |
471 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); | 431 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); |
472 | } | 432 | } |
473 | 433 | ||
474 | static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 434 | static ssize_t set_aout(struct device *dev, |
435 | struct device_attribute *attr, | ||
436 | const char *buf, size_t count) | ||
475 | { | 437 | { |
476 | struct i2c_client *client = to_i2c_client(dev); | 438 | struct i2c_client *client = to_i2c_client(dev); |
477 | struct adm9240_data *data = i2c_get_clientdata(client); | 439 | struct adm9240_data *data = i2c_get_clientdata(client); |
@@ -479,20 +441,23 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const | |||
479 | 441 | ||
480 | down(&data->update_lock); | 442 | down(&data->update_lock); |
481 | data->aout = AOUT_TO_REG(val); | 443 | data->aout = AOUT_TO_REG(val); |
482 | adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); | 444 | i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout); |
483 | up(&data->update_lock); | 445 | up(&data->update_lock); |
484 | return count; | 446 | return count; |
485 | } | 447 | } |
486 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | 448 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); |
487 | 449 | ||
488 | /* chassis_clear */ | 450 | /* chassis_clear */ |
489 | static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 451 | static ssize_t chassis_clear(struct device *dev, |
452 | struct device_attribute *attr, | ||
453 | const char *buf, size_t count) | ||
490 | { | 454 | { |
491 | struct i2c_client *client = to_i2c_client(dev); | 455 | struct i2c_client *client = to_i2c_client(dev); |
492 | unsigned long val = simple_strtol(buf, NULL, 10); | 456 | unsigned long val = simple_strtol(buf, NULL, 10); |
493 | 457 | ||
494 | if (val == 1) { | 458 | if (val == 1) { |
495 | adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); | 459 | i2c_smbus_write_byte_data(client, |
460 | ADM9240_REG_CHASSIS_CLEAR, 0x80); | ||
496 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); | 461 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); |
497 | } | 462 | } |
498 | return count; | 463 | return count; |
@@ -513,11 +478,10 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
513 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 478 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
514 | goto exit; | 479 | goto exit; |
515 | 480 | ||
516 | if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { | 481 | if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) { |
517 | err = -ENOMEM; | 482 | err = -ENOMEM; |
518 | goto exit; | 483 | goto exit; |
519 | } | 484 | } |
520 | memset(data, 0, sizeof(struct adm9240_data)); | ||
521 | 485 | ||
522 | new_client = &data->client; | 486 | new_client = &data->client; |
523 | i2c_set_clientdata(new_client, data); | 487 | i2c_set_clientdata(new_client, data); |
@@ -533,7 +497,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
533 | if (kind < 0) { | 497 | if (kind < 0) { |
534 | 498 | ||
535 | /* verify chip: reg address should match i2c address */ | 499 | /* verify chip: reg address should match i2c address */ |
536 | if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) | 500 | if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR) |
537 | != address) { | 501 | != address) { |
538 | dev_err(&adapter->dev, "detect fail: address match, " | 502 | dev_err(&adapter->dev, "detect fail: address match, " |
539 | "0x%02x\n", address); | 503 | "0x%02x\n", address); |
@@ -541,8 +505,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
541 | } | 505 | } |
542 | 506 | ||
543 | /* check known chip manufacturer */ | 507 | /* check known chip manufacturer */ |
544 | man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); | 508 | man_id = i2c_smbus_read_byte_data(new_client, |
545 | 509 | ADM9240_REG_MAN_ID); | |
546 | if (man_id == 0x23) { | 510 | if (man_id == 0x23) { |
547 | kind = adm9240; | 511 | kind = adm9240; |
548 | } else if (man_id == 0xda) { | 512 | } else if (man_id == 0xda) { |
@@ -556,7 +520,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
556 | } | 520 | } |
557 | 521 | ||
558 | /* successful detect, print chip info */ | 522 | /* successful detect, print chip info */ |
559 | die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); | 523 | die_rev = i2c_smbus_read_byte_data(new_client, |
524 | ADM9240_REG_DIE_REV); | ||
560 | dev_info(&adapter->dev, "found %s revision %u\n", | 525 | dev_info(&adapter->dev, "found %s revision %u\n", |
561 | man_id == 0x23 ? "ADM9240" : | 526 | man_id == 0x23 ? "ADM9240" : |
562 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | 527 | man_id == 0xda ? "DS1780" : "LM81", die_rev); |
@@ -588,33 +553,59 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
588 | goto exit_detach; | 553 | goto exit_detach; |
589 | } | 554 | } |
590 | 555 | ||
591 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 556 | device_create_file(&new_client->dev, |
592 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 557 | &sensor_dev_attr_in0_input.dev_attr); |
593 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 558 | device_create_file(&new_client->dev, |
594 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 559 | &sensor_dev_attr_in0_min.dev_attr); |
595 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 560 | device_create_file(&new_client->dev, |
596 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 561 | &sensor_dev_attr_in0_max.dev_attr); |
597 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 562 | device_create_file(&new_client->dev, |
598 | device_create_file(&new_client->dev, &dev_attr_in2_min); | 563 | &sensor_dev_attr_in1_input.dev_attr); |
599 | device_create_file(&new_client->dev, &dev_attr_in2_max); | 564 | device_create_file(&new_client->dev, |
600 | device_create_file(&new_client->dev, &dev_attr_in3_input); | 565 | &sensor_dev_attr_in1_min.dev_attr); |
601 | device_create_file(&new_client->dev, &dev_attr_in3_min); | 566 | device_create_file(&new_client->dev, |
602 | device_create_file(&new_client->dev, &dev_attr_in3_max); | 567 | &sensor_dev_attr_in1_max.dev_attr); |
603 | device_create_file(&new_client->dev, &dev_attr_in4_input); | 568 | device_create_file(&new_client->dev, |
604 | device_create_file(&new_client->dev, &dev_attr_in4_min); | 569 | &sensor_dev_attr_in2_input.dev_attr); |
605 | device_create_file(&new_client->dev, &dev_attr_in4_max); | 570 | device_create_file(&new_client->dev, |
606 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 571 | &sensor_dev_attr_in2_min.dev_attr); |
607 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 572 | device_create_file(&new_client->dev, |
608 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 573 | &sensor_dev_attr_in2_max.dev_attr); |
609 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 574 | device_create_file(&new_client->dev, |
610 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | 575 | &sensor_dev_attr_in3_input.dev_attr); |
576 | device_create_file(&new_client->dev, | ||
577 | &sensor_dev_attr_in3_min.dev_attr); | ||
578 | device_create_file(&new_client->dev, | ||
579 | &sensor_dev_attr_in3_max.dev_attr); | ||
580 | device_create_file(&new_client->dev, | ||
581 | &sensor_dev_attr_in4_input.dev_attr); | ||
582 | device_create_file(&new_client->dev, | ||
583 | &sensor_dev_attr_in4_min.dev_attr); | ||
584 | device_create_file(&new_client->dev, | ||
585 | &sensor_dev_attr_in4_max.dev_attr); | ||
586 | device_create_file(&new_client->dev, | ||
587 | &sensor_dev_attr_in5_input.dev_attr); | ||
588 | device_create_file(&new_client->dev, | ||
589 | &sensor_dev_attr_in5_min.dev_attr); | ||
590 | device_create_file(&new_client->dev, | ||
591 | &sensor_dev_attr_in5_max.dev_attr); | ||
611 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 592 | device_create_file(&new_client->dev, &dev_attr_temp1_input); |
612 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 593 | device_create_file(&new_client->dev, |
613 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 594 | &sensor_dev_attr_temp1_max.dev_attr); |
614 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 595 | device_create_file(&new_client->dev, |
615 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 596 | &sensor_dev_attr_temp1_max_hyst.dev_attr); |
616 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 597 | device_create_file(&new_client->dev, |
617 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 598 | &sensor_dev_attr_fan1_input.dev_attr); |
599 | device_create_file(&new_client->dev, | ||
600 | &sensor_dev_attr_fan1_div.dev_attr); | ||
601 | device_create_file(&new_client->dev, | ||
602 | &sensor_dev_attr_fan1_min.dev_attr); | ||
603 | device_create_file(&new_client->dev, | ||
604 | &sensor_dev_attr_fan2_input.dev_attr); | ||
605 | device_create_file(&new_client->dev, | ||
606 | &sensor_dev_attr_fan2_div.dev_attr); | ||
607 | device_create_file(&new_client->dev, | ||
608 | &sensor_dev_attr_fan2_min.dev_attr); | ||
618 | device_create_file(&new_client->dev, &dev_attr_alarms); | 609 | device_create_file(&new_client->dev, &dev_attr_alarms); |
619 | device_create_file(&new_client->dev, &dev_attr_aout_output); | 610 | device_create_file(&new_client->dev, &dev_attr_aout_output); |
620 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); | 611 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); |
@@ -654,8 +645,8 @@ static int adm9240_detach_client(struct i2c_client *client) | |||
654 | static void adm9240_init_client(struct i2c_client *client) | 645 | static void adm9240_init_client(struct i2c_client *client) |
655 | { | 646 | { |
656 | struct adm9240_data *data = i2c_get_clientdata(client); | 647 | struct adm9240_data *data = i2c_get_clientdata(client); |
657 | u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); | 648 | u8 conf = i2c_smbus_read_byte_data(client, ADM9240_REG_CONFIG); |
658 | u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; | 649 | u8 mode = i2c_smbus_read_byte_data(client, ADM9240_REG_TEMP_CONF) & 3; |
659 | 650 | ||
660 | data->vrm = vid_which_vrm(); /* need this to report vid as mV */ | 651 | data->vrm = vid_which_vrm(); /* need this to report vid as mV */ |
661 | 652 | ||
@@ -672,18 +663,22 @@ static void adm9240_init_client(struct i2c_client *client) | |||
672 | 663 | ||
673 | for (i = 0; i < 6; i++) | 664 | for (i = 0; i < 6; i++) |
674 | { | 665 | { |
675 | adm9240_write_value(client, | 666 | i2c_smbus_write_byte_data(client, |
676 | ADM9240_REG_IN_MIN(i), 0); | 667 | ADM9240_REG_IN_MIN(i), 0); |
677 | adm9240_write_value(client, | 668 | i2c_smbus_write_byte_data(client, |
678 | ADM9240_REG_IN_MAX(i), 255); | 669 | ADM9240_REG_IN_MAX(i), 255); |
679 | } | 670 | } |
680 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); | 671 | i2c_smbus_write_byte_data(client, |
681 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); | 672 | ADM9240_REG_FAN_MIN(0), 255); |
682 | adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); | 673 | i2c_smbus_write_byte_data(client, |
683 | adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); | 674 | ADM9240_REG_FAN_MIN(1), 255); |
675 | i2c_smbus_write_byte_data(client, | ||
676 | ADM9240_REG_TEMP_MAX(0), 127); | ||
677 | i2c_smbus_write_byte_data(client, | ||
678 | ADM9240_REG_TEMP_MAX(1), 127); | ||
684 | 679 | ||
685 | /* start measurement cycle */ | 680 | /* start measurement cycle */ |
686 | adm9240_write_value(client, ADM9240_REG_CONFIG, 1); | 681 | i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1); |
687 | 682 | ||
688 | dev_info(&client->dev, "cold start: config was 0x%02x " | 683 | dev_info(&client->dev, "cold start: config was 0x%02x " |
689 | "mode %u\n", conf, mode); | 684 | "mode %u\n", conf, mode); |
@@ -704,25 +699,25 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
704 | 699 | ||
705 | for (i = 0; i < 6; i++) /* read voltages */ | 700 | for (i = 0; i < 6; i++) /* read voltages */ |
706 | { | 701 | { |
707 | data->in[i] = adm9240_read_value(client, | 702 | data->in[i] = i2c_smbus_read_byte_data(client, |
708 | ADM9240_REG_IN(i)); | 703 | ADM9240_REG_IN(i)); |
709 | } | 704 | } |
710 | data->alarms = adm9240_read_value(client, | 705 | data->alarms = i2c_smbus_read_byte_data(client, |
711 | ADM9240_REG_INT(0)) | | 706 | ADM9240_REG_INT(0)) | |
712 | adm9240_read_value(client, | 707 | i2c_smbus_read_byte_data(client, |
713 | ADM9240_REG_INT(1)) << 8; | 708 | ADM9240_REG_INT(1)) << 8; |
714 | 709 | ||
715 | /* read temperature: assume temperature changes less than | 710 | /* read temperature: assume temperature changes less than |
716 | * 0.5'C per two measurement cycles thus ignore possible | 711 | * 0.5'C per two measurement cycles thus ignore possible |
717 | * but unlikely aliasing error on lsb reading. --Grant */ | 712 | * but unlikely aliasing error on lsb reading. --Grant */ |
718 | data->temp = ((adm9240_read_value(client, | 713 | data->temp = ((i2c_smbus_read_byte_data(client, |
719 | ADM9240_REG_TEMP) << 8) | | 714 | ADM9240_REG_TEMP) << 8) | |
720 | adm9240_read_value(client, | 715 | i2c_smbus_read_byte_data(client, |
721 | ADM9240_REG_TEMP_CONF)) / 128; | 716 | ADM9240_REG_TEMP_CONF)) / 128; |
722 | 717 | ||
723 | for (i = 0; i < 2; i++) /* read fans */ | 718 | for (i = 0; i < 2; i++) /* read fans */ |
724 | { | 719 | { |
725 | data->fan[i] = adm9240_read_value(client, | 720 | data->fan[i] = i2c_smbus_read_byte_data(client, |
726 | ADM9240_REG_FAN(i)); | 721 | ADM9240_REG_FAN(i)); |
727 | 722 | ||
728 | /* adjust fan clock divider on overflow */ | 723 | /* adjust fan clock divider on overflow */ |
@@ -747,30 +742,30 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
747 | 742 | ||
748 | for (i = 0; i < 6; i++) | 743 | for (i = 0; i < 6; i++) |
749 | { | 744 | { |
750 | data->in_min[i] = adm9240_read_value(client, | 745 | data->in_min[i] = i2c_smbus_read_byte_data(client, |
751 | ADM9240_REG_IN_MIN(i)); | 746 | ADM9240_REG_IN_MIN(i)); |
752 | data->in_max[i] = adm9240_read_value(client, | 747 | data->in_max[i] = i2c_smbus_read_byte_data(client, |
753 | ADM9240_REG_IN_MAX(i)); | 748 | ADM9240_REG_IN_MAX(i)); |
754 | } | 749 | } |
755 | for (i = 0; i < 2; i++) | 750 | for (i = 0; i < 2; i++) |
756 | { | 751 | { |
757 | data->fan_min[i] = adm9240_read_value(client, | 752 | data->fan_min[i] = i2c_smbus_read_byte_data(client, |
758 | ADM9240_REG_FAN_MIN(i)); | 753 | ADM9240_REG_FAN_MIN(i)); |
759 | } | 754 | } |
760 | data->temp_high = adm9240_read_value(client, | 755 | data->temp_max[0] = i2c_smbus_read_byte_data(client, |
761 | ADM9240_REG_TEMP_HIGH); | 756 | ADM9240_REG_TEMP_MAX(0)); |
762 | data->temp_hyst = adm9240_read_value(client, | 757 | data->temp_max[1] = i2c_smbus_read_byte_data(client, |
763 | ADM9240_REG_TEMP_HYST); | 758 | ADM9240_REG_TEMP_MAX(1)); |
764 | 759 | ||
765 | /* read fan divs and 5-bit VID */ | 760 | /* read fan divs and 5-bit VID */ |
766 | i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | 761 | i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); |
767 | data->fan_div[0] = (i >> 4) & 3; | 762 | data->fan_div[0] = (i >> 4) & 3; |
768 | data->fan_div[1] = (i >> 6) & 3; | 763 | data->fan_div[1] = (i >> 6) & 3; |
769 | data->vid = i & 0x0f; | 764 | data->vid = i & 0x0f; |
770 | data->vid |= (adm9240_read_value(client, | 765 | data->vid |= (i2c_smbus_read_byte_data(client, |
771 | ADM9240_REG_VID4) & 1) << 4; | 766 | ADM9240_REG_VID4) & 1) << 4; |
772 | /* read analog out */ | 767 | /* read analog out */ |
773 | data->aout = adm9240_read_value(client, | 768 | data->aout = i2c_smbus_read_byte_data(client, |
774 | ADM9240_REG_ANALOG_OUT); | 769 | ADM9240_REG_ANALOG_OUT); |
775 | 770 | ||
776 | data->last_updated_config = jiffies; | 771 | data->last_updated_config = jiffies; |
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 8e34855a6274..52c469722a65 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -629,19 +629,17 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, | |||
629 | int i, id, err; | 629 | int i, id, err; |
630 | struct asb100_data *data = i2c_get_clientdata(new_client); | 630 | struct asb100_data *data = i2c_get_clientdata(new_client); |
631 | 631 | ||
632 | data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 632 | data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
633 | if (!(data->lm75[0])) { | 633 | if (!(data->lm75[0])) { |
634 | err = -ENOMEM; | 634 | err = -ENOMEM; |
635 | goto ERROR_SC_0; | 635 | goto ERROR_SC_0; |
636 | } | 636 | } |
637 | memset(data->lm75[0], 0x00, sizeof(struct i2c_client)); | ||
638 | 637 | ||
639 | data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 638 | data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
640 | if (!(data->lm75[1])) { | 639 | if (!(data->lm75[1])) { |
641 | err = -ENOMEM; | 640 | err = -ENOMEM; |
642 | goto ERROR_SC_1; | 641 | goto ERROR_SC_1; |
643 | } | 642 | } |
644 | memset(data->lm75[1], 0x00, sizeof(struct i2c_client)); | ||
645 | 643 | ||
646 | id = i2c_adapter_id(adapter); | 644 | id = i2c_adapter_id(adapter); |
647 | 645 | ||
@@ -724,12 +722,11 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
724 | client structure, even though we cannot fill it completely yet. | 722 | client structure, even though we cannot fill it completely yet. |
725 | But it allows us to access asb100_{read,write}_value. */ | 723 | But it allows us to access asb100_{read,write}_value. */ |
726 | 724 | ||
727 | if (!(data = kmalloc(sizeof(struct asb100_data), GFP_KERNEL))) { | 725 | if (!(data = kzalloc(sizeof(struct asb100_data), GFP_KERNEL))) { |
728 | pr_debug("asb100.o: detect failed, kmalloc failed!\n"); | 726 | pr_debug("asb100.o: detect failed, kzalloc failed!\n"); |
729 | err = -ENOMEM; | 727 | err = -ENOMEM; |
730 | goto ERROR0; | 728 | goto ERROR0; |
731 | } | 729 | } |
732 | memset(data, 0, sizeof(struct asb100_data)); | ||
733 | 730 | ||
734 | new_client = &data->client; | 731 | new_client = &data->client; |
735 | init_MUTEX(&data->lock); | 732 | init_MUTEX(&data->lock); |
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index deb4d34c9539..53324f56404e 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -253,6 +253,8 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); | |||
253 | 253 | ||
254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) | 254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) |
255 | { | 255 | { |
256 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
257 | return 0; | ||
256 | return i2c_probe(adapter, &addr_data, &atxp1_detect); | 258 | return i2c_probe(adapter, &addr_data, &atxp1_detect); |
257 | }; | 259 | }; |
258 | 260 | ||
@@ -266,12 +268,11 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
266 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 268 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
267 | goto exit; | 269 | goto exit; |
268 | 270 | ||
269 | if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { | 271 | if (!(data = kzalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { |
270 | err = -ENOMEM; | 272 | err = -ENOMEM; |
271 | goto exit; | 273 | goto exit; |
272 | } | 274 | } |
273 | 275 | ||
274 | memset(data, 0, sizeof(struct atxp1_data)); | ||
275 | new_client = &data->client; | 276 | new_client = &data->client; |
276 | i2c_set_clientdata(new_client, data); | 277 | i2c_set_clientdata(new_client, data); |
277 | 278 | ||
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index b0199e063d0e..34f71b7c7f37 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c | |||
@@ -180,12 +180,14 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max); | |||
180 | 180 | ||
181 | static int ds1621_attach_adapter(struct i2c_adapter *adapter) | 181 | static int ds1621_attach_adapter(struct i2c_adapter *adapter) |
182 | { | 182 | { |
183 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
184 | return 0; | ||
183 | return i2c_probe(adapter, &addr_data, ds1621_detect); | 185 | return i2c_probe(adapter, &addr_data, ds1621_detect); |
184 | } | 186 | } |
185 | 187 | ||
186 | /* This function is called by i2c_probe */ | 188 | /* This function is called by i2c_probe */ |
187 | int ds1621_detect(struct i2c_adapter *adapter, int address, | 189 | static int ds1621_detect(struct i2c_adapter *adapter, int address, |
188 | int kind) | 190 | int kind) |
189 | { | 191 | { |
190 | int conf, temp; | 192 | int conf, temp; |
191 | struct i2c_client *new_client; | 193 | struct i2c_client *new_client; |
@@ -200,11 +202,10 @@ int ds1621_detect(struct i2c_adapter *adapter, int address, | |||
200 | /* OK. For now, we presume we have a valid client. We now create the | 202 | /* OK. For now, we presume we have a valid client. We now create the |
201 | client structure, even though we cannot fill it completely yet. | 203 | client structure, even though we cannot fill it completely yet. |
202 | But it allows us to access ds1621_{read,write}_value. */ | 204 | But it allows us to access ds1621_{read,write}_value. */ |
203 | if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { | 205 | if (!(data = kzalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { |
204 | err = -ENOMEM; | 206 | err = -ENOMEM; |
205 | goto exit; | 207 | goto exit; |
206 | } | 208 | } |
207 | memset(data, 0, sizeof(struct ds1621_data)); | ||
208 | 209 | ||
209 | new_client = &data->client; | 210 | new_client = &data->client; |
210 | i2c_set_clientdata(new_client, data); | 211 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index eef6061d786b..a02e1c34c757 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c | |||
@@ -303,11 +303,10 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) | |||
303 | /* OK. For now, we presume we have a valid client. We now create the | 303 | /* OK. For now, we presume we have a valid client. We now create the |
304 | * client structure, even though we cannot fill it completely yet. | 304 | * client structure, even though we cannot fill it completely yet. |
305 | * But it allows us to access i2c_smbus_read_byte_data. */ | 305 | * But it allows us to access i2c_smbus_read_byte_data. */ |
306 | if (!(data = kmalloc(sizeof(struct fscher_data), GFP_KERNEL))) { | 306 | if (!(data = kzalloc(sizeof(struct fscher_data), GFP_KERNEL))) { |
307 | err = -ENOMEM; | 307 | err = -ENOMEM; |
308 | goto exit; | 308 | goto exit; |
309 | } | 309 | } |
310 | memset(data, 0, sizeof(struct fscher_data)); | ||
311 | 310 | ||
312 | /* The common I2C client data is placed right before the | 311 | /* The common I2C client data is placed right before the |
313 | * Hermes-specific data. */ | 312 | * Hermes-specific data. */ |
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 5fc77a5fed07..64e4edc64f8d 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c | |||
@@ -438,7 +438,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter) | |||
438 | return i2c_probe(adapter, &addr_data, fscpos_detect); | 438 | return i2c_probe(adapter, &addr_data, fscpos_detect); |
439 | } | 439 | } |
440 | 440 | ||
441 | int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | 441 | static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) |
442 | { | 442 | { |
443 | struct i2c_client *new_client; | 443 | struct i2c_client *new_client; |
444 | struct fscpos_data *data; | 444 | struct fscpos_data *data; |
@@ -453,11 +453,10 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | |||
453 | * But it allows us to access fscpos_{read,write}_value. | 453 | * But it allows us to access fscpos_{read,write}_value. |
454 | */ | 454 | */ |
455 | 455 | ||
456 | if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { | 456 | if (!(data = kzalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { |
457 | err = -ENOMEM; | 457 | err = -ENOMEM; |
458 | goto exit; | 458 | goto exit; |
459 | } | 459 | } |
460 | memset(data, 0, sizeof(struct fscpos_data)); | ||
461 | 460 | ||
462 | new_client = &data->client; | 461 | new_client = &data->client; |
463 | i2c_set_clientdata(new_client, data); | 462 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 256b9323c84b..2f178dbe3d87 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -365,11 +365,10 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
365 | client structure, even though we cannot fill it completely yet. | 365 | client structure, even though we cannot fill it completely yet. |
366 | But it allows us to access gl518_{read,write}_value. */ | 366 | But it allows us to access gl518_{read,write}_value. */ |
367 | 367 | ||
368 | if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) { | 368 | if (!(data = kzalloc(sizeof(struct gl518_data), GFP_KERNEL))) { |
369 | err = -ENOMEM; | 369 | err = -ENOMEM; |
370 | goto exit; | 370 | goto exit; |
371 | } | 371 | } |
372 | memset(data, 0, sizeof(struct gl518_data)); | ||
373 | 372 | ||
374 | new_client = &data->client; | 373 | new_client = &data->client; |
375 | i2c_set_clientdata(new_client, data); | 374 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 12fd757066fc..c39ba1239426 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -536,11 +536,10 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
536 | client structure, even though we cannot fill it completely yet. | 536 | client structure, even though we cannot fill it completely yet. |
537 | But it allows us to access gl520_{read,write}_value. */ | 537 | But it allows us to access gl520_{read,write}_value. */ |
538 | 538 | ||
539 | if (!(data = kmalloc(sizeof(struct gl520_data), GFP_KERNEL))) { | 539 | if (!(data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL))) { |
540 | err = -ENOMEM; | 540 | err = -ENOMEM; |
541 | goto exit; | 541 | goto exit; |
542 | } | 542 | } |
543 | memset(data, 0, sizeof(struct gl520_data)); | ||
544 | 543 | ||
545 | new_client = &data->client; | 544 | new_client = &data->client; |
546 | i2c_set_clientdata(new_client, data); | 545 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 7f0107613827..0015da5668a1 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -296,11 +296,9 @@ static int hdaps_probe(struct device *dev) | |||
296 | return 0; | 296 | return 0; |
297 | } | 297 | } |
298 | 298 | ||
299 | static int hdaps_resume(struct device *dev, u32 level) | 299 | static int hdaps_resume(struct device *dev) |
300 | { | 300 | { |
301 | if (level == RESUME_ENABLE) | 301 | return hdaps_device_init(); |
302 | return hdaps_device_init(); | ||
303 | return 0; | ||
304 | } | 302 | } |
305 | 303 | ||
306 | static struct device_driver hdaps_driver = { | 304 | static struct device_driver hdaps_driver = { |
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 9b41c9bd805f..6f48579799b5 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c | |||
@@ -45,7 +45,7 @@ struct class_device *hwmon_device_register(struct device *dev) | |||
45 | return ERR_PTR(-ENOMEM); | 45 | return ERR_PTR(-ENOMEM); |
46 | 46 | ||
47 | id = id & MAX_ID_MASK; | 47 | id = id & MAX_ID_MASK; |
48 | cdev = class_device_create(hwmon_class, MKDEV(0,0), dev, | 48 | cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, |
49 | HWMON_ID_FORMAT, id); | 49 | HWMON_ID_FORMAT, id); |
50 | 50 | ||
51 | if (IS_ERR(cdev)) | 51 | if (IS_ERR(cdev)) |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 53cc2b6d6385..6c41e25e670b 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -2,7 +2,7 @@ | |||
2 | it87.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | it87.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring. | 3 | monitoring. |
4 | 4 | ||
5 | Supports: IT8705F Super I/O chip w/LPC interface & SMBus | 5 | Supports: IT8705F Super I/O chip w/LPC interface |
6 | IT8712F Super I/O chip w/LPC interface & SMBus | 6 | IT8712F Super I/O chip w/LPC interface & SMBus |
7 | Sis950 A clone of the IT8705F | 7 | Sis950 A clone of the IT8705F |
8 | 8 | ||
@@ -47,7 +47,7 @@ | |||
47 | /* Addresses to scan */ | 47 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, | 48 | static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, |
49 | 0x2e, 0x2f, I2C_CLIENT_END }; | 49 | 0x2e, 0x2f, I2C_CLIENT_END }; |
50 | static unsigned short isa_address = 0x290; | 50 | static unsigned short isa_address; |
51 | 51 | ||
52 | /* Insmod parameters */ | 52 | /* Insmod parameters */ |
53 | I2C_CLIENT_INSMOD_2(it87, it8712); | 53 | I2C_CLIENT_INSMOD_2(it87, it8712); |
@@ -706,7 +706,7 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter) | |||
706 | } | 706 | } |
707 | 707 | ||
708 | /* SuperIO detection - will change isa_address if a chip is found */ | 708 | /* SuperIO detection - will change isa_address if a chip is found */ |
709 | static int __init it87_find(int *address) | 709 | static int __init it87_find(unsigned short *address) |
710 | { | 710 | { |
711 | int err = -ENODEV; | 711 | int err = -ENODEV; |
712 | 712 | ||
@@ -738,7 +738,7 @@ exit: | |||
738 | } | 738 | } |
739 | 739 | ||
740 | /* This function is called by i2c_probe */ | 740 | /* This function is called by i2c_probe */ |
741 | int it87_detect(struct i2c_adapter *adapter, int address, int kind) | 741 | static int it87_detect(struct i2c_adapter *adapter, int address, int kind) |
742 | { | 742 | { |
743 | int i; | 743 | int i; |
744 | struct i2c_client *new_client; | 744 | struct i2c_client *new_client; |
@@ -757,42 +757,14 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
757 | if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) | 757 | if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) |
758 | goto ERROR0; | 758 | goto ERROR0; |
759 | 759 | ||
760 | /* Probe whether there is anything available on this address. Already | 760 | /* For now, we presume we have a valid client. We create the |
761 | done for SMBus and Super-I/O clients */ | ||
762 | if (kind < 0) { | ||
763 | if (is_isa && !chip_type) { | ||
764 | #define REALLY_SLOW_IO | ||
765 | /* We need the timeouts for at least some IT87-like chips. But only | ||
766 | if we read 'undefined' registers. */ | ||
767 | i = inb_p(address + 1); | ||
768 | if (inb_p(address + 2) != i | ||
769 | || inb_p(address + 3) != i | ||
770 | || inb_p(address + 7) != i) { | ||
771 | err = -ENODEV; | ||
772 | goto ERROR1; | ||
773 | } | ||
774 | #undef REALLY_SLOW_IO | ||
775 | |||
776 | /* Let's just hope nothing breaks here */ | ||
777 | i = inb_p(address + 5) & 0x7f; | ||
778 | outb_p(~i & 0x7f, address + 5); | ||
779 | if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) { | ||
780 | outb_p(i, address + 5); | ||
781 | err = -ENODEV; | ||
782 | goto ERROR1; | ||
783 | } | ||
784 | } | ||
785 | } | ||
786 | |||
787 | /* OK. For now, we presume we have a valid client. We now create the | ||
788 | client structure, even though we cannot fill it completely yet. | 761 | client structure, even though we cannot fill it completely yet. |
789 | But it allows us to access it87_{read,write}_value. */ | 762 | But it allows us to access it87_{read,write}_value. */ |
790 | 763 | ||
791 | if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) { | 764 | if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { |
792 | err = -ENOMEM; | 765 | err = -ENOMEM; |
793 | goto ERROR1; | 766 | goto ERROR1; |
794 | } | 767 | } |
795 | memset(data, 0, sizeof(struct it87_data)); | ||
796 | 768 | ||
797 | new_client = &data->client; | 769 | new_client = &data->client; |
798 | if (is_isa) | 770 | if (is_isa) |
@@ -1182,20 +1154,18 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1182 | 1154 | ||
1183 | static int __init sm_it87_init(void) | 1155 | static int __init sm_it87_init(void) |
1184 | { | 1156 | { |
1185 | int addr, res; | 1157 | int res; |
1186 | |||
1187 | if (!it87_find(&addr)) { | ||
1188 | isa_address = addr; | ||
1189 | } | ||
1190 | 1158 | ||
1191 | res = i2c_add_driver(&it87_driver); | 1159 | res = i2c_add_driver(&it87_driver); |
1192 | if (res) | 1160 | if (res) |
1193 | return res; | 1161 | return res; |
1194 | 1162 | ||
1195 | res = i2c_isa_add_driver(&it87_isa_driver); | 1163 | if (!it87_find(&isa_address)) { |
1196 | if (res) { | 1164 | res = i2c_isa_add_driver(&it87_isa_driver); |
1197 | i2c_del_driver(&it87_driver); | 1165 | if (res) { |
1198 | return res; | 1166 | i2c_del_driver(&it87_driver); |
1167 | return res; | ||
1168 | } | ||
1199 | } | 1169 | } |
1200 | 1170 | ||
1201 | return 0; | 1171 | return 0; |
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index be5c7095ecbb..954ec2497249 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -375,11 +375,10 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
375 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 375 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
376 | goto exit; | 376 | goto exit; |
377 | 377 | ||
378 | if (!(data = kmalloc(sizeof(struct lm63_data), GFP_KERNEL))) { | 378 | if (!(data = kzalloc(sizeof(struct lm63_data), GFP_KERNEL))) { |
379 | err = -ENOMEM; | 379 | err = -ENOMEM; |
380 | goto exit; | 380 | goto exit; |
381 | } | 381 | } |
382 | memset(data, 0, sizeof(struct lm63_data)); | ||
383 | 382 | ||
384 | /* The common I2C client data is placed right before the | 383 | /* The common I2C client data is placed right before the |
385 | LM63-specific data. */ | 384 | LM63-specific data. */ |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 9a3ebdf583f4..d70f4c8fc1e6 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -127,11 +127,10 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
127 | /* OK. For now, we presume we have a valid client. We now create the | 127 | /* OK. For now, we presume we have a valid client. We now create the |
128 | client structure, even though we cannot fill it completely yet. | 128 | client structure, even though we cannot fill it completely yet. |
129 | But it allows us to access lm75_{read,write}_value. */ | 129 | But it allows us to access lm75_{read,write}_value. */ |
130 | if (!(data = kmalloc(sizeof(struct lm75_data), GFP_KERNEL))) { | 130 | if (!(data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL))) { |
131 | err = -ENOMEM; | 131 | err = -ENOMEM; |
132 | goto exit; | 132 | goto exit; |
133 | } | 133 | } |
134 | memset(data, 0, sizeof(struct lm75_data)); | ||
135 | 134 | ||
136 | new_client = &data->client; | 135 | new_client = &data->client; |
137 | i2c_set_clientdata(new_client, data); | 136 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 866eab96a6f6..9380fda7dcd1 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -226,11 +226,10 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
226 | /* OK. For now, we presume we have a valid client. We now create the | 226 | /* OK. For now, we presume we have a valid client. We now create the |
227 | client structure, even though we cannot fill it completely yet. | 227 | client structure, even though we cannot fill it completely yet. |
228 | But it allows us to access lm77_{read,write}_value. */ | 228 | But it allows us to access lm77_{read,write}_value. */ |
229 | if (!(data = kmalloc(sizeof(struct lm77_data), GFP_KERNEL))) { | 229 | if (!(data = kzalloc(sizeof(struct lm77_data), GFP_KERNEL))) { |
230 | err = -ENOMEM; | 230 | err = -ENOMEM; |
231 | goto exit; | 231 | goto exit; |
232 | } | 232 | } |
233 | memset(data, 0, sizeof(struct lm77_data)); | ||
234 | 233 | ||
235 | new_client = &data->client; | 234 | new_client = &data->client; |
236 | i2c_set_clientdata(new_client, data); | 235 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index f6730dc3573b..bde0cda9477e 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c | |||
@@ -480,7 +480,7 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter) | |||
480 | } | 480 | } |
481 | 481 | ||
482 | /* This function is called by i2c_probe */ | 482 | /* This function is called by i2c_probe */ |
483 | int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | 483 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) |
484 | { | 484 | { |
485 | int i, err; | 485 | int i, err; |
486 | struct i2c_client *new_client; | 486 | struct i2c_client *new_client; |
@@ -540,11 +540,10 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
540 | client structure, even though we cannot fill it completely yet. | 540 | client structure, even though we cannot fill it completely yet. |
541 | But it allows us to access lm78_{read,write}_value. */ | 541 | But it allows us to access lm78_{read,write}_value. */ |
542 | 542 | ||
543 | if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) { | 543 | if (!(data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL))) { |
544 | err = -ENOMEM; | 544 | err = -ENOMEM; |
545 | goto ERROR1; | 545 | goto ERROR1; |
546 | } | 546 | } |
547 | memset(data, 0, sizeof(struct lm78_data)); | ||
548 | 547 | ||
549 | new_client = &data->client; | 548 | new_client = &data->client; |
550 | if (is_isa) | 549 | if (is_isa) |
@@ -726,7 +725,6 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
726 | return i2c_smbus_write_byte_data(client, reg, value); | 725 | return i2c_smbus_write_byte_data(client, reg, value); |
727 | } | 726 | } |
728 | 727 | ||
729 | /* Called when we have found a new LM78. It should set limits, etc. */ | ||
730 | static void lm78_init_client(struct i2c_client *client) | 728 | static void lm78_init_client(struct i2c_client *client) |
731 | { | 729 | { |
732 | u8 config = lm78_read_value(client, LM78_REG_CONFIG); | 730 | u8 config = lm78_read_value(client, LM78_REG_CONFIG); |
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 83af8b3a0cac..c359fdea211e 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c | |||
@@ -393,7 +393,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter) | |||
393 | return i2c_probe(adapter, &addr_data, lm80_detect); | 393 | return i2c_probe(adapter, &addr_data, lm80_detect); |
394 | } | 394 | } |
395 | 395 | ||
396 | int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | 396 | static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) |
397 | { | 397 | { |
398 | int i, cur; | 398 | int i, cur; |
399 | struct i2c_client *new_client; | 399 | struct i2c_client *new_client; |
@@ -407,11 +407,10 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind) | |||
407 | /* OK. For now, we presume we have a valid client. We now create the | 407 | /* OK. For now, we presume we have a valid client. We now create the |
408 | client structure, even though we cannot fill it completely yet. | 408 | client structure, even though we cannot fill it completely yet. |
409 | But it allows us to access lm80_{read,write}_value. */ | 409 | But it allows us to access lm80_{read,write}_value. */ |
410 | if (!(data = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) { | 410 | if (!(data = kzalloc(sizeof(struct lm80_data), GFP_KERNEL))) { |
411 | err = -ENOMEM; | 411 | err = -ENOMEM; |
412 | goto exit; | 412 | goto exit; |
413 | } | 413 | } |
414 | memset(data, 0, sizeof(struct lm80_data)); | ||
415 | 414 | ||
416 | new_client = &data->client; | 415 | new_client = &data->client; |
417 | i2c_set_clientdata(new_client, data); | 416 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index d74b2c20c719..9a70611a9f69 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -230,11 +230,10 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
230 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 230 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
231 | goto exit; | 231 | goto exit; |
232 | 232 | ||
233 | if (!(data = kmalloc(sizeof(struct lm83_data), GFP_KERNEL))) { | 233 | if (!(data = kzalloc(sizeof(struct lm83_data), GFP_KERNEL))) { |
234 | err = -ENOMEM; | 234 | err = -ENOMEM; |
235 | goto exit; | 235 | goto exit; |
236 | } | 236 | } |
237 | memset(data, 0, sizeof(struct lm83_data)); | ||
238 | 237 | ||
239 | /* The common I2C client data is placed right after the | 238 | /* The common I2C client data is placed right after the |
240 | * LM83-specific data. */ | 239 | * LM83-specific data. */ |
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index ab214df9624b..d1070ed2bee6 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -1007,14 +1007,14 @@ temp_auto(1); | |||
1007 | temp_auto(2); | 1007 | temp_auto(2); |
1008 | temp_auto(3); | 1008 | temp_auto(3); |
1009 | 1009 | ||
1010 | int lm85_attach_adapter(struct i2c_adapter *adapter) | 1010 | static int lm85_attach_adapter(struct i2c_adapter *adapter) |
1011 | { | 1011 | { |
1012 | if (!(adapter->class & I2C_CLASS_HWMON)) | 1012 | if (!(adapter->class & I2C_CLASS_HWMON)) |
1013 | return 0; | 1013 | return 0; |
1014 | return i2c_probe(adapter, &addr_data, lm85_detect); | 1014 | return i2c_probe(adapter, &addr_data, lm85_detect); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | int lm85_detect(struct i2c_adapter *adapter, int address, | 1017 | static int lm85_detect(struct i2c_adapter *adapter, int address, |
1018 | int kind) | 1018 | int kind) |
1019 | { | 1019 | { |
1020 | int company, verstep ; | 1020 | int company, verstep ; |
@@ -1033,11 +1033,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1033 | client structure, even though we cannot fill it completely yet. | 1033 | client structure, even though we cannot fill it completely yet. |
1034 | But it allows us to access lm85_{read,write}_value. */ | 1034 | But it allows us to access lm85_{read,write}_value. */ |
1035 | 1035 | ||
1036 | if (!(data = kmalloc(sizeof(struct lm85_data), GFP_KERNEL))) { | 1036 | if (!(data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL))) { |
1037 | err = -ENOMEM; | 1037 | err = -ENOMEM; |
1038 | goto ERROR0; | 1038 | goto ERROR0; |
1039 | } | 1039 | } |
1040 | memset(data, 0, sizeof(struct lm85_data)); | ||
1041 | 1040 | ||
1042 | new_client = &data->client; | 1041 | new_client = &data->client; |
1043 | i2c_set_clientdata(new_client, data); | 1042 | i2c_set_clientdata(new_client, data); |
@@ -1236,7 +1235,7 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1236 | return err; | 1235 | return err; |
1237 | } | 1236 | } |
1238 | 1237 | ||
1239 | int lm85_detach_client(struct i2c_client *client) | 1238 | static int lm85_detach_client(struct i2c_client *client) |
1240 | { | 1239 | { |
1241 | struct lm85_data *data = i2c_get_clientdata(client); | 1240 | struct lm85_data *data = i2c_get_clientdata(client); |
1242 | hwmon_device_unregister(data->class_dev); | 1241 | hwmon_device_unregister(data->class_dev); |
@@ -1246,7 +1245,7 @@ int lm85_detach_client(struct i2c_client *client) | |||
1246 | } | 1245 | } |
1247 | 1246 | ||
1248 | 1247 | ||
1249 | int lm85_read_value(struct i2c_client *client, u8 reg) | 1248 | static int lm85_read_value(struct i2c_client *client, u8 reg) |
1250 | { | 1249 | { |
1251 | int res; | 1250 | int res; |
1252 | 1251 | ||
@@ -1276,7 +1275,7 @@ int lm85_read_value(struct i2c_client *client, u8 reg) | |||
1276 | return res ; | 1275 | return res ; |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | int lm85_write_value(struct i2c_client *client, u8 reg, int value) | 1278 | static int lm85_write_value(struct i2c_client *client, u8 reg, int value) |
1280 | { | 1279 | { |
1281 | int res ; | 1280 | int res ; |
1282 | 1281 | ||
@@ -1305,7 +1304,7 @@ int lm85_write_value(struct i2c_client *client, u8 reg, int value) | |||
1305 | return res ; | 1304 | return res ; |
1306 | } | 1305 | } |
1307 | 1306 | ||
1308 | void lm85_init_client(struct i2c_client *client) | 1307 | static void lm85_init_client(struct i2c_client *client) |
1309 | { | 1308 | { |
1310 | int value; | 1309 | int value; |
1311 | struct lm85_data *data = i2c_get_clientdata(client); | 1310 | struct lm85_data *data = i2c_get_clientdata(client); |
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index dca996de4c33..eeec18177861 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -554,11 +554,10 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
554 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 554 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
555 | goto exit; | 555 | goto exit; |
556 | 556 | ||
557 | if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) { | 557 | if (!(data = kzalloc(sizeof(struct lm87_data), GFP_KERNEL))) { |
558 | err = -ENOMEM; | 558 | err = -ENOMEM; |
559 | goto exit; | 559 | goto exit; |
560 | } | 560 | } |
561 | memset(data, 0, sizeof(struct lm87_data)); | ||
562 | 561 | ||
563 | /* The common I2C client data is placed right before the | 562 | /* The common I2C client data is placed right before the |
564 | LM87-specific data. */ | 563 | LM87-specific data. */ |
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 14de05fcd431..83cf2e1b09f5 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -31,7 +31,7 @@ | |||
31 | * Devices. That chip is similar to the LM90, with a few differences | 31 | * Devices. That chip is similar to the LM90, with a few differences |
32 | * that are not handled by this driver. Complete datasheet can be | 32 | * that are not handled by this driver. Complete datasheet can be |
33 | * obtained from Analog's website at: | 33 | * obtained from Analog's website at: |
34 | * http://products.analog.com/products/info.asp?product=ADM1032 | 34 | * http://www.analog.com/en/prod/0,2877,ADM1032,00.html |
35 | * Among others, it has a higher accuracy than the LM90, much like the | 35 | * Among others, it has a higher accuracy than the LM90, much like the |
36 | * LM86 does. | 36 | * LM86 does. |
37 | * | 37 | * |
@@ -49,7 +49,7 @@ | |||
49 | * register values are decoded differently) it is ignored by this | 49 | * register values are decoded differently) it is ignored by this |
50 | * driver. Complete datasheet can be obtained from Analog's website | 50 | * driver. Complete datasheet can be obtained from Analog's website |
51 | * at: | 51 | * at: |
52 | * http://products.analog.com/products/info.asp?product=ADT7461 | 52 | * http://www.analog.com/en/prod/0,2877,ADT7461,00.html |
53 | * | 53 | * |
54 | * Since the LM90 was the first chipset supported by this driver, most | 54 | * Since the LM90 was the first chipset supported by this driver, most |
55 | * comments will refer to this chipset, but are actually general and | 55 | * comments will refer to this chipset, but are actually general and |
@@ -83,10 +83,10 @@ | |||
83 | * Addresses to scan | 83 | * Addresses to scan |
84 | * Address is fully defined internally and cannot be changed except for | 84 | * Address is fully defined internally and cannot be changed except for |
85 | * MAX6659. | 85 | * MAX6659. |
86 | * LM86, LM89, LM90, LM99, ADM1032, MAX6657 and MAX6658 have address 0x4c. | 86 | * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6657 and MAX6658 |
87 | * LM89-1, and LM99-1 have address 0x4d. | 87 | * have address 0x4c. |
88 | * ADM1032-2, ADT7461-2, LM89-1, and LM99-1 have address 0x4d. | ||
88 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). | 89 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). |
89 | * ADT7461 always has address 0x4c. | ||
90 | */ | 90 | */ |
91 | 91 | ||
92 | static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; | 92 | static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; |
@@ -345,10 +345,74 @@ static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, | |||
345 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); | 345 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); |
346 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 346 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
347 | 347 | ||
348 | /* pec used for ADM1032 only */ | ||
349 | static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, | ||
350 | char *buf) | ||
351 | { | ||
352 | struct i2c_client *client = to_i2c_client(dev); | ||
353 | return sprintf(buf, "%d\n", !!(client->flags & I2C_CLIENT_PEC)); | ||
354 | } | ||
355 | |||
356 | static ssize_t set_pec(struct device *dev, struct device_attribute *dummy, | ||
357 | const char *buf, size_t count) | ||
358 | { | ||
359 | struct i2c_client *client = to_i2c_client(dev); | ||
360 | long val = simple_strtol(buf, NULL, 10); | ||
361 | |||
362 | switch (val) { | ||
363 | case 0: | ||
364 | client->flags &= ~I2C_CLIENT_PEC; | ||
365 | break; | ||
366 | case 1: | ||
367 | client->flags |= I2C_CLIENT_PEC; | ||
368 | break; | ||
369 | default: | ||
370 | return -EINVAL; | ||
371 | } | ||
372 | |||
373 | return count; | ||
374 | } | ||
375 | |||
376 | static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec); | ||
377 | |||
348 | /* | 378 | /* |
349 | * Real code | 379 | * Real code |
350 | */ | 380 | */ |
351 | 381 | ||
382 | /* The ADM1032 supports PEC but not on write byte transactions, so we need | ||
383 | to explicitely ask for a transaction without PEC. */ | ||
384 | static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value) | ||
385 | { | ||
386 | return i2c_smbus_xfer(client->adapter, client->addr, | ||
387 | client->flags & ~I2C_CLIENT_PEC, | ||
388 | I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); | ||
389 | } | ||
390 | |||
391 | /* It is assumed that client->update_lock is held (unless we are in | ||
392 | detection or initialization steps). This matters when PEC is enabled, | ||
393 | because we don't want the address pointer to change between the write | ||
394 | byte and the read byte transactions. */ | ||
395 | static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value) | ||
396 | { | ||
397 | int err; | ||
398 | |||
399 | if (client->flags & I2C_CLIENT_PEC) { | ||
400 | err = adm1032_write_byte(client, reg); | ||
401 | if (err >= 0) | ||
402 | err = i2c_smbus_read_byte(client); | ||
403 | } else | ||
404 | err = i2c_smbus_read_byte_data(client, reg); | ||
405 | |||
406 | if (err < 0) { | ||
407 | dev_warn(&client->dev, "Register %#02x read failed (%d)\n", | ||
408 | reg, err); | ||
409 | return err; | ||
410 | } | ||
411 | *value = err; | ||
412 | |||
413 | return 0; | ||
414 | } | ||
415 | |||
352 | static int lm90_attach_adapter(struct i2c_adapter *adapter) | 416 | static int lm90_attach_adapter(struct i2c_adapter *adapter) |
353 | { | 417 | { |
354 | if (!(adapter->class & I2C_CLASS_HWMON)) | 418 | if (!(adapter->class & I2C_CLASS_HWMON)) |
@@ -370,11 +434,10 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
370 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 434 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
371 | goto exit; | 435 | goto exit; |
372 | 436 | ||
373 | if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) { | 437 | if (!(data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL))) { |
374 | err = -ENOMEM; | 438 | err = -ENOMEM; |
375 | goto exit; | 439 | goto exit; |
376 | } | 440 | } |
377 | memset(data, 0, sizeof(struct lm90_data)); | ||
378 | 441 | ||
379 | /* The common I2C client data is placed right before the | 442 | /* The common I2C client data is placed right before the |
380 | LM90-specific data. */ | 443 | LM90-specific data. */ |
@@ -403,20 +466,22 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
403 | if (kind < 0) { /* detection and identification */ | 466 | if (kind < 0) { /* detection and identification */ |
404 | u8 man_id, chip_id, reg_config1, reg_convrate; | 467 | u8 man_id, chip_id, reg_config1, reg_convrate; |
405 | 468 | ||
406 | man_id = i2c_smbus_read_byte_data(new_client, | 469 | if (lm90_read_reg(new_client, LM90_REG_R_MAN_ID, |
407 | LM90_REG_R_MAN_ID); | 470 | &man_id) < 0 |
408 | chip_id = i2c_smbus_read_byte_data(new_client, | 471 | || lm90_read_reg(new_client, LM90_REG_R_CHIP_ID, |
409 | LM90_REG_R_CHIP_ID); | 472 | &chip_id) < 0 |
410 | reg_config1 = i2c_smbus_read_byte_data(new_client, | 473 | || lm90_read_reg(new_client, LM90_REG_R_CONFIG1, |
411 | LM90_REG_R_CONFIG1); | 474 | ®_config1) < 0 |
412 | reg_convrate = i2c_smbus_read_byte_data(new_client, | 475 | || lm90_read_reg(new_client, LM90_REG_R_CONVRATE, |
413 | LM90_REG_R_CONVRATE); | 476 | ®_convrate) < 0) |
477 | goto exit_free; | ||
414 | 478 | ||
415 | if (man_id == 0x01) { /* National Semiconductor */ | 479 | if (man_id == 0x01) { /* National Semiconductor */ |
416 | u8 reg_config2; | 480 | u8 reg_config2; |
417 | 481 | ||
418 | reg_config2 = i2c_smbus_read_byte_data(new_client, | 482 | if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2, |
419 | LM90_REG_R_CONFIG2); | 483 | ®_config2) < 0) |
484 | goto exit_free; | ||
420 | 485 | ||
421 | if ((reg_config1 & 0x2A) == 0x00 | 486 | if ((reg_config1 & 0x2A) == 0x00 |
422 | && (reg_config2 & 0xF8) == 0x00 | 487 | && (reg_config2 & 0xF8) == 0x00 |
@@ -435,14 +500,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
435 | } | 500 | } |
436 | } else | 501 | } else |
437 | if (man_id == 0x41) { /* Analog Devices */ | 502 | if (man_id == 0x41) { /* Analog Devices */ |
438 | if (address == 0x4C | 503 | if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ |
439 | && (chip_id & 0xF0) == 0x40 /* ADM1032 */ | ||
440 | && (reg_config1 & 0x3F) == 0x00 | 504 | && (reg_config1 & 0x3F) == 0x00 |
441 | && reg_convrate <= 0x0A) { | 505 | && reg_convrate <= 0x0A) { |
442 | kind = adm1032; | 506 | kind = adm1032; |
443 | } else | 507 | } else |
444 | if (address == 0x4c | 508 | if (chip_id == 0x51 /* ADT7461 */ |
445 | && chip_id == 0x51 /* ADT7461 */ | ||
446 | && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ | 509 | && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ |
447 | && reg_convrate <= 0x0A) { | 510 | && reg_convrate <= 0x0A) { |
448 | kind = adt7461; | 511 | kind = adt7461; |
@@ -477,6 +540,10 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
477 | name = "lm90"; | 540 | name = "lm90"; |
478 | } else if (kind == adm1032) { | 541 | } else if (kind == adm1032) { |
479 | name = "adm1032"; | 542 | name = "adm1032"; |
543 | /* The ADM1032 supports PEC, but only if combined | ||
544 | transactions are not used. */ | ||
545 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) | ||
546 | new_client->flags |= I2C_CLIENT_PEC; | ||
480 | } else if (kind == lm99) { | 547 | } else if (kind == lm99) { |
481 | name = "lm99"; | 548 | name = "lm99"; |
482 | } else if (kind == lm86) { | 549 | } else if (kind == lm86) { |
@@ -529,6 +596,9 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
529 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); | 596 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); |
530 | device_create_file(&new_client->dev, &dev_attr_alarms); | 597 | device_create_file(&new_client->dev, &dev_attr_alarms); |
531 | 598 | ||
599 | if (new_client->flags & I2C_CLIENT_PEC) | ||
600 | device_create_file(&new_client->dev, &dev_attr_pec); | ||
601 | |||
532 | return 0; | 602 | return 0; |
533 | 603 | ||
534 | exit_detach: | 604 | exit_detach: |
@@ -548,7 +618,10 @@ static void lm90_init_client(struct i2c_client *client) | |||
548 | */ | 618 | */ |
549 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, | 619 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, |
550 | 5); /* 2 Hz */ | 620 | 5); /* 2 Hz */ |
551 | config = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG1); | 621 | if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) { |
622 | dev_warn(&client->dev, "Initialization failed!\n"); | ||
623 | return; | ||
624 | } | ||
552 | if (config & 0x40) | 625 | if (config & 0x40) |
553 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, | 626 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, |
554 | config & 0xBF); /* run */ | 627 | config & 0xBF); /* run */ |
@@ -576,21 +649,15 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
576 | down(&data->update_lock); | 649 | down(&data->update_lock); |
577 | 650 | ||
578 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | 651 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
579 | u8 oldh, newh; | 652 | u8 oldh, newh, l; |
580 | 653 | ||
581 | dev_dbg(&client->dev, "Updating lm90 data.\n"); | 654 | dev_dbg(&client->dev, "Updating lm90 data.\n"); |
582 | data->temp8[0] = i2c_smbus_read_byte_data(client, | 655 | lm90_read_reg(client, LM90_REG_R_LOCAL_TEMP, &data->temp8[0]); |
583 | LM90_REG_R_LOCAL_TEMP); | 656 | lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[1]); |
584 | data->temp8[1] = i2c_smbus_read_byte_data(client, | 657 | lm90_read_reg(client, LM90_REG_R_LOCAL_HIGH, &data->temp8[2]); |
585 | LM90_REG_R_LOCAL_LOW); | 658 | lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT, &data->temp8[3]); |
586 | data->temp8[2] = i2c_smbus_read_byte_data(client, | 659 | lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[4]); |
587 | LM90_REG_R_LOCAL_HIGH); | 660 | lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst); |
588 | data->temp8[3] = i2c_smbus_read_byte_data(client, | ||
589 | LM90_REG_R_LOCAL_CRIT); | ||
590 | data->temp8[4] = i2c_smbus_read_byte_data(client, | ||
591 | LM90_REG_R_REMOTE_CRIT); | ||
592 | data->temp_hyst = i2c_smbus_read_byte_data(client, | ||
593 | LM90_REG_R_TCRIT_HYST); | ||
594 | 661 | ||
595 | /* | 662 | /* |
596 | * There is a trick here. We have to read two registers to | 663 | * There is a trick here. We have to read two registers to |
@@ -606,36 +673,20 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
606 | * then we have a valid reading. Else we have to read the low | 673 | * then we have a valid reading. Else we have to read the low |
607 | * byte again, and now we believe we have a correct reading. | 674 | * byte again, and now we believe we have a correct reading. |
608 | */ | 675 | */ |
609 | oldh = i2c_smbus_read_byte_data(client, | 676 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &oldh) == 0 |
610 | LM90_REG_R_REMOTE_TEMPH); | 677 | && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0 |
611 | data->temp11[0] = i2c_smbus_read_byte_data(client, | 678 | && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &newh) == 0 |
612 | LM90_REG_R_REMOTE_TEMPL); | 679 | && (newh == oldh |
613 | newh = i2c_smbus_read_byte_data(client, | 680 | || lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0)) |
614 | LM90_REG_R_REMOTE_TEMPH); | 681 | data->temp11[0] = (newh << 8) | l; |
615 | if (newh != oldh) { | 682 | |
616 | data->temp11[0] = i2c_smbus_read_byte_data(client, | 683 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &newh) == 0 |
617 | LM90_REG_R_REMOTE_TEMPL); | 684 | && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL, &l) == 0) |
618 | #ifdef DEBUG | 685 | data->temp11[1] = (newh << 8) | l; |
619 | oldh = i2c_smbus_read_byte_data(client, | 686 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &newh) == 0 |
620 | LM90_REG_R_REMOTE_TEMPH); | 687 | && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, &l) == 0) |
621 | /* oldh is actually newer */ | 688 | data->temp11[2] = (newh << 8) | l; |
622 | if (newh != oldh) | 689 | lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms); |
623 | dev_warn(&client->dev, "Remote temperature may be " | ||
624 | "wrong.\n"); | ||
625 | #endif | ||
626 | } | ||
627 | data->temp11[0] |= (newh << 8); | ||
628 | |||
629 | data->temp11[1] = (i2c_smbus_read_byte_data(client, | ||
630 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
631 | i2c_smbus_read_byte_data(client, | ||
632 | LM90_REG_R_REMOTE_LOWL); | ||
633 | data->temp11[2] = (i2c_smbus_read_byte_data(client, | ||
634 | LM90_REG_R_REMOTE_HIGHH) << 8) + | ||
635 | i2c_smbus_read_byte_data(client, | ||
636 | LM90_REG_R_REMOTE_HIGHL); | ||
637 | data->alarms = i2c_smbus_read_byte_data(client, | ||
638 | LM90_REG_R_STATUS); | ||
639 | 690 | ||
640 | data->last_updated = jiffies; | 691 | data->last_updated = jiffies; |
641 | data->valid = 1; | 692 | data->valid = 1; |
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 647b7c7cd575..7a4b3701ed1a 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -300,11 +300,10 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) | |||
300 | | I2C_FUNC_SMBUS_WORD_DATA)) | 300 | | I2C_FUNC_SMBUS_WORD_DATA)) |
301 | goto exit; | 301 | goto exit; |
302 | 302 | ||
303 | if (!(data = kmalloc(sizeof(struct lm92_data), GFP_KERNEL))) { | 303 | if (!(data = kzalloc(sizeof(struct lm92_data), GFP_KERNEL))) { |
304 | err = -ENOMEM; | 304 | err = -ENOMEM; |
305 | goto exit; | 305 | goto exit; |
306 | } | 306 | } |
307 | memset(data, 0, sizeof(struct lm92_data)); | ||
308 | 307 | ||
309 | /* Fill in enough client fields so that we can read from the chip, | 308 | /* Fill in enough client fields so that we can read from the chip, |
310 | which is required for identication */ | 309 | which is required for identication */ |
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 16bf71f3a04d..6a82ffae1bfd 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c | |||
@@ -197,11 +197,10 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) | |||
197 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 197 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
198 | goto exit; | 198 | goto exit; |
199 | 199 | ||
200 | if (!(data = kmalloc(sizeof(struct max1619_data), GFP_KERNEL))) { | 200 | if (!(data = kzalloc(sizeof(struct max1619_data), GFP_KERNEL))) { |
201 | err = -ENOMEM; | 201 | err = -ENOMEM; |
202 | goto exit; | 202 | goto exit; |
203 | } | 203 | } |
204 | memset(data, 0, sizeof(struct max1619_data)); | ||
205 | 204 | ||
206 | /* The common I2C client data is placed right before the | 205 | /* The common I2C client data is placed right before the |
207 | MAX1619-specific data. */ | 206 | MAX1619-specific data. */ |
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index cf2a35799c7c..17f745a23d04 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -754,9 +754,8 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
754 | const char *name = "pc87360"; | 754 | const char *name = "pc87360"; |
755 | int use_thermistors = 0; | 755 | int use_thermistors = 0; |
756 | 756 | ||
757 | if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) | 757 | if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL))) |
758 | return -ENOMEM; | 758 | return -ENOMEM; |
759 | memset(data, 0x00, sizeof(struct pc87360_data)); | ||
760 | 759 | ||
761 | new_client = &data->client; | 760 | new_client = &data->client; |
762 | i2c_set_clientdata(new_client, data); | 761 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 21aa9a41f62c..9c6cadec1087 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c | |||
@@ -518,11 +518,10 @@ static int sis5595_detect(struct i2c_adapter *adapter) | |||
518 | goto exit_release; | 518 | goto exit_release; |
519 | } | 519 | } |
520 | 520 | ||
521 | if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { | 521 | if (!(data = kzalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { |
522 | err = -ENOMEM; | 522 | err = -ENOMEM; |
523 | goto exit_release; | 523 | goto exit_release; |
524 | } | 524 | } |
525 | memset(data, 0, sizeof(struct sis5595_data)); | ||
526 | 525 | ||
527 | new_client = &data->client; | 526 | new_client = &data->client; |
528 | new_client->addr = address; | 527 | new_client->addr = address; |
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 7fe71576dea4..2a3e21b5b6b4 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c | |||
@@ -244,11 +244,10 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) | |||
244 | return -EBUSY; | 244 | return -EBUSY; |
245 | } | 245 | } |
246 | 246 | ||
247 | if (!(data = kmalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { | 247 | if (!(data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { |
248 | err = -ENOMEM; | 248 | err = -ENOMEM; |
249 | goto error_release; | 249 | goto error_release; |
250 | } | 250 | } |
251 | memset(data, 0x00, sizeof(struct smsc47b397_data)); | ||
252 | 251 | ||
253 | new_client = &data->client; | 252 | new_client = &data->client; |
254 | i2c_set_clientdata(new_client, data); | 253 | i2c_set_clientdata(new_client, data); |
@@ -299,7 +298,7 @@ static int __init smsc47b397_find(unsigned short *addr) | |||
299 | superio_enter(); | 298 | superio_enter(); |
300 | id = superio_inb(SUPERIO_REG_DEVID); | 299 | id = superio_inb(SUPERIO_REG_DEVID); |
301 | 300 | ||
302 | if (id != 0x6f) { | 301 | if ((id != 0x6f) && (id != 0x81)) { |
303 | superio_exit(); | 302 | superio_exit(); |
304 | return -ENODEV; | 303 | return -ENODEV; |
305 | } | 304 | } |
@@ -310,8 +309,9 @@ static int __init smsc47b397_find(unsigned short *addr) | |||
310 | *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) | 309 | *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) |
311 | | superio_inb(SUPERIO_REG_BASE_LSB); | 310 | | superio_inb(SUPERIO_REG_BASE_LSB); |
312 | 311 | ||
313 | printk(KERN_INFO "smsc47b397: found SMSC LPC47B397-NC " | 312 | printk(KERN_INFO "smsc47b397: found SMSC %s " |
314 | "(base address 0x%04x, revision %u)\n", *addr, rev); | 313 | "(base address 0x%04x, revision %u)\n", |
314 | id == 0x81 ? "SCH5307-NS" : "LPC47B397-NC", *addr, rev); | ||
315 | 315 | ||
316 | superio_exit(); | 316 | superio_exit(); |
317 | return 0; | 317 | return 0; |
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index c9cc683eba4a..5905c1af88f2 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -3,7 +3,7 @@ | |||
3 | for hardware monitoring | 3 | for hardware monitoring |
4 | 4 | ||
5 | Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, | 5 | Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, |
6 | LPC47M15x and LPC47M192 Super-I/O chips. | 6 | LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips. |
7 | 7 | ||
8 | Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> | 8 | Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
9 | Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> | 9 | Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> |
@@ -356,6 +356,8 @@ static int __init smsc47m1_find(unsigned short *addr) | |||
356 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. | 356 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. |
357 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" | 357 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" |
358 | * can do much more besides (device id 0x60). | 358 | * can do much more besides (device id 0x60). |
359 | * The LPC47M997 is undocumented, but seems to be compatible with | ||
360 | * the LPC47M192, and has the same device id. | ||
359 | */ | 361 | */ |
360 | if (val == 0x51) | 362 | if (val == 0x51) |
361 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); | 363 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); |
@@ -364,7 +366,8 @@ static int __init smsc47m1_find(unsigned short *addr) | |||
364 | else if (val == 0x5F) | 366 | else if (val == 0x5F) |
365 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); | 367 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); |
366 | else if (val == 0x60) | 368 | else if (val == 0x60) |
367 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); | 369 | printk(KERN_INFO "smsc47m1: Found SMSC " |
370 | "LPC47M15x/LPC47M192/LPC47M997\n"); | ||
368 | else { | 371 | else { |
369 | superio_exit(); | 372 | superio_exit(); |
370 | return -ENODEV; | 373 | return -ENODEV; |
@@ -396,11 +399,10 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) | |||
396 | return -EBUSY; | 399 | return -EBUSY; |
397 | } | 400 | } |
398 | 401 | ||
399 | if (!(data = kmalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { | 402 | if (!(data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { |
400 | err = -ENOMEM; | 403 | err = -ENOMEM; |
401 | goto error_release; | 404 | goto error_release; |
402 | } | 405 | } |
403 | memset(data, 0x00, sizeof(struct smsc47m1_data)); | ||
404 | 406 | ||
405 | new_client = &data->client; | 407 | new_client = &data->client; |
406 | i2c_set_clientdata(new_client, data); | 408 | i2c_set_clientdata(new_client, data); |
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 05ddc88e7dd2..6f696f897176 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -44,7 +44,7 @@ | |||
44 | 44 | ||
45 | /* If force_addr is set to anything different from 0, we forcibly enable | 45 | /* If force_addr is set to anything different from 0, we forcibly enable |
46 | the device at the given address. */ | 46 | the device at the given address. */ |
47 | static unsigned short force_addr = 0; | 47 | static unsigned short force_addr; |
48 | module_param(force_addr, ushort, 0); | 48 | module_param(force_addr, ushort, 0); |
49 | MODULE_PARM_DESC(force_addr, | 49 | MODULE_PARM_DESC(force_addr, |
50 | "Initialize the base address of the sensors"); | 50 | "Initialize the base address of the sensors"); |
@@ -198,7 +198,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
198 | but the function is very linear in the useful range (0-80 deg C), so | 198 | but the function is very linear in the useful range (0-80 deg C), so |
199 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT | 199 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT |
200 | is the temp at via register values 0-255: */ | 200 | is the temp at via register values 0-255: */ |
201 | static const long tempLUT[] = | 201 | static const s16 tempLUT[] = |
202 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, | 202 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, |
203 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, | 203 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, |
204 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, | 204 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, |
@@ -270,7 +270,7 @@ static inline u8 TEMP_TO_REG(long val) | |||
270 | } | 270 | } |
271 | 271 | ||
272 | /* for 8-bit temperature hyst and over registers */ | 272 | /* for 8-bit temperature hyst and over registers */ |
273 | #define TEMP_FROM_REG(val) (tempLUT[(val)] * 100) | 273 | #define TEMP_FROM_REG(val) ((long)tempLUT[val] * 100) |
274 | 274 | ||
275 | /* for 10-bit temperature readings */ | 275 | /* for 10-bit temperature readings */ |
276 | static inline long TEMP_FROM_REG10(u16 val) | 276 | static inline long TEMP_FROM_REG10(u16 val) |
@@ -589,10 +589,8 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
589 | u16 val; | 589 | u16 val; |
590 | 590 | ||
591 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ | 591 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ |
592 | if (force_addr) | ||
593 | address = force_addr & 0xFF00; | ||
594 | |||
595 | if (force_addr) { | 592 | if (force_addr) { |
593 | address = force_addr & 0xFF00; | ||
596 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", | 594 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", |
597 | address); | 595 | address); |
598 | if (PCIBIOS_SUCCESSFUL != | 596 | if (PCIBIOS_SUCCESSFUL != |
@@ -603,11 +601,17 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
603 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) | 601 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) |
604 | return -ENODEV; | 602 | return -ENODEV; |
605 | if (!(val & 0x0001)) { | 603 | if (!(val & 0x0001)) { |
606 | dev_warn(&adapter->dev, "enabling sensors\n"); | 604 | if (force_addr) { |
607 | if (PCIBIOS_SUCCESSFUL != | 605 | dev_info(&adapter->dev, "enabling sensors\n"); |
608 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, | 606 | if (PCIBIOS_SUCCESSFUL != |
609 | val | 0x0001)) | 607 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, |
608 | val | 0x0001)) | ||
609 | return -ENODEV; | ||
610 | } else { | ||
611 | dev_warn(&adapter->dev, "sensors disabled - enable " | ||
612 | "with force_addr=0x%x\n", address); | ||
610 | return -ENODEV; | 613 | return -ENODEV; |
614 | } | ||
611 | } | 615 | } |
612 | 616 | ||
613 | /* Reserve the ISA region */ | 617 | /* Reserve the ISA region */ |
@@ -617,11 +621,10 @@ static int via686a_detect(struct i2c_adapter *adapter) | |||
617 | return -ENODEV; | 621 | return -ENODEV; |
618 | } | 622 | } |
619 | 623 | ||
620 | if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { | 624 | if (!(data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL))) { |
621 | err = -ENOMEM; | 625 | err = -ENOMEM; |
622 | goto exit_release; | 626 | goto exit_release; |
623 | } | 627 | } |
624 | memset(data, 0, sizeof(struct via686a_data)); | ||
625 | 628 | ||
626 | new_client = &data->client; | 629 | new_client = &data->client; |
627 | i2c_set_clientdata(new_client, data); | 630 | i2c_set_clientdata(new_client, data); |
@@ -708,7 +711,6 @@ static int via686a_detach_client(struct i2c_client *client) | |||
708 | return 0; | 711 | return 0; |
709 | } | 712 | } |
710 | 713 | ||
711 | /* Called when we have found a new VIA686A. Set limits, etc. */ | ||
712 | static void via686a_init_client(struct i2c_client *client) | 714 | static void via686a_init_client(struct i2c_client *client) |
713 | { | 715 | { |
714 | u8 reg; | 716 | u8 reg; |
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index b60efe8f8b26..eee22a57e929 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -105,7 +105,9 @@ superio_exit(void) | |||
105 | * ISA constants | 105 | * ISA constants |
106 | */ | 106 | */ |
107 | 107 | ||
108 | #define REGION_LENGTH 8 | 108 | #define REGION_ALIGNMENT ~7 |
109 | #define REGION_OFFSET 5 | ||
110 | #define REGION_LENGTH 2 | ||
109 | #define ADDR_REG_OFFSET 5 | 111 | #define ADDR_REG_OFFSET 5 |
110 | #define DATA_REG_OFFSET 6 | 112 | #define DATA_REG_OFFSET 6 |
111 | 113 | ||
@@ -673,16 +675,16 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
673 | struct w83627ehf_data *data; | 675 | struct w83627ehf_data *data; |
674 | int i, err = 0; | 676 | int i, err = 0; |
675 | 677 | ||
676 | if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { | 678 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, |
679 | w83627ehf_driver.name)) { | ||
677 | err = -EBUSY; | 680 | err = -EBUSY; |
678 | goto exit; | 681 | goto exit; |
679 | } | 682 | } |
680 | 683 | ||
681 | if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { | 684 | if (!(data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { |
682 | err = -ENOMEM; | 685 | err = -ENOMEM; |
683 | goto exit_release; | 686 | goto exit_release; |
684 | } | 687 | } |
685 | memset(data, 0, sizeof(struct w83627ehf_data)); | ||
686 | 688 | ||
687 | client = &data->client; | 689 | client = &data->client; |
688 | i2c_set_clientdata(client, data); | 690 | i2c_set_clientdata(client, data); |
@@ -762,7 +764,7 @@ exit_detach: | |||
762 | exit_free: | 764 | exit_free: |
763 | kfree(data); | 765 | kfree(data); |
764 | exit_release: | 766 | exit_release: |
765 | release_region(address, REGION_LENGTH); | 767 | release_region(address + REGION_OFFSET, REGION_LENGTH); |
766 | exit: | 768 | exit: |
767 | return err; | 769 | return err; |
768 | } | 770 | } |
@@ -776,7 +778,7 @@ static int w83627ehf_detach_client(struct i2c_client *client) | |||
776 | 778 | ||
777 | if ((err = i2c_detach_client(client))) | 779 | if ((err = i2c_detach_client(client))) |
778 | return err; | 780 | return err; |
779 | release_region(client->addr, REGION_LENGTH); | 781 | release_region(client->addr + REGION_OFFSET, REGION_LENGTH); |
780 | kfree(data); | 782 | kfree(data); |
781 | 783 | ||
782 | return 0; | 784 | return 0; |
@@ -807,7 +809,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr) | |||
807 | superio_select(W83627EHF_LD_HWM); | 809 | superio_select(W83627EHF_LD_HWM); |
808 | val = (superio_inb(SIO_REG_ADDR) << 8) | 810 | val = (superio_inb(SIO_REG_ADDR) << 8) |
809 | | superio_inb(SIO_REG_ADDR + 1); | 811 | | superio_inb(SIO_REG_ADDR + 1); |
810 | *addr = val & ~(REGION_LENGTH - 1); | 812 | *addr = val & REGION_ALIGNMENT; |
811 | if (*addr == 0) { | 813 | if (*addr == 0) { |
812 | superio_exit(); | 814 | superio_exit(); |
813 | return -ENODEV; | 815 | return -ENODEV; |
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 3479dc5208e2..70ef926c3bd8 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -142,10 +142,14 @@ superio_exit(void) | |||
142 | #define WINB_BASE_REG 0x60 | 142 | #define WINB_BASE_REG 0x60 |
143 | /* Constants specified below */ | 143 | /* Constants specified below */ |
144 | 144 | ||
145 | /* Length of ISA address segment */ | 145 | /* Alignment of the base address */ |
146 | #define WINB_EXTENT 8 | 146 | #define WINB_ALIGNMENT ~7 |
147 | 147 | ||
148 | /* Where are the ISA address/data registers relative to the base address */ | 148 | /* Offset & size of I/O region we are interested in */ |
149 | #define WINB_REGION_OFFSET 5 | ||
150 | #define WINB_REGION_SIZE 2 | ||
151 | |||
152 | /* Where are the sensors address/data registers relative to the base address */ | ||
149 | #define W83781D_ADDR_REG_OFFSET 5 | 153 | #define W83781D_ADDR_REG_OFFSET 5 |
150 | #define W83781D_DATA_REG_OFFSET 6 | 154 | #define W83781D_DATA_REG_OFFSET 6 |
151 | 155 | ||
@@ -197,7 +201,6 @@ superio_exit(void) | |||
197 | 201 | ||
198 | #define W83627HF_REG_PWM1 0x5A | 202 | #define W83627HF_REG_PWM1 0x5A |
199 | #define W83627HF_REG_PWM2 0x5B | 203 | #define W83627HF_REG_PWM2 0x5B |
200 | #define W83627HF_REG_PWMCLK12 0x5C | ||
201 | 204 | ||
202 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ | 205 | #define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ |
203 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ | 206 | #define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ |
@@ -981,7 +984,7 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) | |||
981 | superio_select(W83627HF_LD_HWM); | 984 | superio_select(W83627HF_LD_HWM); |
982 | val = (superio_inb(WINB_BASE_REG) << 8) | | 985 | val = (superio_inb(WINB_BASE_REG) << 8) | |
983 | superio_inb(WINB_BASE_REG + 1); | 986 | superio_inb(WINB_BASE_REG + 1); |
984 | *addr = val & ~(WINB_EXTENT - 1); | 987 | *addr = val & WINB_ALIGNMENT; |
985 | if (*addr == 0 && force_addr == 0) { | 988 | if (*addr == 0 && force_addr == 0) { |
986 | superio_exit(); | 989 | superio_exit(); |
987 | return -ENODEV; | 990 | return -ENODEV; |
@@ -1000,9 +1003,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1000 | const char *client_name = ""; | 1003 | const char *client_name = ""; |
1001 | 1004 | ||
1002 | if(force_addr) | 1005 | if(force_addr) |
1003 | address = force_addr & ~(WINB_EXTENT - 1); | 1006 | address = force_addr & WINB_ALIGNMENT; |
1004 | 1007 | ||
1005 | if (!request_region(address, WINB_EXTENT, w83627hf_driver.name)) { | 1008 | if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE, |
1009 | w83627hf_driver.name)) { | ||
1006 | err = -EBUSY; | 1010 | err = -EBUSY; |
1007 | goto ERROR0; | 1011 | goto ERROR0; |
1008 | } | 1012 | } |
@@ -1041,11 +1045,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1041 | client structure, even though we cannot fill it completely yet. | 1045 | client structure, even though we cannot fill it completely yet. |
1042 | But it allows us to access w83627hf_{read,write}_value. */ | 1046 | But it allows us to access w83627hf_{read,write}_value. */ |
1043 | 1047 | ||
1044 | if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { | 1048 | if (!(data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { |
1045 | err = -ENOMEM; | 1049 | err = -ENOMEM; |
1046 | goto ERROR1; | 1050 | goto ERROR1; |
1047 | } | 1051 | } |
1048 | memset(data, 0, sizeof(struct w83627hf_data)); | ||
1049 | 1052 | ||
1050 | new_client = &data->client; | 1053 | new_client = &data->client; |
1051 | i2c_set_clientdata(new_client, data); | 1054 | i2c_set_clientdata(new_client, data); |
@@ -1148,7 +1151,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) | |||
1148 | ERROR2: | 1151 | ERROR2: |
1149 | kfree(data); | 1152 | kfree(data); |
1150 | ERROR1: | 1153 | ERROR1: |
1151 | release_region(address, WINB_EXTENT); | 1154 | release_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE); |
1152 | ERROR0: | 1155 | ERROR0: |
1153 | return err; | 1156 | return err; |
1154 | } | 1157 | } |
@@ -1163,7 +1166,7 @@ static int w83627hf_detach_client(struct i2c_client *client) | |||
1163 | if ((err = i2c_detach_client(client))) | 1166 | if ((err = i2c_detach_client(client))) |
1164 | return err; | 1167 | return err; |
1165 | 1168 | ||
1166 | release_region(client->addr, WINB_EXTENT); | 1169 | release_region(client->addr + WINB_REGION_OFFSET, WINB_REGION_SIZE); |
1167 | kfree(data); | 1170 | kfree(data); |
1168 | 1171 | ||
1169 | return 0; | 1172 | return 0; |
@@ -1275,7 +1278,6 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1275 | return 0; | 1278 | return 0; |
1276 | } | 1279 | } |
1277 | 1280 | ||
1278 | /* Called when we have found a new W83781D. It should set limits, etc. */ | ||
1279 | static void w83627hf_init_client(struct i2c_client *client) | 1281 | static void w83627hf_init_client(struct i2c_client *client) |
1280 | { | 1282 | { |
1281 | struct w83627hf_data *data = i2c_get_clientdata(client); | 1283 | struct w83627hf_data *data = i2c_get_clientdata(client); |
@@ -1369,12 +1371,6 @@ static void w83627hf_init_client(struct i2c_client *client) | |||
1369 | } | 1371 | } |
1370 | } | 1372 | } |
1371 | 1373 | ||
1372 | if (type == w83627hf) { | ||
1373 | /* enable PWM2 control (can't hurt since PWM reg | ||
1374 | should have been reset to 0xff) */ | ||
1375 | w83627hf_write_value(client, W83627HF_REG_PWMCLK12, | ||
1376 | 0x19); | ||
1377 | } | ||
1378 | /* enable comparator mode for temp2 and temp3 so | 1374 | /* enable comparator mode for temp2 and temp3 so |
1379 | alarm indication will work correctly */ | 1375 | alarm indication will work correctly */ |
1380 | i = w83627hf_read_value(client, W83781D_REG_IRQ); | 1376 | i = w83627hf_read_value(client, W83781D_REG_IRQ); |
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 4c43337ca780..9265f32122fa 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -889,12 +889,11 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, | |||
889 | const char *client_name = ""; | 889 | const char *client_name = ""; |
890 | struct w83781d_data *data = i2c_get_clientdata(new_client); | 890 | struct w83781d_data *data = i2c_get_clientdata(new_client); |
891 | 891 | ||
892 | data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 892 | data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
893 | if (!(data->lm75[0])) { | 893 | if (!(data->lm75[0])) { |
894 | err = -ENOMEM; | 894 | err = -ENOMEM; |
895 | goto ERROR_SC_0; | 895 | goto ERROR_SC_0; |
896 | } | 896 | } |
897 | memset(data->lm75[0], 0x00, sizeof (struct i2c_client)); | ||
898 | 897 | ||
899 | id = i2c_adapter_id(adapter); | 898 | id = i2c_adapter_id(adapter); |
900 | 899 | ||
@@ -919,13 +918,11 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, | |||
919 | } | 918 | } |
920 | 919 | ||
921 | if (kind != w83783s) { | 920 | if (kind != w83783s) { |
922 | 921 | data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | |
923 | data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
924 | if (!(data->lm75[1])) { | 922 | if (!(data->lm75[1])) { |
925 | err = -ENOMEM; | 923 | err = -ENOMEM; |
926 | goto ERROR_SC_1; | 924 | goto ERROR_SC_1; |
927 | } | 925 | } |
928 | memset(data->lm75[1], 0x0, sizeof(struct i2c_client)); | ||
929 | 926 | ||
930 | if (force_subclients[0] == id && | 927 | if (force_subclients[0] == id && |
931 | force_subclients[1] == address) { | 928 | force_subclients[1] == address) { |
@@ -1064,11 +1061,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1064 | client structure, even though we cannot fill it completely yet. | 1061 | client structure, even though we cannot fill it completely yet. |
1065 | But it allows us to access w83781d_{read,write}_value. */ | 1062 | But it allows us to access w83781d_{read,write}_value. */ |
1066 | 1063 | ||
1067 | if (!(data = kmalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { | 1064 | if (!(data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { |
1068 | err = -ENOMEM; | 1065 | err = -ENOMEM; |
1069 | goto ERROR1; | 1066 | goto ERROR1; |
1070 | } | 1067 | } |
1071 | memset(data, 0, sizeof(struct w83781d_data)); | ||
1072 | 1068 | ||
1073 | new_client = &data->client; | 1069 | new_client = &data->client; |
1074 | i2c_set_clientdata(new_client, data); | 1070 | i2c_set_clientdata(new_client, data); |
@@ -1451,7 +1447,6 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
1451 | return 0; | 1447 | return 0; |
1452 | } | 1448 | } |
1453 | 1449 | ||
1454 | /* Called when we have found a new W83781D. It should set limits, etc. */ | ||
1455 | static void | 1450 | static void |
1456 | w83781d_init_client(struct i2c_client *client) | 1451 | w83781d_init_client(struct i2c_client *client) |
1457 | { | 1452 | { |
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index ba0c28015f6a..4be59dbb78c4 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -1086,11 +1086,10 @@ w83792d_create_subclient(struct i2c_adapter *adapter, | |||
1086 | int err; | 1086 | int err; |
1087 | struct i2c_client *sub_client; | 1087 | struct i2c_client *sub_client; |
1088 | 1088 | ||
1089 | (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | 1089 | (*sub_cli) = sub_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
1090 | if (!(sub_client)) { | 1090 | if (!(sub_client)) { |
1091 | return -ENOMEM; | 1091 | return -ENOMEM; |
1092 | } | 1092 | } |
1093 | memset(sub_client, 0x00, sizeof(struct i2c_client)); | ||
1094 | sub_client->addr = 0x48 + addr; | 1093 | sub_client->addr = 0x48 + addr; |
1095 | i2c_set_clientdata(sub_client, NULL); | 1094 | i2c_set_clientdata(sub_client, NULL); |
1096 | sub_client->adapter = adapter; | 1095 | sub_client->adapter = adapter; |
@@ -1184,11 +1183,10 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1184 | client structure, even though we cannot fill it completely yet. | 1183 | client structure, even though we cannot fill it completely yet. |
1185 | But it allows us to access w83792d_{read,write}_value. */ | 1184 | But it allows us to access w83792d_{read,write}_value. */ |
1186 | 1185 | ||
1187 | if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { | 1186 | if (!(data = kzalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { |
1188 | err = -ENOMEM; | 1187 | err = -ENOMEM; |
1189 | goto ERROR0; | 1188 | goto ERROR0; |
1190 | } | 1189 | } |
1191 | memset(data, 0, sizeof(struct w83792d_data)); | ||
1192 | 1190 | ||
1193 | new_client = &data->client; | 1191 | new_client = &data->client; |
1194 | i2c_set_clientdata(new_client, data); | 1192 | i2c_set_clientdata(new_client, data); |
@@ -1429,7 +1427,6 @@ w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
1429 | return 0; | 1427 | return 0; |
1430 | } | 1428 | } |
1431 | 1429 | ||
1432 | /* Called when we have found a new W83792D. It should set limits, etc. */ | ||
1433 | static void | 1430 | static void |
1434 | w83792d_init_client(struct i2c_client *client) | 1431 | w83792d_init_client(struct i2c_client *client) |
1435 | { | 1432 | { |
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 133e34ab1d0a..f495b6378668 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/jiffies.h> | 37 | #include <linux/jiffies.h> |
38 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
39 | #include <linux/hwmon.h> | 39 | #include <linux/hwmon.h> |
40 | #include <linux/hwmon-sysfs.h> | ||
40 | #include <linux/err.h> | 41 | #include <linux/err.h> |
41 | 42 | ||
42 | /* How many retries on register read error */ | 43 | /* How many retries on register read error */ |
@@ -73,7 +74,7 @@ I2C_CLIENT_INSMOD_1(w83l785ts); | |||
73 | * The W83L785TS-S uses signed 8-bit values. | 74 | * The W83L785TS-S uses signed 8-bit values. |
74 | */ | 75 | */ |
75 | 76 | ||
76 | #define TEMP_FROM_REG(val) ((val & 0x80 ? val-0x100 : val) * 1000) | 77 | #define TEMP_FROM_REG(val) ((val) * 1000) |
77 | 78 | ||
78 | /* | 79 | /* |
79 | * Functions declaration | 80 | * Functions declaration |
@@ -111,27 +112,24 @@ struct w83l785ts_data { | |||
111 | unsigned long last_updated; /* in jiffies */ | 112 | unsigned long last_updated; /* in jiffies */ |
112 | 113 | ||
113 | /* registers values */ | 114 | /* registers values */ |
114 | u8 temp, temp_over; | 115 | s8 temp[2]; /* 0: input |
116 | 1: critical limit */ | ||
115 | }; | 117 | }; |
116 | 118 | ||
117 | /* | 119 | /* |
118 | * Sysfs stuff | 120 | * Sysfs stuff |
119 | */ | 121 | */ |
120 | 122 | ||
121 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) | 123 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
124 | char *buf) | ||
122 | { | 125 | { |
126 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
123 | struct w83l785ts_data *data = w83l785ts_update_device(dev); | 127 | struct w83l785ts_data *data = w83l785ts_update_device(dev); |
124 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); | 128 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); |
125 | } | 129 | } |
126 | 130 | ||
127 | static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) | 131 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
128 | { | 132 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 1); |
129 | struct w83l785ts_data *data = w83l785ts_update_device(dev); | ||
130 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); | ||
131 | } | ||
132 | |||
133 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | ||
134 | static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL); | ||
135 | 133 | ||
136 | /* | 134 | /* |
137 | * Real code | 135 | * Real code |
@@ -158,12 +156,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
158 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 156 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
159 | goto exit; | 157 | goto exit; |
160 | 158 | ||
161 | if (!(data = kmalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { | 159 | if (!(data = kzalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { |
162 | err = -ENOMEM; | 160 | err = -ENOMEM; |
163 | goto exit; | 161 | goto exit; |
164 | } | 162 | } |
165 | memset(data, 0, sizeof(struct w83l785ts_data)); | ||
166 | |||
167 | 163 | ||
168 | /* The common I2C client data is placed right before the | 164 | /* The common I2C client data is placed right before the |
169 | * W83L785TS-specific data. */ | 165 | * W83L785TS-specific data. */ |
@@ -228,7 +224,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
228 | init_MUTEX(&data->update_lock); | 224 | init_MUTEX(&data->update_lock); |
229 | 225 | ||
230 | /* Default values in case the first read fails (unlikely). */ | 226 | /* Default values in case the first read fails (unlikely). */ |
231 | data->temp_over = data->temp = 0; | 227 | data->temp[1] = data->temp[0] = 0; |
232 | 228 | ||
233 | /* Tell the I2C layer a new client has arrived. */ | 229 | /* Tell the I2C layer a new client has arrived. */ |
234 | if ((err = i2c_attach_client(new_client))) | 230 | if ((err = i2c_attach_client(new_client))) |
@@ -246,8 +242,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) | |||
246 | goto exit_detach; | 242 | goto exit_detach; |
247 | } | 243 | } |
248 | 244 | ||
249 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 245 | device_create_file(&new_client->dev, |
250 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 246 | &sensor_dev_attr_temp1_input.dev_attr); |
247 | device_create_file(&new_client->dev, | ||
248 | &sensor_dev_attr_temp1_max.dev_attr); | ||
251 | 249 | ||
252 | return 0; | 250 | return 0; |
253 | 251 | ||
@@ -305,10 +303,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev) | |||
305 | 303 | ||
306 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { | 304 | if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { |
307 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); | 305 | dev_dbg(&client->dev, "Updating w83l785ts data.\n"); |
308 | data->temp = w83l785ts_read_value(client, | 306 | data->temp[0] = w83l785ts_read_value(client, |
309 | W83L785TS_REG_TEMP, data->temp); | 307 | W83L785TS_REG_TEMP, data->temp[0]); |
310 | data->temp_over = w83l785ts_read_value(client, | 308 | data->temp[1] = w83l785ts_read_value(client, |
311 | W83L785TS_REG_TEMP_OVER, data->temp_over); | 309 | W83L785TS_REG_TEMP_OVER, data->temp[1]); |
312 | 310 | ||
313 | data->last_updated = jiffies; | 311 | data->last_updated = jiffies; |
314 | data->valid = 1; | 312 | data->valid = 1; |