aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/windfarm_pm91.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/macintosh/windfarm_pm91.c')
-rw-r--r--drivers/macintosh/windfarm_pm91.c95
1 files changed, 14 insertions, 81 deletions
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c
index 43243cf7410b..0d6372e96d32 100644
--- a/drivers/macintosh/windfarm_pm91.c
+++ b/drivers/macintosh/windfarm_pm91.c
@@ -458,45 +458,6 @@ static void wf_smu_slots_fans_tick(struct wf_smu_slots_fans_state *st)
458 458
459 459
460/* 460/*
461 * ****** Attributes ******
462 *
463 */
464
465#define BUILD_SHOW_FUNC_FIX(name, data) \
466static ssize_t show_##name(struct device *dev, \
467 struct device_attribute *attr, \
468 char *buf) \
469{ \
470 ssize_t r; \
471 s32 val = 0; \
472 data->ops->get_value(data, &val); \
473 r = sprintf(buf, "%d.%03d", FIX32TOPRINT(val)); \
474 return r; \
475} \
476static DEVICE_ATTR(name,S_IRUGO,show_##name, NULL);
477
478
479#define BUILD_SHOW_FUNC_INT(name, data) \
480static ssize_t show_##name(struct device *dev, \
481 struct device_attribute *attr, \
482 char *buf) \
483{ \
484 s32 val = 0; \
485 data->ops->get_value(data, &val); \
486 return sprintf(buf, "%d", val); \
487} \
488static DEVICE_ATTR(name,S_IRUGO,show_##name, NULL);
489
490BUILD_SHOW_FUNC_INT(cpu_fan, fan_cpu_main);
491BUILD_SHOW_FUNC_INT(hd_fan, fan_hd);
492BUILD_SHOW_FUNC_INT(slots_fan, fan_slots);
493
494BUILD_SHOW_FUNC_FIX(cpu_temp, sensor_cpu_temp);
495BUILD_SHOW_FUNC_FIX(cpu_power, sensor_cpu_power);
496BUILD_SHOW_FUNC_FIX(hd_temp, sensor_hd_temp);
497BUILD_SHOW_FUNC_FIX(slots_power, sensor_slots_power);
498
499/*
500 * ****** Setup / Init / Misc ... ****** 461 * ****** Setup / Init / Misc ... ******
501 * 462 *
502 */ 463 */
@@ -581,10 +542,8 @@ static void wf_smu_new_control(struct wf_control *ct)
581 return; 542 return;
582 543
583 if (fan_cpu_main == NULL && !strcmp(ct->name, "cpu-rear-fan-0")) { 544 if (fan_cpu_main == NULL && !strcmp(ct->name, "cpu-rear-fan-0")) {
584 if (wf_get_control(ct) == 0) { 545 if (wf_get_control(ct) == 0)
585 fan_cpu_main = ct; 546 fan_cpu_main = ct;
586 device_create_file(wf_smu_dev, &dev_attr_cpu_fan);
587 }
588 } 547 }
589 548
590 if (fan_cpu_second == NULL && !strcmp(ct->name, "cpu-rear-fan-1")) { 549 if (fan_cpu_second == NULL && !strcmp(ct->name, "cpu-rear-fan-1")) {
@@ -603,17 +562,13 @@ static void wf_smu_new_control(struct wf_control *ct)
603 } 562 }
604 563
605 if (fan_hd == NULL && !strcmp(ct->name, "drive-bay-fan")) { 564 if (fan_hd == NULL && !strcmp(ct->name, "drive-bay-fan")) {
606 if (wf_get_control(ct) == 0) { 565 if (wf_get_control(ct) == 0)
607 fan_hd = ct; 566 fan_hd = ct;
608 device_create_file(wf_smu_dev, &dev_attr_hd_fan);
609 }
610 } 567 }
611 568
612 if (fan_slots == NULL && !strcmp(ct->name, "slots-fan")) { 569 if (fan_slots == NULL && !strcmp(ct->name, "slots-fan")) {
613 if (wf_get_control(ct) == 0) { 570 if (wf_get_control(ct) == 0)
614 fan_slots = ct; 571 fan_slots = ct;
615 device_create_file(wf_smu_dev, &dev_attr_slots_fan);
616 }
617 } 572 }
618 573
619 if (fan_cpu_main && (fan_cpu_second || fan_cpu_third) && fan_hd && 574 if (fan_cpu_main && (fan_cpu_second || fan_cpu_third) && fan_hd &&
@@ -627,31 +582,23 @@ static void wf_smu_new_sensor(struct wf_sensor *sr)
627 return; 582 return;
628 583
629 if (sensor_cpu_power == NULL && !strcmp(sr->name, "cpu-power")) { 584 if (sensor_cpu_power == NULL && !strcmp(sr->name, "cpu-power")) {
630 if (wf_get_sensor(sr) == 0) { 585 if (wf_get_sensor(sr) == 0)
631 sensor_cpu_power = sr; 586 sensor_cpu_power = sr;
632 device_create_file(wf_smu_dev, &dev_attr_cpu_power);
633 }
634 } 587 }
635 588
636 if (sensor_cpu_temp == NULL && !strcmp(sr->name, "cpu-temp")) { 589 if (sensor_cpu_temp == NULL && !strcmp(sr->name, "cpu-temp")) {
637 if (wf_get_sensor(sr) == 0) { 590 if (wf_get_sensor(sr) == 0)
638 sensor_cpu_temp = sr; 591 sensor_cpu_temp = sr;
639 device_create_file(wf_smu_dev, &dev_attr_cpu_temp);
640 }
641 } 592 }
642 593
643 if (sensor_hd_temp == NULL && !strcmp(sr->name, "hd-temp")) { 594 if (sensor_hd_temp == NULL && !strcmp(sr->name, "hd-temp")) {
644 if (wf_get_sensor(sr) == 0) { 595 if (wf_get_sensor(sr) == 0)
645 sensor_hd_temp = sr; 596 sensor_hd_temp = sr;
646 device_create_file(wf_smu_dev, &dev_attr_hd_temp);
647 }
648 } 597 }
649 598
650 if (sensor_slots_power == NULL && !strcmp(sr->name, "slots-power")) { 599 if (sensor_slots_power == NULL && !strcmp(sr->name, "slots-power")) {
651 if (wf_get_sensor(sr) == 0) { 600 if (wf_get_sensor(sr) == 0)
652 sensor_slots_power = sr; 601 sensor_slots_power = sr;
653 device_create_file(wf_smu_dev, &dev_attr_slots_power);
654 }
655 } 602 }
656 603
657 if (sensor_cpu_power && sensor_cpu_temp && 604 if (sensor_cpu_power && sensor_cpu_temp &&
@@ -720,40 +667,26 @@ static int wf_smu_remove(struct device *ddev)
720 * with that except by adding locks all over... I'll do that 667 * with that except by adding locks all over... I'll do that
721 * eventually but heh, who ever rmmod this module anyway ? 668 * eventually but heh, who ever rmmod this module anyway ?
722 */ 669 */
723 if (sensor_cpu_power) { 670 if (sensor_cpu_power)
724 device_remove_file(wf_smu_dev, &dev_attr_cpu_power);
725 wf_put_sensor(sensor_cpu_power); 671 wf_put_sensor(sensor_cpu_power);
726 } 672 if (sensor_cpu_temp)
727 if (sensor_cpu_temp) {
728 device_remove_file(wf_smu_dev, &dev_attr_cpu_temp);
729 wf_put_sensor(sensor_cpu_temp); 673 wf_put_sensor(sensor_cpu_temp);
730 } 674 if (sensor_hd_temp)
731 if (sensor_hd_temp) {
732 device_remove_file(wf_smu_dev, &dev_attr_hd_temp);
733 wf_put_sensor(sensor_hd_temp); 675 wf_put_sensor(sensor_hd_temp);
734 } 676 if (sensor_slots_power)
735 if (sensor_slots_power) {
736 device_remove_file(wf_smu_dev, &dev_attr_slots_power);
737 wf_put_sensor(sensor_slots_power); 677 wf_put_sensor(sensor_slots_power);
738 }
739 678
740 /* Release all controls */ 679 /* Release all controls */
741 if (fan_cpu_main) { 680 if (fan_cpu_main)
742 device_remove_file(wf_smu_dev, &dev_attr_cpu_fan);
743 wf_put_control(fan_cpu_main); 681 wf_put_control(fan_cpu_main);
744 }
745 if (fan_cpu_second) 682 if (fan_cpu_second)
746 wf_put_control(fan_cpu_second); 683 wf_put_control(fan_cpu_second);
747 if (fan_cpu_third) 684 if (fan_cpu_third)
748 wf_put_control(fan_cpu_third); 685 wf_put_control(fan_cpu_third);
749 if (fan_hd) { 686 if (fan_hd)
750 device_remove_file(wf_smu_dev, &dev_attr_hd_fan);
751 wf_put_control(fan_hd); 687 wf_put_control(fan_hd);
752 } 688 if (fan_slots)
753 if (fan_slots) {
754 device_remove_file(wf_smu_dev, &dev_attr_slots_fan);
755 wf_put_control(fan_slots); 689 wf_put_control(fan_slots);
756 }
757 if (cpufreq_clamp) 690 if (cpufreq_clamp)
758 wf_put_control(cpufreq_clamp); 691 wf_put_control(cpufreq_clamp);
759 692