diff options
Diffstat (limited to 'drivers/hwmon/w83627ehf.c')
-rw-r--r-- | drivers/hwmon/w83627ehf.c | 239 |
1 files changed, 97 insertions, 142 deletions
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 12d79f5e4900..b6bd5685fd38 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -42,7 +42,9 @@ | |||
42 | #include <linux/i2c.h> | 42 | #include <linux/i2c.h> |
43 | #include <linux/i2c-isa.h> | 43 | #include <linux/i2c-isa.h> |
44 | #include <linux/hwmon.h> | 44 | #include <linux/hwmon.h> |
45 | #include <linux/hwmon-sysfs.h> | ||
45 | #include <linux/err.h> | 46 | #include <linux/err.h> |
47 | #include <linux/mutex.h> | ||
46 | #include <asm/io.h> | 48 | #include <asm/io.h> |
47 | #include "lm75.h" | 49 | #include "lm75.h" |
48 | 50 | ||
@@ -177,9 +179,9 @@ temp1_to_reg(int temp) | |||
177 | struct w83627ehf_data { | 179 | struct w83627ehf_data { |
178 | struct i2c_client client; | 180 | struct i2c_client client; |
179 | struct class_device *class_dev; | 181 | struct class_device *class_dev; |
180 | struct semaphore lock; | 182 | struct mutex lock; |
181 | 183 | ||
182 | struct semaphore update_lock; | 184 | struct mutex update_lock; |
183 | char valid; /* !=0 if following fields are valid */ | 185 | char valid; /* !=0 if following fields are valid */ |
184 | unsigned long last_updated; /* In jiffies */ | 186 | unsigned long last_updated; /* In jiffies */ |
185 | 187 | ||
@@ -230,7 +232,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | |||
230 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 232 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
231 | int res, word_sized = is_word_sized(reg); | 233 | int res, word_sized = is_word_sized(reg); |
232 | 234 | ||
233 | down(&data->lock); | 235 | mutex_lock(&data->lock); |
234 | 236 | ||
235 | w83627ehf_set_bank(client, reg); | 237 | w83627ehf_set_bank(client, reg); |
236 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | 238 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); |
@@ -242,7 +244,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | |||
242 | } | 244 | } |
243 | w83627ehf_reset_bank(client, reg); | 245 | w83627ehf_reset_bank(client, reg); |
244 | 246 | ||
245 | up(&data->lock); | 247 | mutex_unlock(&data->lock); |
246 | 248 | ||
247 | return res; | 249 | return res; |
248 | } | 250 | } |
@@ -252,7 +254,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
252 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 254 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
253 | int word_sized = is_word_sized(reg); | 255 | int word_sized = is_word_sized(reg); |
254 | 256 | ||
255 | down(&data->lock); | 257 | mutex_lock(&data->lock); |
256 | 258 | ||
257 | w83627ehf_set_bank(client, reg); | 259 | w83627ehf_set_bank(client, reg); |
258 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | 260 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); |
@@ -264,7 +266,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | |||
264 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); | 266 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); |
265 | w83627ehf_reset_bank(client, reg); | 267 | w83627ehf_reset_bank(client, reg); |
266 | 268 | ||
267 | up(&data->lock); | 269 | mutex_unlock(&data->lock); |
268 | return 0; | 270 | return 0; |
269 | } | 271 | } |
270 | 272 | ||
@@ -322,7 +324,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
322 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 324 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
323 | int i; | 325 | int i; |
324 | 326 | ||
325 | down(&data->update_lock); | 327 | mutex_lock(&data->update_lock); |
326 | 328 | ||
327 | if (time_after(jiffies, data->last_updated + HZ) | 329 | if (time_after(jiffies, data->last_updated + HZ) |
328 | || !data->valid) { | 330 | || !data->valid) { |
@@ -397,7 +399,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
397 | data->valid = 1; | 399 | data->valid = 1; |
398 | } | 400 | } |
399 | 401 | ||
400 | up(&data->update_lock); | 402 | mutex_unlock(&data->update_lock); |
401 | return data; | 403 | return data; |
402 | } | 404 | } |
403 | 405 | ||
@@ -407,9 +409,12 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | |||
407 | 409 | ||
408 | #define show_fan_reg(reg) \ | 410 | #define show_fan_reg(reg) \ |
409 | static ssize_t \ | 411 | static ssize_t \ |
410 | show_##reg(struct device *dev, char *buf, int nr) \ | 412 | show_##reg(struct device *dev, struct device_attribute *attr, \ |
413 | char *buf) \ | ||
411 | { \ | 414 | { \ |
412 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | 415 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ |
416 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
417 | int nr = sensor_attr->index; \ | ||
413 | return sprintf(buf, "%d\n", \ | 418 | return sprintf(buf, "%d\n", \ |
414 | fan_from_reg(data->reg[nr], \ | 419 | fan_from_reg(data->reg[nr], \ |
415 | div_from_reg(data->fan_div[nr]))); \ | 420 | div_from_reg(data->fan_div[nr]))); \ |
@@ -418,23 +423,28 @@ show_fan_reg(fan); | |||
418 | show_fan_reg(fan_min); | 423 | show_fan_reg(fan_min); |
419 | 424 | ||
420 | static ssize_t | 425 | static ssize_t |
421 | show_fan_div(struct device *dev, char *buf, int nr) | 426 | show_fan_div(struct device *dev, struct device_attribute *attr, |
427 | char *buf) | ||
422 | { | 428 | { |
423 | struct w83627ehf_data *data = w83627ehf_update_device(dev); | 429 | struct w83627ehf_data *data = w83627ehf_update_device(dev); |
424 | return sprintf(buf, "%u\n", | 430 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
425 | div_from_reg(data->fan_div[nr])); | 431 | int nr = sensor_attr->index; |
432 | return sprintf(buf, "%u\n", div_from_reg(data->fan_div[nr])); | ||
426 | } | 433 | } |
427 | 434 | ||
428 | static ssize_t | 435 | static ssize_t |
429 | store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | 436 | store_fan_min(struct device *dev, struct device_attribute *attr, |
437 | const char *buf, size_t count) | ||
430 | { | 438 | { |
431 | struct i2c_client *client = to_i2c_client(dev); | 439 | struct i2c_client *client = to_i2c_client(dev); |
432 | struct w83627ehf_data *data = i2c_get_clientdata(client); | 440 | struct w83627ehf_data *data = i2c_get_clientdata(client); |
441 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
442 | int nr = sensor_attr->index; | ||
433 | unsigned int val = simple_strtoul(buf, NULL, 10); | 443 | unsigned int val = simple_strtoul(buf, NULL, 10); |
434 | unsigned int reg; | 444 | unsigned int reg; |
435 | u8 new_div; | 445 | u8 new_div; |
436 | 446 | ||
437 | down(&data->update_lock); | 447 | mutex_lock(&data->update_lock); |
438 | if (!val) { | 448 | if (!val) { |
439 | /* No min limit, alarm disabled */ | 449 | /* No min limit, alarm disabled */ |
440 | data->fan_min[nr] = 255; | 450 | data->fan_min[nr] = 255; |
@@ -482,63 +492,46 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
482 | } | 492 | } |
483 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], | 493 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], |
484 | data->fan_min[nr]); | 494 | data->fan_min[nr]); |
485 | up(&data->update_lock); | 495 | mutex_unlock(&data->update_lock); |
486 | 496 | ||
487 | return count; | 497 | return count; |
488 | } | 498 | } |
489 | 499 | ||
490 | #define sysfs_fan_offset(offset) \ | 500 | static struct sensor_device_attribute sda_fan_input[] = { |
491 | static ssize_t \ | 501 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), |
492 | show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ | 502 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), |
493 | char *buf) \ | 503 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), |
494 | { \ | 504 | SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3), |
495 | return show_fan(dev, buf, offset-1); \ | 505 | SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4), |
496 | } \ | 506 | }; |
497 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
498 | show_reg_fan_##offset, NULL); | ||
499 | 507 | ||
500 | #define sysfs_fan_min_offset(offset) \ | 508 | static struct sensor_device_attribute sda_fan_min[] = { |
501 | static ssize_t \ | 509 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, |
502 | show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | 510 | store_fan_min, 0), |
503 | char *buf) \ | 511 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, |
504 | { \ | 512 | store_fan_min, 1), |
505 | return show_fan_min(dev, buf, offset-1); \ | 513 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, |
506 | } \ | 514 | store_fan_min, 2), |
507 | static ssize_t \ | 515 | SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, |
508 | store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | 516 | store_fan_min, 3), |
509 | const char *buf, size_t count) \ | 517 | SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, |
510 | { \ | 518 | store_fan_min, 4), |
511 | return store_fan_min(dev, buf, count, offset-1); \ | 519 | }; |
512 | } \ | ||
513 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
514 | show_reg_fan##offset##_min, \ | ||
515 | store_reg_fan##offset##_min); | ||
516 | 520 | ||
517 | #define sysfs_fan_div_offset(offset) \ | 521 | static struct sensor_device_attribute sda_fan_div[] = { |
518 | static ssize_t \ | 522 | SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), |
519 | show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ | 523 | SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), |
520 | char *buf) \ | 524 | SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), |
521 | { \ | 525 | SENSOR_ATTR(fan4_div, S_IRUGO, show_fan_div, NULL, 3), |
522 | return show_fan_div(dev, buf, offset - 1); \ | 526 | SENSOR_ATTR(fan5_div, S_IRUGO, show_fan_div, NULL, 4), |
523 | } \ | 527 | }; |
524 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | 528 | |
525 | show_reg_fan##offset##_div, NULL); | 529 | static void device_create_file_fan(struct device *dev, int i) |
526 | 530 | { | |
527 | sysfs_fan_offset(1); | 531 | device_create_file(dev, &sda_fan_input[i].dev_attr); |
528 | sysfs_fan_min_offset(1); | 532 | device_create_file(dev, &sda_fan_div[i].dev_attr); |
529 | sysfs_fan_div_offset(1); | 533 | device_create_file(dev, &sda_fan_min[i].dev_attr); |
530 | sysfs_fan_offset(2); | 534 | } |
531 | sysfs_fan_min_offset(2); | ||
532 | sysfs_fan_div_offset(2); | ||
533 | sysfs_fan_offset(3); | ||
534 | sysfs_fan_min_offset(3); | ||
535 | sysfs_fan_div_offset(3); | ||
536 | sysfs_fan_offset(4); | ||
537 | sysfs_fan_min_offset(4); | ||
538 | sysfs_fan_div_offset(4); | ||
539 | sysfs_fan_offset(5); | ||
540 | sysfs_fan_min_offset(5); | ||
541 | sysfs_fan_div_offset(5); | ||
542 | 535 | ||
543 | #define show_temp1_reg(reg) \ | 536 | #define show_temp1_reg(reg) \ |
544 | static ssize_t \ | 537 | static ssize_t \ |
@@ -561,27 +554,24 @@ store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ | |||
561 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | 554 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ |
562 | u32 val = simple_strtoul(buf, NULL, 10); \ | 555 | u32 val = simple_strtoul(buf, NULL, 10); \ |
563 | \ | 556 | \ |
564 | down(&data->update_lock); \ | 557 | mutex_lock(&data->update_lock); \ |
565 | data->temp1_##reg = temp1_to_reg(val); \ | 558 | data->temp1_##reg = temp1_to_reg(val); \ |
566 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ | 559 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ |
567 | data->temp1_##reg); \ | 560 | data->temp1_##reg); \ |
568 | up(&data->update_lock); \ | 561 | mutex_unlock(&data->update_lock); \ |
569 | return count; \ | 562 | return count; \ |
570 | } | 563 | } |
571 | store_temp1_reg(OVER, max); | 564 | store_temp1_reg(OVER, max); |
572 | store_temp1_reg(HYST, max_hyst); | 565 | store_temp1_reg(HYST, max_hyst); |
573 | 566 | ||
574 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); | ||
575 | static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, | ||
576 | show_temp1_max, store_temp1_max); | ||
577 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, | ||
578 | show_temp1_max_hyst, store_temp1_max_hyst); | ||
579 | |||
580 | #define show_temp_reg(reg) \ | 567 | #define show_temp_reg(reg) \ |
581 | static ssize_t \ | 568 | static ssize_t \ |
582 | show_##reg (struct device *dev, char *buf, int nr) \ | 569 | show_##reg(struct device *dev, struct device_attribute *attr, \ |
570 | char *buf) \ | ||
583 | { \ | 571 | { \ |
584 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | 572 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ |
573 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
574 | int nr = sensor_attr->index; \ | ||
585 | return sprintf(buf, "%d\n", \ | 575 | return sprintf(buf, "%d\n", \ |
586 | LM75_TEMP_FROM_REG(data->reg[nr])); \ | 576 | LM75_TEMP_FROM_REG(data->reg[nr])); \ |
587 | } | 577 | } |
@@ -591,55 +581,42 @@ show_temp_reg(temp_max_hyst); | |||
591 | 581 | ||
592 | #define store_temp_reg(REG, reg) \ | 582 | #define store_temp_reg(REG, reg) \ |
593 | static ssize_t \ | 583 | static ssize_t \ |
594 | store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | 584 | store_##reg(struct device *dev, struct device_attribute *attr, \ |
585 | const char *buf, size_t count) \ | ||
595 | { \ | 586 | { \ |
596 | struct i2c_client *client = to_i2c_client(dev); \ | 587 | struct i2c_client *client = to_i2c_client(dev); \ |
597 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | 588 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ |
589 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | ||
590 | int nr = sensor_attr->index; \ | ||
598 | u32 val = simple_strtoul(buf, NULL, 10); \ | 591 | u32 val = simple_strtoul(buf, NULL, 10); \ |
599 | \ | 592 | \ |
600 | down(&data->update_lock); \ | 593 | mutex_lock(&data->update_lock); \ |
601 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | 594 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ |
602 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ | 595 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ |
603 | data->reg[nr]); \ | 596 | data->reg[nr]); \ |
604 | up(&data->update_lock); \ | 597 | mutex_unlock(&data->update_lock); \ |
605 | return count; \ | 598 | return count; \ |
606 | } | 599 | } |
607 | store_temp_reg(OVER, temp_max); | 600 | store_temp_reg(OVER, temp_max); |
608 | store_temp_reg(HYST, temp_max_hyst); | 601 | store_temp_reg(HYST, temp_max_hyst); |
609 | 602 | ||
610 | #define sysfs_temp_offset(offset) \ | 603 | static struct sensor_device_attribute sda_temp[] = { |
611 | static ssize_t \ | 604 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0), |
612 | show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ | 605 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0), |
613 | char *buf) \ | 606 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 1), |
614 | { \ | 607 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1_max, |
615 | return show_temp(dev, buf, offset - 2); \ | 608 | store_temp1_max, 0), |
616 | } \ | 609 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, |
617 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | 610 | store_temp_max, 0), |
618 | show_reg_temp##offset, NULL); | 611 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, |
619 | 612 | store_temp_max, 1), | |
620 | #define sysfs_temp_reg_offset(reg, offset) \ | 613 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1_max_hyst, |
621 | static ssize_t \ | 614 | store_temp1_max_hyst, 0), |
622 | show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | 615 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, |
623 | char *buf) \ | 616 | store_temp_max_hyst, 0), |
624 | { \ | 617 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, |
625 | return show_temp_##reg(dev, buf, offset - 2); \ | 618 | store_temp_max_hyst, 1), |
626 | } \ | 619 | }; |
627 | static ssize_t \ | ||
628 | store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
629 | const char *buf, size_t count) \ | ||
630 | { \ | ||
631 | return store_temp_##reg(dev, buf, count, offset - 2); \ | ||
632 | } \ | ||
633 | static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ | ||
634 | show_reg_temp##offset##_##reg, \ | ||
635 | store_reg_temp##offset##_##reg); | ||
636 | |||
637 | sysfs_temp_offset(2); | ||
638 | sysfs_temp_reg_offset(max, 2); | ||
639 | sysfs_temp_reg_offset(max_hyst, 2); | ||
640 | sysfs_temp_offset(3); | ||
641 | sysfs_temp_reg_offset(max, 3); | ||
642 | sysfs_temp_reg_offset(max_hyst, 3); | ||
643 | 620 | ||
644 | /* | 621 | /* |
645 | * Driver and client management | 622 | * Driver and client management |
@@ -673,6 +650,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
673 | { | 650 | { |
674 | struct i2c_client *client; | 651 | struct i2c_client *client; |
675 | struct w83627ehf_data *data; | 652 | struct w83627ehf_data *data; |
653 | struct device *dev; | ||
676 | int i, err = 0; | 654 | int i, err = 0; |
677 | 655 | ||
678 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, | 656 | if (!request_region(address + REGION_OFFSET, REGION_LENGTH, |
@@ -689,14 +667,15 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
689 | client = &data->client; | 667 | client = &data->client; |
690 | i2c_set_clientdata(client, data); | 668 | i2c_set_clientdata(client, data); |
691 | client->addr = address; | 669 | client->addr = address; |
692 | init_MUTEX(&data->lock); | 670 | mutex_init(&data->lock); |
693 | client->adapter = adapter; | 671 | client->adapter = adapter; |
694 | client->driver = &w83627ehf_driver; | 672 | client->driver = &w83627ehf_driver; |
695 | client->flags = 0; | 673 | client->flags = 0; |
674 | dev = &client->dev; | ||
696 | 675 | ||
697 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); | 676 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); |
698 | data->valid = 0; | 677 | data->valid = 0; |
699 | init_MUTEX(&data->update_lock); | 678 | mutex_init(&data->update_lock); |
700 | 679 | ||
701 | /* Tell the i2c layer a new client has arrived */ | 680 | /* Tell the i2c layer a new client has arrived */ |
702 | if ((err = i2c_attach_client(client))) | 681 | if ((err = i2c_attach_client(client))) |
@@ -720,42 +699,18 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) | |||
720 | data->has_fan |= (1 << 4); | 699 | data->has_fan |= (1 << 4); |
721 | 700 | ||
722 | /* Register sysfs hooks */ | 701 | /* Register sysfs hooks */ |
723 | data->class_dev = hwmon_device_register(&client->dev); | 702 | data->class_dev = hwmon_device_register(dev); |
724 | if (IS_ERR(data->class_dev)) { | 703 | if (IS_ERR(data->class_dev)) { |
725 | err = PTR_ERR(data->class_dev); | 704 | err = PTR_ERR(data->class_dev); |
726 | goto exit_detach; | 705 | goto exit_detach; |
727 | } | 706 | } |
728 | 707 | ||
729 | device_create_file(&client->dev, &dev_attr_fan1_input); | 708 | for (i = 0; i < 5; i++) { |
730 | device_create_file(&client->dev, &dev_attr_fan1_min); | 709 | if (data->has_fan & (1 << i)) |
731 | device_create_file(&client->dev, &dev_attr_fan1_div); | 710 | device_create_file_fan(dev, i); |
732 | device_create_file(&client->dev, &dev_attr_fan2_input); | ||
733 | device_create_file(&client->dev, &dev_attr_fan2_min); | ||
734 | device_create_file(&client->dev, &dev_attr_fan2_div); | ||
735 | device_create_file(&client->dev, &dev_attr_fan3_input); | ||
736 | device_create_file(&client->dev, &dev_attr_fan3_min); | ||
737 | device_create_file(&client->dev, &dev_attr_fan3_div); | ||
738 | |||
739 | if (data->has_fan & (1 << 3)) { | ||
740 | device_create_file(&client->dev, &dev_attr_fan4_input); | ||
741 | device_create_file(&client->dev, &dev_attr_fan4_min); | ||
742 | device_create_file(&client->dev, &dev_attr_fan4_div); | ||
743 | } | ||
744 | if (data->has_fan & (1 << 4)) { | ||
745 | device_create_file(&client->dev, &dev_attr_fan5_input); | ||
746 | device_create_file(&client->dev, &dev_attr_fan5_min); | ||
747 | device_create_file(&client->dev, &dev_attr_fan5_div); | ||
748 | } | 711 | } |
749 | 712 | for (i = 0; i < ARRAY_SIZE(sda_temp); i++) | |
750 | device_create_file(&client->dev, &dev_attr_temp1_input); | 713 | device_create_file(dev, &sda_temp[i].dev_attr); |
751 | device_create_file(&client->dev, &dev_attr_temp1_max); | ||
752 | device_create_file(&client->dev, &dev_attr_temp1_max_hyst); | ||
753 | device_create_file(&client->dev, &dev_attr_temp2_input); | ||
754 | device_create_file(&client->dev, &dev_attr_temp2_max); | ||
755 | device_create_file(&client->dev, &dev_attr_temp2_max_hyst); | ||
756 | device_create_file(&client->dev, &dev_attr_temp3_input); | ||
757 | device_create_file(&client->dev, &dev_attr_temp3_max); | ||
758 | device_create_file(&client->dev, &dev_attr_temp3_max_hyst); | ||
759 | 714 | ||
760 | return 0; | 715 | return 0; |
761 | 716 | ||