diff options
Diffstat (limited to 'drivers/hwmon/asb100.c')
-rw-r--r-- | drivers/hwmon/asb100.c | 395 |
1 files changed, 183 insertions, 212 deletions
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 9460dba4cf74..950cea8d1d65 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/i2c.h> | 41 | #include <linux/i2c.h> |
42 | #include <linux/hwmon.h> | 42 | #include <linux/hwmon.h> |
43 | #include <linux/hwmon-sysfs.h> | ||
43 | #include <linux/hwmon-vid.h> | 44 | #include <linux/hwmon-vid.h> |
44 | #include <linux/err.h> | 45 | #include <linux/err.h> |
45 | #include <linux/init.h> | 46 | #include <linux/init.h> |
@@ -47,12 +48,6 @@ | |||
47 | #include <linux/mutex.h> | 48 | #include <linux/mutex.h> |
48 | #include "lm75.h" | 49 | #include "lm75.h" |
49 | 50 | ||
50 | /* | ||
51 | HISTORY: | ||
52 | 2003-12-29 1.0.0 Ported from lm_sensors project for kernel 2.6 | ||
53 | */ | ||
54 | #define ASB100_VERSION "1.0.0" | ||
55 | |||
56 | /* I2C addresses to scan */ | 51 | /* I2C addresses to scan */ |
57 | static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; | 52 | static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; |
58 | 53 | ||
@@ -221,15 +216,16 @@ static struct i2c_driver asb100_driver = { | |||
221 | .driver = { | 216 | .driver = { |
222 | .name = "asb100", | 217 | .name = "asb100", |
223 | }, | 218 | }, |
224 | .id = I2C_DRIVERID_ASB100, | ||
225 | .attach_adapter = asb100_attach_adapter, | 219 | .attach_adapter = asb100_attach_adapter, |
226 | .detach_client = asb100_detach_client, | 220 | .detach_client = asb100_detach_client, |
227 | }; | 221 | }; |
228 | 222 | ||
229 | /* 7 Voltages */ | 223 | /* 7 Voltages */ |
230 | #define show_in_reg(reg) \ | 224 | #define show_in_reg(reg) \ |
231 | static ssize_t show_##reg (struct device *dev, char *buf, int nr) \ | 225 | static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \ |
226 | char *buf) \ | ||
232 | { \ | 227 | { \ |
228 | int nr = to_sensor_dev_attr(attr)->index; \ | ||
233 | struct asb100_data *data = asb100_update_device(dev); \ | 229 | struct asb100_data *data = asb100_update_device(dev); \ |
234 | return sprintf(buf, "%d\n", IN_FROM_REG(data->reg[nr])); \ | 230 | return sprintf(buf, "%d\n", IN_FROM_REG(data->reg[nr])); \ |
235 | } | 231 | } |
@@ -239,9 +235,10 @@ show_in_reg(in_min) | |||
239 | show_in_reg(in_max) | 235 | show_in_reg(in_max) |
240 | 236 | ||
241 | #define set_in_reg(REG, reg) \ | 237 | #define set_in_reg(REG, reg) \ |
242 | static ssize_t set_in_##reg(struct device *dev, const char *buf, \ | 238 | static ssize_t set_in_##reg(struct device *dev, struct device_attribute *attr, \ |
243 | size_t count, int nr) \ | 239 | const char *buf, size_t count) \ |
244 | { \ | 240 | { \ |
241 | int nr = to_sensor_dev_attr(attr)->index; \ | ||
245 | struct i2c_client *client = to_i2c_client(dev); \ | 242 | struct i2c_client *client = to_i2c_client(dev); \ |
246 | struct asb100_data *data = i2c_get_clientdata(client); \ | 243 | struct asb100_data *data = i2c_get_clientdata(client); \ |
247 | unsigned long val = simple_strtoul(buf, NULL, 10); \ | 244 | unsigned long val = simple_strtoul(buf, NULL, 10); \ |
@@ -258,37 +255,12 @@ set_in_reg(MIN, min) | |||
258 | set_in_reg(MAX, max) | 255 | set_in_reg(MAX, max) |
259 | 256 | ||
260 | #define sysfs_in(offset) \ | 257 | #define sysfs_in(offset) \ |
261 | static ssize_t \ | 258 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
262 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 259 | show_in, NULL, offset); \ |
263 | { \ | 260 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
264 | return show_in(dev, buf, offset); \ | 261 | show_in_min, set_in_min, offset); \ |
265 | } \ | 262 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
266 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | 263 | show_in_max, set_in_max, offset) |
267 | show_in##offset, NULL); \ | ||
268 | static ssize_t \ | ||
269 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
270 | { \ | ||
271 | return show_in_min(dev, buf, offset); \ | ||
272 | } \ | ||
273 | static ssize_t \ | ||
274 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
275 | { \ | ||
276 | return show_in_max(dev, buf, offset); \ | ||
277 | } \ | ||
278 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ | ||
279 | const char *buf, size_t count) \ | ||
280 | { \ | ||
281 | return set_in_min(dev, buf, count, offset); \ | ||
282 | } \ | ||
283 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ | ||
284 | const char *buf, size_t count) \ | ||
285 | { \ | ||
286 | return set_in_max(dev, buf, count, offset); \ | ||
287 | } \ | ||
288 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
289 | show_in##offset##_min, set_in##offset##_min); \ | ||
290 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
291 | show_in##offset##_max, set_in##offset##_max); | ||
292 | 264 | ||
293 | sysfs_in(0); | 265 | sysfs_in(0); |
294 | sysfs_in(1); | 266 | sysfs_in(1); |
@@ -299,29 +271,36 @@ sysfs_in(5); | |||
299 | sysfs_in(6); | 271 | sysfs_in(6); |
300 | 272 | ||
301 | /* 3 Fans */ | 273 | /* 3 Fans */ |
302 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 274 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
275 | char *buf) | ||
303 | { | 276 | { |
277 | int nr = to_sensor_dev_attr(attr)->index; | ||
304 | struct asb100_data *data = asb100_update_device(dev); | 278 | struct asb100_data *data = asb100_update_device(dev); |
305 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | 279 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], |
306 | DIV_FROM_REG(data->fan_div[nr]))); | 280 | DIV_FROM_REG(data->fan_div[nr]))); |
307 | } | 281 | } |
308 | 282 | ||
309 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 283 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
284 | char *buf) | ||
310 | { | 285 | { |
286 | int nr = to_sensor_dev_attr(attr)->index; | ||
311 | struct asb100_data *data = asb100_update_device(dev); | 287 | struct asb100_data *data = asb100_update_device(dev); |
312 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | 288 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], |
313 | DIV_FROM_REG(data->fan_div[nr]))); | 289 | DIV_FROM_REG(data->fan_div[nr]))); |
314 | } | 290 | } |
315 | 291 | ||
316 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 292 | static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, |
293 | char *buf) | ||
317 | { | 294 | { |
295 | int nr = to_sensor_dev_attr(attr)->index; | ||
318 | struct asb100_data *data = asb100_update_device(dev); | 296 | struct asb100_data *data = asb100_update_device(dev); |
319 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); | 297 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); |
320 | } | 298 | } |
321 | 299 | ||
322 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 300 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
323 | size_t count, int nr) | 301 | const char *buf, size_t count) |
324 | { | 302 | { |
303 | int nr = to_sensor_dev_attr(attr)->index; | ||
325 | struct i2c_client *client = to_i2c_client(dev); | 304 | struct i2c_client *client = to_i2c_client(dev); |
326 | struct asb100_data *data = i2c_get_clientdata(client); | 305 | struct asb100_data *data = i2c_get_clientdata(client); |
327 | u32 val = simple_strtoul(buf, NULL, 10); | 306 | u32 val = simple_strtoul(buf, NULL, 10); |
@@ -337,22 +316,23 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
337 | determined in part by the fan divisor. This follows the principle of | 316 | determined in part by the fan divisor. This follows the principle of |
338 | least surprise; the user doesn't expect the fan minimum to change just | 317 | least surprise; the user doesn't expect the fan minimum to change just |
339 | because the divisor changed. */ | 318 | because the divisor changed. */ |
340 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 319 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
341 | size_t count, int nr) | 320 | const char *buf, size_t count) |
342 | { | 321 | { |
322 | int nr = to_sensor_dev_attr(attr)->index; | ||
343 | struct i2c_client *client = to_i2c_client(dev); | 323 | struct i2c_client *client = to_i2c_client(dev); |
344 | struct asb100_data *data = i2c_get_clientdata(client); | 324 | struct asb100_data *data = i2c_get_clientdata(client); |
345 | unsigned long min; | 325 | unsigned long min; |
346 | unsigned long val = simple_strtoul(buf, NULL, 10); | 326 | unsigned long val = simple_strtoul(buf, NULL, 10); |
347 | int reg; | 327 | int reg; |
348 | 328 | ||
349 | mutex_lock(&data->update_lock); | 329 | mutex_lock(&data->update_lock); |
350 | 330 | ||
351 | min = FAN_FROM_REG(data->fan_min[nr], | 331 | min = FAN_FROM_REG(data->fan_min[nr], |
352 | DIV_FROM_REG(data->fan_div[nr])); | 332 | DIV_FROM_REG(data->fan_div[nr])); |
353 | data->fan_div[nr] = DIV_TO_REG(val); | 333 | data->fan_div[nr] = DIV_TO_REG(val); |
354 | 334 | ||
355 | switch(nr) { | 335 | switch (nr) { |
356 | case 0: /* fan 1 */ | 336 | case 0: /* fan 1 */ |
357 | reg = asb100_read_value(client, ASB100_REG_VID_FANDIV); | 337 | reg = asb100_read_value(client, ASB100_REG_VID_FANDIV); |
358 | reg = (reg & 0xcf) | (data->fan_div[0] << 4); | 338 | reg = (reg & 0xcf) | (data->fan_div[0] << 4); |
@@ -382,34 +362,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
382 | } | 362 | } |
383 | 363 | ||
384 | #define sysfs_fan(offset) \ | 364 | #define sysfs_fan(offset) \ |
385 | static ssize_t show_fan##offset(struct device *dev, struct device_attribute *attr, char *buf) \ | 365 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ |
386 | { \ | 366 | show_fan, NULL, offset - 1); \ |
387 | return show_fan(dev, buf, offset - 1); \ | 367 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
388 | } \ | 368 | show_fan_min, set_fan_min, offset - 1); \ |
389 | static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ | 369 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
390 | { \ | 370 | show_fan_div, set_fan_div, offset - 1) |
391 | return show_fan_min(dev, buf, offset - 1); \ | ||
392 | } \ | ||
393 | static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \ | ||
394 | { \ | ||
395 | return show_fan_div(dev, buf, offset - 1); \ | ||
396 | } \ | ||
397 | static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ | ||
398 | size_t count) \ | ||
399 | { \ | ||
400 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
401 | } \ | ||
402 | static ssize_t set_fan##offset##_div(struct device *dev, struct device_attribute *attr, const char *buf, \ | ||
403 | size_t count) \ | ||
404 | { \ | ||
405 | return set_fan_div(dev, buf, count, offset - 1); \ | ||
406 | } \ | ||
407 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
408 | show_fan##offset, NULL); \ | ||
409 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
410 | show_fan##offset##_min, set_fan##offset##_min); \ | ||
411 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | ||
412 | show_fan##offset##_div, set_fan##offset##_div); | ||
413 | 371 | ||
414 | sysfs_fan(1); | 372 | sysfs_fan(1); |
415 | sysfs_fan(2); | 373 | sysfs_fan(2); |
@@ -430,10 +388,12 @@ static int sprintf_temp_from_reg(u16 reg, char *buf, int nr) | |||
430 | } | 388 | } |
431 | return ret; | 389 | return ret; |
432 | } | 390 | } |
433 | 391 | ||
434 | #define show_temp_reg(reg) \ | 392 | #define show_temp_reg(reg) \ |
435 | static ssize_t show_##reg(struct device *dev, char *buf, int nr) \ | 393 | static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \ |
394 | char *buf) \ | ||
436 | { \ | 395 | { \ |
396 | int nr = to_sensor_dev_attr(attr)->index; \ | ||
437 | struct asb100_data *data = asb100_update_device(dev); \ | 397 | struct asb100_data *data = asb100_update_device(dev); \ |
438 | return sprintf_temp_from_reg(data->reg[nr], buf, nr); \ | 398 | return sprintf_temp_from_reg(data->reg[nr], buf, nr); \ |
439 | } | 399 | } |
@@ -443,9 +403,10 @@ show_temp_reg(temp_max); | |||
443 | show_temp_reg(temp_hyst); | 403 | show_temp_reg(temp_hyst); |
444 | 404 | ||
445 | #define set_temp_reg(REG, reg) \ | 405 | #define set_temp_reg(REG, reg) \ |
446 | static ssize_t set_##reg(struct device *dev, const char *buf, \ | 406 | static ssize_t set_##reg(struct device *dev, struct device_attribute *attr, \ |
447 | size_t count, int nr) \ | 407 | const char *buf, size_t count) \ |
448 | { \ | 408 | { \ |
409 | int nr = to_sensor_dev_attr(attr)->index; \ | ||
449 | struct i2c_client *client = to_i2c_client(dev); \ | 410 | struct i2c_client *client = to_i2c_client(dev); \ |
450 | struct asb100_data *data = i2c_get_clientdata(client); \ | 411 | struct asb100_data *data = i2c_get_clientdata(client); \ |
451 | long val = simple_strtol(buf, NULL, 10); \ | 412 | long val = simple_strtol(buf, NULL, 10); \ |
@@ -469,33 +430,12 @@ set_temp_reg(MAX, temp_max); | |||
469 | set_temp_reg(HYST, temp_hyst); | 430 | set_temp_reg(HYST, temp_hyst); |
470 | 431 | ||
471 | #define sysfs_temp(num) \ | 432 | #define sysfs_temp(num) \ |
472 | static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \ | 433 | static SENSOR_DEVICE_ATTR(temp##num##_input, S_IRUGO, \ |
473 | { \ | 434 | show_temp, NULL, num - 1); \ |
474 | return show_temp(dev, buf, num-1); \ | 435 | static SENSOR_DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \ |
475 | } \ | 436 | show_temp_max, set_temp_max, num - 1); \ |
476 | static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \ | 437 | static SENSOR_DEVICE_ATTR(temp##num##_max_hyst, S_IRUGO | S_IWUSR, \ |
477 | static ssize_t show_temp_max##num(struct device *dev, struct device_attribute *attr, char *buf) \ | 438 | show_temp_hyst, set_temp_hyst, num - 1) |
478 | { \ | ||
479 | return show_temp_max(dev, buf, num-1); \ | ||
480 | } \ | ||
481 | static ssize_t set_temp_max##num(struct device *dev, struct device_attribute *attr, const char *buf, \ | ||
482 | size_t count) \ | ||
483 | { \ | ||
484 | return set_temp_max(dev, buf, count, num-1); \ | ||
485 | } \ | ||
486 | static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \ | ||
487 | show_temp_max##num, set_temp_max##num); \ | ||
488 | static ssize_t show_temp_hyst##num(struct device *dev, struct device_attribute *attr, char *buf) \ | ||
489 | { \ | ||
490 | return show_temp_hyst(dev, buf, num-1); \ | ||
491 | } \ | ||
492 | static ssize_t set_temp_hyst##num(struct device *dev, struct device_attribute *attr, const char *buf, \ | ||
493 | size_t count) \ | ||
494 | { \ | ||
495 | return set_temp_hyst(dev, buf, count, num-1); \ | ||
496 | } \ | ||
497 | static DEVICE_ATTR(temp##num##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
498 | show_temp_hyst##num, set_temp_hyst##num); | ||
499 | 439 | ||
500 | sysfs_temp(1); | 440 | sysfs_temp(1); |
501 | sysfs_temp(2); | 441 | sysfs_temp(2); |
@@ -503,7 +443,8 @@ sysfs_temp(3); | |||
503 | sysfs_temp(4); | 443 | sysfs_temp(4); |
504 | 444 | ||
505 | /* VID */ | 445 | /* VID */ |
506 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | 446 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, |
447 | char *buf) | ||
507 | { | 448 | { |
508 | struct asb100_data *data = asb100_update_device(dev); | 449 | struct asb100_data *data = asb100_update_device(dev); |
509 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | 450 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); |
@@ -512,25 +453,26 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char | |||
512 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | 453 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
513 | 454 | ||
514 | /* VRM */ | 455 | /* VRM */ |
515 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) | 456 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, |
457 | char *buf) | ||
516 | { | 458 | { |
517 | struct asb100_data *data = dev_get_drvdata(dev); | 459 | struct asb100_data *data = dev_get_drvdata(dev); |
518 | return sprintf(buf, "%d\n", data->vrm); | 460 | return sprintf(buf, "%d\n", data->vrm); |
519 | } | 461 | } |
520 | 462 | ||
521 | static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 463 | static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, |
464 | const char *buf, size_t count) | ||
522 | { | 465 | { |
523 | struct i2c_client *client = to_i2c_client(dev); | 466 | struct asb100_data *data = dev_get_drvdata(dev); |
524 | struct asb100_data *data = i2c_get_clientdata(client); | 467 | data->vrm = simple_strtoul(buf, NULL, 10); |
525 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
526 | data->vrm = val; | ||
527 | return count; | 468 | return count; |
528 | } | 469 | } |
529 | 470 | ||
530 | /* Alarms */ | 471 | /* Alarms */ |
531 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); | 472 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); |
532 | 473 | ||
533 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 474 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, |
475 | char *buf) | ||
534 | { | 476 | { |
535 | struct asb100_data *data = asb100_update_device(dev); | 477 | struct asb100_data *data = asb100_update_device(dev); |
536 | return sprintf(buf, "%u\n", data->alarms); | 478 | return sprintf(buf, "%u\n", data->alarms); |
@@ -538,14 +480,35 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
538 | 480 | ||
539 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 481 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
540 | 482 | ||
483 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
484 | char *buf) | ||
485 | { | ||
486 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
487 | struct asb100_data *data = asb100_update_device(dev); | ||
488 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); | ||
489 | } | ||
490 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
491 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
492 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); | ||
493 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
494 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); | ||
495 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); | ||
496 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); | ||
497 | static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11); | ||
498 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
499 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); | ||
500 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); | ||
501 | |||
541 | /* 1 PWM */ | 502 | /* 1 PWM */ |
542 | static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf) | 503 | static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, |
504 | char *buf) | ||
543 | { | 505 | { |
544 | struct asb100_data *data = asb100_update_device(dev); | 506 | struct asb100_data *data = asb100_update_device(dev); |
545 | return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f)); | 507 | return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f)); |
546 | } | 508 | } |
547 | 509 | ||
548 | static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 510 | static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, |
511 | const char *buf, size_t count) | ||
549 | { | 512 | { |
550 | struct i2c_client *client = to_i2c_client(dev); | 513 | struct i2c_client *client = to_i2c_client(dev); |
551 | struct asb100_data *data = i2c_get_clientdata(client); | 514 | struct asb100_data *data = i2c_get_clientdata(client); |
@@ -559,14 +522,15 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const | |||
559 | return count; | 522 | return count; |
560 | } | 523 | } |
561 | 524 | ||
562 | static ssize_t show_pwm_enable1(struct device *dev, struct device_attribute *attr, char *buf) | 525 | static ssize_t show_pwm_enable1(struct device *dev, |
526 | struct device_attribute *attr, char *buf) | ||
563 | { | 527 | { |
564 | struct asb100_data *data = asb100_update_device(dev); | 528 | struct asb100_data *data = asb100_update_device(dev); |
565 | return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0); | 529 | return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0); |
566 | } | 530 | } |
567 | 531 | ||
568 | static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr, const char *buf, | 532 | static ssize_t set_pwm_enable1(struct device *dev, |
569 | size_t count) | 533 | struct device_attribute *attr, const char *buf, size_t count) |
570 | { | 534 | { |
571 | struct i2c_client *client = to_i2c_client(dev); | 535 | struct i2c_client *client = to_i2c_client(dev); |
572 | struct asb100_data *data = i2c_get_clientdata(client); | 536 | struct asb100_data *data = i2c_get_clientdata(client); |
@@ -585,50 +549,62 @@ static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, | |||
585 | show_pwm_enable1, set_pwm_enable1); | 549 | show_pwm_enable1, set_pwm_enable1); |
586 | 550 | ||
587 | static struct attribute *asb100_attributes[] = { | 551 | static struct attribute *asb100_attributes[] = { |
588 | &dev_attr_in0_input.attr, | 552 | &sensor_dev_attr_in0_input.dev_attr.attr, |
589 | &dev_attr_in0_min.attr, | 553 | &sensor_dev_attr_in0_min.dev_attr.attr, |
590 | &dev_attr_in0_max.attr, | 554 | &sensor_dev_attr_in0_max.dev_attr.attr, |
591 | &dev_attr_in1_input.attr, | 555 | &sensor_dev_attr_in1_input.dev_attr.attr, |
592 | &dev_attr_in1_min.attr, | 556 | &sensor_dev_attr_in1_min.dev_attr.attr, |
593 | &dev_attr_in1_max.attr, | 557 | &sensor_dev_attr_in1_max.dev_attr.attr, |
594 | &dev_attr_in2_input.attr, | 558 | &sensor_dev_attr_in2_input.dev_attr.attr, |
595 | &dev_attr_in2_min.attr, | 559 | &sensor_dev_attr_in2_min.dev_attr.attr, |
596 | &dev_attr_in2_max.attr, | 560 | &sensor_dev_attr_in2_max.dev_attr.attr, |
597 | &dev_attr_in3_input.attr, | 561 | &sensor_dev_attr_in3_input.dev_attr.attr, |
598 | &dev_attr_in3_min.attr, | 562 | &sensor_dev_attr_in3_min.dev_attr.attr, |
599 | &dev_attr_in3_max.attr, | 563 | &sensor_dev_attr_in3_max.dev_attr.attr, |
600 | &dev_attr_in4_input.attr, | 564 | &sensor_dev_attr_in4_input.dev_attr.attr, |
601 | &dev_attr_in4_min.attr, | 565 | &sensor_dev_attr_in4_min.dev_attr.attr, |
602 | &dev_attr_in4_max.attr, | 566 | &sensor_dev_attr_in4_max.dev_attr.attr, |
603 | &dev_attr_in5_input.attr, | 567 | &sensor_dev_attr_in5_input.dev_attr.attr, |
604 | &dev_attr_in5_min.attr, | 568 | &sensor_dev_attr_in5_min.dev_attr.attr, |
605 | &dev_attr_in5_max.attr, | 569 | &sensor_dev_attr_in5_max.dev_attr.attr, |
606 | &dev_attr_in6_input.attr, | 570 | &sensor_dev_attr_in6_input.dev_attr.attr, |
607 | &dev_attr_in6_min.attr, | 571 | &sensor_dev_attr_in6_min.dev_attr.attr, |
608 | &dev_attr_in6_max.attr, | 572 | &sensor_dev_attr_in6_max.dev_attr.attr, |
609 | 573 | ||
610 | &dev_attr_fan1_input.attr, | 574 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
611 | &dev_attr_fan1_min.attr, | 575 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
612 | &dev_attr_fan1_div.attr, | 576 | &sensor_dev_attr_fan1_div.dev_attr.attr, |
613 | &dev_attr_fan2_input.attr, | 577 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
614 | &dev_attr_fan2_min.attr, | 578 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
615 | &dev_attr_fan2_div.attr, | 579 | &sensor_dev_attr_fan2_div.dev_attr.attr, |
616 | &dev_attr_fan3_input.attr, | 580 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
617 | &dev_attr_fan3_min.attr, | 581 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
618 | &dev_attr_fan3_div.attr, | 582 | &sensor_dev_attr_fan3_div.dev_attr.attr, |
619 | 583 | ||
620 | &dev_attr_temp1_input.attr, | 584 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
621 | &dev_attr_temp1_max.attr, | 585 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
622 | &dev_attr_temp1_max_hyst.attr, | 586 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, |
623 | &dev_attr_temp2_input.attr, | 587 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
624 | &dev_attr_temp2_max.attr, | 588 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
625 | &dev_attr_temp2_max_hyst.attr, | 589 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, |
626 | &dev_attr_temp3_input.attr, | 590 | &sensor_dev_attr_temp3_input.dev_attr.attr, |
627 | &dev_attr_temp3_max.attr, | 591 | &sensor_dev_attr_temp3_max.dev_attr.attr, |
628 | &dev_attr_temp3_max_hyst.attr, | 592 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, |
629 | &dev_attr_temp4_input.attr, | 593 | &sensor_dev_attr_temp4_input.dev_attr.attr, |
630 | &dev_attr_temp4_max.attr, | 594 | &sensor_dev_attr_temp4_max.dev_attr.attr, |
631 | &dev_attr_temp4_max_hyst.attr, | 595 | &sensor_dev_attr_temp4_max_hyst.dev_attr.attr, |
596 | |||
597 | &sensor_dev_attr_in0_alarm.dev_attr.attr, | ||
598 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | ||
599 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | ||
600 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | ||
601 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
602 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
603 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
604 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
605 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | ||
606 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | ||
607 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | ||
632 | 608 | ||
633 | &dev_attr_cpu0_vid.attr, | 609 | &dev_attr_cpu0_vid.attr, |
634 | &dev_attr_vrm.attr, | 610 | &dev_attr_vrm.attr, |
@@ -656,10 +632,10 @@ static int asb100_attach_adapter(struct i2c_adapter *adapter) | |||
656 | } | 632 | } |
657 | 633 | ||
658 | static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, | 634 | static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, |
659 | int kind, struct i2c_client *new_client) | 635 | int kind, struct i2c_client *client) |
660 | { | 636 | { |
661 | int i, id, err; | 637 | int i, id, err; |
662 | struct asb100_data *data = i2c_get_clientdata(new_client); | 638 | struct asb100_data *data = i2c_get_clientdata(client); |
663 | 639 | ||
664 | data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 640 | data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); |
665 | if (!(data->lm75[0])) { | 641 | if (!(data->lm75[0])) { |
@@ -679,26 +655,26 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, | |||
679 | for (i = 2; i <= 3; i++) { | 655 | for (i = 2; i <= 3; i++) { |
680 | if (force_subclients[i] < 0x48 || | 656 | if (force_subclients[i] < 0x48 || |
681 | force_subclients[i] > 0x4f) { | 657 | force_subclients[i] > 0x4f) { |
682 | dev_err(&new_client->dev, "invalid subclient " | 658 | dev_err(&client->dev, "invalid subclient " |
683 | "address %d; must be 0x48-0x4f\n", | 659 | "address %d; must be 0x48-0x4f\n", |
684 | force_subclients[i]); | 660 | force_subclients[i]); |
685 | err = -ENODEV; | 661 | err = -ENODEV; |
686 | goto ERROR_SC_2; | 662 | goto ERROR_SC_2; |
687 | } | 663 | } |
688 | } | 664 | } |
689 | asb100_write_value(new_client, ASB100_REG_I2C_SUBADDR, | 665 | asb100_write_value(client, ASB100_REG_I2C_SUBADDR, |
690 | (force_subclients[2] & 0x07) | | 666 | (force_subclients[2] & 0x07) | |
691 | ((force_subclients[3] & 0x07) <<4)); | 667 | ((force_subclients[3] & 0x07) << 4)); |
692 | data->lm75[0]->addr = force_subclients[2]; | 668 | data->lm75[0]->addr = force_subclients[2]; |
693 | data->lm75[1]->addr = force_subclients[3]; | 669 | data->lm75[1]->addr = force_subclients[3]; |
694 | } else { | 670 | } else { |
695 | int val = asb100_read_value(new_client, ASB100_REG_I2C_SUBADDR); | 671 | int val = asb100_read_value(client, ASB100_REG_I2C_SUBADDR); |
696 | data->lm75[0]->addr = 0x48 + (val & 0x07); | 672 | data->lm75[0]->addr = 0x48 + (val & 0x07); |
697 | data->lm75[1]->addr = 0x48 + ((val >> 4) & 0x07); | 673 | data->lm75[1]->addr = 0x48 + ((val >> 4) & 0x07); |
698 | } | 674 | } |
699 | 675 | ||
700 | if(data->lm75[0]->addr == data->lm75[1]->addr) { | 676 | if (data->lm75[0]->addr == data->lm75[1]->addr) { |
701 | dev_err(&new_client->dev, "duplicate addresses 0x%x " | 677 | dev_err(&client->dev, "duplicate addresses 0x%x " |
702 | "for subclients\n", data->lm75[0]->addr); | 678 | "for subclients\n", data->lm75[0]->addr); |
703 | err = -ENODEV; | 679 | err = -ENODEV; |
704 | goto ERROR_SC_2; | 680 | goto ERROR_SC_2; |
@@ -708,18 +684,17 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, | |||
708 | i2c_set_clientdata(data->lm75[i], NULL); | 684 | i2c_set_clientdata(data->lm75[i], NULL); |
709 | data->lm75[i]->adapter = adapter; | 685 | data->lm75[i]->adapter = adapter; |
710 | data->lm75[i]->driver = &asb100_driver; | 686 | data->lm75[i]->driver = &asb100_driver; |
711 | data->lm75[i]->flags = 0; | ||
712 | strlcpy(data->lm75[i]->name, "asb100 subclient", I2C_NAME_SIZE); | 687 | strlcpy(data->lm75[i]->name, "asb100 subclient", I2C_NAME_SIZE); |
713 | } | 688 | } |
714 | 689 | ||
715 | if ((err = i2c_attach_client(data->lm75[0]))) { | 690 | if ((err = i2c_attach_client(data->lm75[0]))) { |
716 | dev_err(&new_client->dev, "subclient %d registration " | 691 | dev_err(&client->dev, "subclient %d registration " |
717 | "at address 0x%x failed.\n", i, data->lm75[0]->addr); | 692 | "at address 0x%x failed.\n", i, data->lm75[0]->addr); |
718 | goto ERROR_SC_2; | 693 | goto ERROR_SC_2; |
719 | } | 694 | } |
720 | 695 | ||
721 | if ((err = i2c_attach_client(data->lm75[1]))) { | 696 | if ((err = i2c_attach_client(data->lm75[1]))) { |
722 | dev_err(&new_client->dev, "subclient %d registration " | 697 | dev_err(&client->dev, "subclient %d registration " |
723 | "at address 0x%x failed.\n", i, data->lm75[1]->addr); | 698 | "at address 0x%x failed.\n", i, data->lm75[1]->addr); |
724 | goto ERROR_SC_3; | 699 | goto ERROR_SC_3; |
725 | } | 700 | } |
@@ -740,7 +715,7 @@ ERROR_SC_0: | |||
740 | static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | 715 | static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) |
741 | { | 716 | { |
742 | int err; | 717 | int err; |
743 | struct i2c_client *new_client; | 718 | struct i2c_client *client; |
744 | struct asb100_data *data; | 719 | struct asb100_data *data; |
745 | 720 | ||
746 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 721 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
@@ -760,13 +735,12 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
760 | goto ERROR0; | 735 | goto ERROR0; |
761 | } | 736 | } |
762 | 737 | ||
763 | new_client = &data->client; | 738 | client = &data->client; |
764 | mutex_init(&data->lock); | 739 | mutex_init(&data->lock); |
765 | i2c_set_clientdata(new_client, data); | 740 | i2c_set_clientdata(client, data); |
766 | new_client->addr = address; | 741 | client->addr = address; |
767 | new_client->adapter = adapter; | 742 | client->adapter = adapter; |
768 | new_client->driver = &asb100_driver; | 743 | client->driver = &asb100_driver; |
769 | new_client->flags = 0; | ||
770 | 744 | ||
771 | /* Now, we do the remaining detection. */ | 745 | /* Now, we do the remaining detection. */ |
772 | 746 | ||
@@ -776,15 +750,15 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
776 | bank. */ | 750 | bank. */ |
777 | if (kind < 0) { | 751 | if (kind < 0) { |
778 | 752 | ||
779 | int val1 = asb100_read_value(new_client, ASB100_REG_BANK); | 753 | int val1 = asb100_read_value(client, ASB100_REG_BANK); |
780 | int val2 = asb100_read_value(new_client, ASB100_REG_CHIPMAN); | 754 | int val2 = asb100_read_value(client, ASB100_REG_CHIPMAN); |
781 | 755 | ||
782 | /* If we're in bank 0 */ | 756 | /* If we're in bank 0 */ |
783 | if ( (!(val1 & 0x07)) && | 757 | if ((!(val1 & 0x07)) && |
784 | /* Check for ASB100 ID (low byte) */ | 758 | /* Check for ASB100 ID (low byte) */ |
785 | ( ((!(val1 & 0x80)) && (val2 != 0x94)) || | 759 | (((!(val1 & 0x80)) && (val2 != 0x94)) || |
786 | /* Check for ASB100 ID (high byte ) */ | 760 | /* Check for ASB100 ID (high byte ) */ |
787 | ((val1 & 0x80) && (val2 != 0x06)) ) ) { | 761 | ((val1 & 0x80) && (val2 != 0x06)))) { |
788 | pr_debug("asb100.o: detect failed, " | 762 | pr_debug("asb100.o: detect failed, " |
789 | "bad chip id 0x%02x!\n", val2); | 763 | "bad chip id 0x%02x!\n", val2); |
790 | err = -ENODEV; | 764 | err = -ENODEV; |
@@ -795,19 +769,19 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
795 | 769 | ||
796 | /* We have either had a force parameter, or we have already detected | 770 | /* We have either had a force parameter, or we have already detected |
797 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ | 771 | Winbond. Put it now into bank 0 and Vendor ID High Byte */ |
798 | asb100_write_value(new_client, ASB100_REG_BANK, | 772 | asb100_write_value(client, ASB100_REG_BANK, |
799 | (asb100_read_value(new_client, ASB100_REG_BANK) & 0x78) | 0x80); | 773 | (asb100_read_value(client, ASB100_REG_BANK) & 0x78) | 0x80); |
800 | 774 | ||
801 | /* Determine the chip type. */ | 775 | /* Determine the chip type. */ |
802 | if (kind <= 0) { | 776 | if (kind <= 0) { |
803 | int val1 = asb100_read_value(new_client, ASB100_REG_WCHIPID); | 777 | int val1 = asb100_read_value(client, ASB100_REG_WCHIPID); |
804 | int val2 = asb100_read_value(new_client, ASB100_REG_CHIPMAN); | 778 | int val2 = asb100_read_value(client, ASB100_REG_CHIPMAN); |
805 | 779 | ||
806 | if ((val1 == 0x31) && (val2 == 0x06)) | 780 | if ((val1 == 0x31) && (val2 == 0x06)) |
807 | kind = asb100; | 781 | kind = asb100; |
808 | else { | 782 | else { |
809 | if (kind == 0) | 783 | if (kind == 0) |
810 | dev_warn(&new_client->dev, "ignoring " | 784 | dev_warn(&client->dev, "ignoring " |
811 | "'force' parameter for unknown chip " | 785 | "'force' parameter for unknown chip " |
812 | "at adapter %d, address 0x%02x.\n", | 786 | "at adapter %d, address 0x%02x.\n", |
813 | i2c_adapter_id(adapter), address); | 787 | i2c_adapter_id(adapter), address); |
@@ -817,34 +791,32 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
817 | } | 791 | } |
818 | 792 | ||
819 | /* Fill in remaining client fields and put it into the global list */ | 793 | /* Fill in remaining client fields and put it into the global list */ |
820 | strlcpy(new_client->name, "asb100", I2C_NAME_SIZE); | 794 | strlcpy(client->name, "asb100", I2C_NAME_SIZE); |
821 | data->type = kind; | 795 | data->type = kind; |
822 | |||
823 | data->valid = 0; | ||
824 | mutex_init(&data->update_lock); | 796 | mutex_init(&data->update_lock); |
825 | 797 | ||
826 | /* Tell the I2C layer a new client has arrived */ | 798 | /* Tell the I2C layer a new client has arrived */ |
827 | if ((err = i2c_attach_client(new_client))) | 799 | if ((err = i2c_attach_client(client))) |
828 | goto ERROR1; | 800 | goto ERROR1; |
829 | 801 | ||
830 | /* Attach secondary lm75 clients */ | 802 | /* Attach secondary lm75 clients */ |
831 | if ((err = asb100_detect_subclients(adapter, address, kind, | 803 | if ((err = asb100_detect_subclients(adapter, address, kind, |
832 | new_client))) | 804 | client))) |
833 | goto ERROR2; | 805 | goto ERROR2; |
834 | 806 | ||
835 | /* Initialize the chip */ | 807 | /* Initialize the chip */ |
836 | asb100_init_client(new_client); | 808 | asb100_init_client(client); |
837 | 809 | ||
838 | /* A few vars need to be filled upon startup */ | 810 | /* A few vars need to be filled upon startup */ |
839 | data->fan_min[0] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(0)); | 811 | data->fan_min[0] = asb100_read_value(client, ASB100_REG_FAN_MIN(0)); |
840 | data->fan_min[1] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(1)); | 812 | data->fan_min[1] = asb100_read_value(client, ASB100_REG_FAN_MIN(1)); |
841 | data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2)); | 813 | data->fan_min[2] = asb100_read_value(client, ASB100_REG_FAN_MIN(2)); |
842 | 814 | ||
843 | /* Register sysfs hooks */ | 815 | /* Register sysfs hooks */ |
844 | if ((err = sysfs_create_group(&new_client->dev.kobj, &asb100_group))) | 816 | if ((err = sysfs_create_group(&client->dev.kobj, &asb100_group))) |
845 | goto ERROR3; | 817 | goto ERROR3; |
846 | 818 | ||
847 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 819 | data->hwmon_dev = hwmon_device_register(&client->dev); |
848 | if (IS_ERR(data->hwmon_dev)) { | 820 | if (IS_ERR(data->hwmon_dev)) { |
849 | err = PTR_ERR(data->hwmon_dev); | 821 | err = PTR_ERR(data->hwmon_dev); |
850 | goto ERROR4; | 822 | goto ERROR4; |
@@ -853,14 +825,14 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
853 | return 0; | 825 | return 0; |
854 | 826 | ||
855 | ERROR4: | 827 | ERROR4: |
856 | sysfs_remove_group(&new_client->dev.kobj, &asb100_group); | 828 | sysfs_remove_group(&client->dev.kobj, &asb100_group); |
857 | ERROR3: | 829 | ERROR3: |
858 | i2c_detach_client(data->lm75[1]); | 830 | i2c_detach_client(data->lm75[1]); |
859 | i2c_detach_client(data->lm75[0]); | 831 | i2c_detach_client(data->lm75[0]); |
860 | kfree(data->lm75[1]); | 832 | kfree(data->lm75[1]); |
861 | kfree(data->lm75[0]); | 833 | kfree(data->lm75[0]); |
862 | ERROR2: | 834 | ERROR2: |
863 | i2c_detach_client(new_client); | 835 | i2c_detach_client(client); |
864 | ERROR1: | 836 | ERROR1: |
865 | kfree(data); | 837 | kfree(data); |
866 | ERROR0: | 838 | ERROR0: |
@@ -916,17 +888,17 @@ static int asb100_read_value(struct i2c_client *client, u16 reg) | |||
916 | /* convert from ISA to LM75 I2C addresses */ | 888 | /* convert from ISA to LM75 I2C addresses */ |
917 | switch (reg & 0xff) { | 889 | switch (reg & 0xff) { |
918 | case 0x50: /* TEMP */ | 890 | case 0x50: /* TEMP */ |
919 | res = swab16(i2c_smbus_read_word_data (cl, 0)); | 891 | res = swab16(i2c_smbus_read_word_data(cl, 0)); |
920 | break; | 892 | break; |
921 | case 0x52: /* CONFIG */ | 893 | case 0x52: /* CONFIG */ |
922 | res = i2c_smbus_read_byte_data(cl, 1); | 894 | res = i2c_smbus_read_byte_data(cl, 1); |
923 | break; | 895 | break; |
924 | case 0x53: /* HYST */ | 896 | case 0x53: /* HYST */ |
925 | res = swab16(i2c_smbus_read_word_data (cl, 2)); | 897 | res = swab16(i2c_smbus_read_word_data(cl, 2)); |
926 | break; | 898 | break; |
927 | case 0x55: /* MAX */ | 899 | case 0x55: /* MAX */ |
928 | default: | 900 | default: |
929 | res = swab16(i2c_smbus_read_word_data (cl, 3)); | 901 | res = swab16(i2c_smbus_read_word_data(cl, 3)); |
930 | break; | 902 | break; |
931 | } | 903 | } |
932 | } | 904 | } |
@@ -989,7 +961,7 @@ static void asb100_init_client(struct i2c_client *client) | |||
989 | vid = vid_from_reg(vid, data->vrm); | 961 | vid = vid_from_reg(vid, data->vrm); |
990 | 962 | ||
991 | /* Start monitoring */ | 963 | /* Start monitoring */ |
992 | asb100_write_value(client, ASB100_REG_CONFIG, | 964 | asb100_write_value(client, ASB100_REG_CONFIG, |
993 | (asb100_read_value(client, ASB100_REG_CONFIG) & 0xf7) | 0x01); | 965 | (asb100_read_value(client, ASB100_REG_CONFIG) & 0xf7) | 0x01); |
994 | } | 966 | } |
995 | 967 | ||
@@ -1078,4 +1050,3 @@ MODULE_LICENSE("GPL"); | |||
1078 | 1050 | ||
1079 | module_init(asb100_init); | 1051 | module_init(asb100_init); |
1080 | module_exit(asb100_exit); | 1052 | module_exit(asb100_exit); |
1081 | |||