diff options
Diffstat (limited to 'drivers/macintosh/therm_pm72.c')
-rw-r--r-- | drivers/macintosh/therm_pm72.c | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index e43554e754a4..1e0a69a5e815 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c | |||
@@ -121,6 +121,7 @@ | |||
121 | #include <linux/reboot.h> | 121 | #include <linux/reboot.h> |
122 | #include <linux/kmod.h> | 122 | #include <linux/kmod.h> |
123 | #include <linux/i2c.h> | 123 | #include <linux/i2c.h> |
124 | #include <linux/kthread.h> | ||
124 | #include <asm/prom.h> | 125 | #include <asm/prom.h> |
125 | #include <asm/machdep.h> | 126 | #include <asm/machdep.h> |
126 | #include <asm/io.h> | 127 | #include <asm/io.h> |
@@ -161,7 +162,7 @@ static struct slots_pid_state slots_state; | |||
161 | static int state; | 162 | static int state; |
162 | static int cpu_count; | 163 | static int cpu_count; |
163 | static int cpu_pid_type; | 164 | static int cpu_pid_type; |
164 | static pid_t ctrl_task; | 165 | static struct task_struct *ctrl_task; |
165 | static struct completion ctrl_complete; | 166 | static struct completion ctrl_complete; |
166 | static int critical_state; | 167 | static int critical_state; |
167 | static int rackmac; | 168 | static int rackmac; |
@@ -1156,6 +1157,8 @@ static void do_monitor_cpu_rack(struct cpu_pid_state *state) | |||
1156 | */ | 1157 | */ |
1157 | static int init_cpu_state(struct cpu_pid_state *state, int index) | 1158 | static int init_cpu_state(struct cpu_pid_state *state, int index) |
1158 | { | 1159 | { |
1160 | int err; | ||
1161 | |||
1159 | state->index = index; | 1162 | state->index = index; |
1160 | state->first = 1; | 1163 | state->first = 1; |
1161 | state->rpm = (cpu_pid_type == CPU_PID_TYPE_RACKMAC) ? 4000 : 1000; | 1164 | state->rpm = (cpu_pid_type == CPU_PID_TYPE_RACKMAC) ? 4000 : 1000; |
@@ -1181,18 +1184,21 @@ static int init_cpu_state(struct cpu_pid_state *state, int index) | |||
1181 | DBG("CPU %d Using %d power history entries\n", index, state->count_power); | 1184 | DBG("CPU %d Using %d power history entries\n", index, state->count_power); |
1182 | 1185 | ||
1183 | if (index == 0) { | 1186 | if (index == 0) { |
1184 | device_create_file(&of_dev->dev, &dev_attr_cpu0_temperature); | 1187 | err = device_create_file(&of_dev->dev, &dev_attr_cpu0_temperature); |
1185 | device_create_file(&of_dev->dev, &dev_attr_cpu0_voltage); | 1188 | err |= device_create_file(&of_dev->dev, &dev_attr_cpu0_voltage); |
1186 | device_create_file(&of_dev->dev, &dev_attr_cpu0_current); | 1189 | err |= device_create_file(&of_dev->dev, &dev_attr_cpu0_current); |
1187 | device_create_file(&of_dev->dev, &dev_attr_cpu0_exhaust_fan_rpm); | 1190 | err |= device_create_file(&of_dev->dev, &dev_attr_cpu0_exhaust_fan_rpm); |
1188 | device_create_file(&of_dev->dev, &dev_attr_cpu0_intake_fan_rpm); | 1191 | err |= device_create_file(&of_dev->dev, &dev_attr_cpu0_intake_fan_rpm); |
1189 | } else { | 1192 | } else { |
1190 | device_create_file(&of_dev->dev, &dev_attr_cpu1_temperature); | 1193 | err = device_create_file(&of_dev->dev, &dev_attr_cpu1_temperature); |
1191 | device_create_file(&of_dev->dev, &dev_attr_cpu1_voltage); | 1194 | err |= device_create_file(&of_dev->dev, &dev_attr_cpu1_voltage); |
1192 | device_create_file(&of_dev->dev, &dev_attr_cpu1_current); | 1195 | err |= device_create_file(&of_dev->dev, &dev_attr_cpu1_current); |
1193 | device_create_file(&of_dev->dev, &dev_attr_cpu1_exhaust_fan_rpm); | 1196 | err |= device_create_file(&of_dev->dev, &dev_attr_cpu1_exhaust_fan_rpm); |
1194 | device_create_file(&of_dev->dev, &dev_attr_cpu1_intake_fan_rpm); | 1197 | err |= device_create_file(&of_dev->dev, &dev_attr_cpu1_intake_fan_rpm); |
1195 | } | 1198 | } |
1199 | if (err) | ||
1200 | printk(KERN_WARNING "Failed to create some of the atribute" | ||
1201 | "files for CPU %d\n", index); | ||
1196 | 1202 | ||
1197 | return 0; | 1203 | return 0; |
1198 | fail: | 1204 | fail: |
@@ -1328,6 +1334,7 @@ static int init_backside_state(struct backside_pid_state *state) | |||
1328 | { | 1334 | { |
1329 | struct device_node *u3; | 1335 | struct device_node *u3; |
1330 | int u3h = 1; /* conservative by default */ | 1336 | int u3h = 1; /* conservative by default */ |
1337 | int err; | ||
1331 | 1338 | ||
1332 | /* | 1339 | /* |
1333 | * There are different PID params for machines with U3 and machines | 1340 | * There are different PID params for machines with U3 and machines |
@@ -1379,8 +1386,11 @@ static int init_backside_state(struct backside_pid_state *state) | |||
1379 | if (state->monitor == NULL) | 1386 | if (state->monitor == NULL) |
1380 | return -ENODEV; | 1387 | return -ENODEV; |
1381 | 1388 | ||
1382 | device_create_file(&of_dev->dev, &dev_attr_backside_temperature); | 1389 | err = device_create_file(&of_dev->dev, &dev_attr_backside_temperature); |
1383 | device_create_file(&of_dev->dev, &dev_attr_backside_fan_pwm); | 1390 | err |= device_create_file(&of_dev->dev, &dev_attr_backside_fan_pwm); |
1391 | if (err) | ||
1392 | printk(KERN_WARNING "Failed to create attribute file(s)" | ||
1393 | " for backside fan\n"); | ||
1384 | 1394 | ||
1385 | return 0; | 1395 | return 0; |
1386 | } | 1396 | } |
@@ -1491,6 +1501,8 @@ static void do_monitor_drives(struct drives_pid_state *state) | |||
1491 | */ | 1501 | */ |
1492 | static int init_drives_state(struct drives_pid_state *state) | 1502 | static int init_drives_state(struct drives_pid_state *state) |
1493 | { | 1503 | { |
1504 | int err; | ||
1505 | |||
1494 | state->ticks = 1; | 1506 | state->ticks = 1; |
1495 | state->first = 1; | 1507 | state->first = 1; |
1496 | state->rpm = 1000; | 1508 | state->rpm = 1000; |
@@ -1499,8 +1511,11 @@ static int init_drives_state(struct drives_pid_state *state) | |||
1499 | if (state->monitor == NULL) | 1511 | if (state->monitor == NULL) |
1500 | return -ENODEV; | 1512 | return -ENODEV; |
1501 | 1513 | ||
1502 | device_create_file(&of_dev->dev, &dev_attr_drives_temperature); | 1514 | err = device_create_file(&of_dev->dev, &dev_attr_drives_temperature); |
1503 | device_create_file(&of_dev->dev, &dev_attr_drives_fan_rpm); | 1515 | err |= device_create_file(&of_dev->dev, &dev_attr_drives_fan_rpm); |
1516 | if (err) | ||
1517 | printk(KERN_WARNING "Failed to create attribute file(s)" | ||
1518 | " for drives bay fan\n"); | ||
1504 | 1519 | ||
1505 | return 0; | 1520 | return 0; |
1506 | } | 1521 | } |
@@ -1621,7 +1636,9 @@ static int init_dimms_state(struct dimm_pid_state *state) | |||
1621 | if (state->monitor == NULL) | 1636 | if (state->monitor == NULL) |
1622 | return -ENODEV; | 1637 | return -ENODEV; |
1623 | 1638 | ||
1624 | device_create_file(&of_dev->dev, &dev_attr_dimms_temperature); | 1639 | if (device_create_file(&of_dev->dev, &dev_attr_dimms_temperature)) |
1640 | printk(KERN_WARNING "Failed to create attribute file" | ||
1641 | " for DIMM temperature\n"); | ||
1625 | 1642 | ||
1626 | return 0; | 1643 | return 0; |
1627 | } | 1644 | } |
@@ -1731,6 +1748,8 @@ static void do_monitor_slots(struct slots_pid_state *state) | |||
1731 | */ | 1748 | */ |
1732 | static int init_slots_state(struct slots_pid_state *state) | 1749 | static int init_slots_state(struct slots_pid_state *state) |
1733 | { | 1750 | { |
1751 | int err; | ||
1752 | |||
1734 | state->ticks = 1; | 1753 | state->ticks = 1; |
1735 | state->first = 1; | 1754 | state->first = 1; |
1736 | state->pwm = 50; | 1755 | state->pwm = 50; |
@@ -1739,8 +1758,11 @@ static int init_slots_state(struct slots_pid_state *state) | |||
1739 | if (state->monitor == NULL) | 1758 | if (state->monitor == NULL) |
1740 | return -ENODEV; | 1759 | return -ENODEV; |
1741 | 1760 | ||
1742 | device_create_file(&of_dev->dev, &dev_attr_slots_temperature); | 1761 | err = device_create_file(&of_dev->dev, &dev_attr_slots_temperature); |
1743 | device_create_file(&of_dev->dev, &dev_attr_slots_fan_pwm); | 1762 | err |= device_create_file(&of_dev->dev, &dev_attr_slots_fan_pwm); |
1763 | if (err) | ||
1764 | printk(KERN_WARNING "Failed to create attribute file(s)" | ||
1765 | " for slots bay fan\n"); | ||
1744 | 1766 | ||
1745 | return 0; | 1767 | return 0; |
1746 | } | 1768 | } |
@@ -1779,8 +1801,6 @@ static int call_critical_overtemp(void) | |||
1779 | */ | 1801 | */ |
1780 | static int main_control_loop(void *x) | 1802 | static int main_control_loop(void *x) |
1781 | { | 1803 | { |
1782 | daemonize("kfand"); | ||
1783 | |||
1784 | DBG("main_control_loop started\n"); | 1804 | DBG("main_control_loop started\n"); |
1785 | 1805 | ||
1786 | down(&driver_lock); | 1806 | down(&driver_lock); |
@@ -1956,7 +1976,7 @@ static void start_control_loops(void) | |||
1956 | { | 1976 | { |
1957 | init_completion(&ctrl_complete); | 1977 | init_completion(&ctrl_complete); |
1958 | 1978 | ||
1959 | ctrl_task = kernel_thread(main_control_loop, NULL, SIGCHLD | CLONE_KERNEL); | 1979 | ctrl_task = kthread_run(main_control_loop, NULL, "kfand"); |
1960 | } | 1980 | } |
1961 | 1981 | ||
1962 | /* | 1982 | /* |
@@ -1964,7 +1984,7 @@ static void start_control_loops(void) | |||
1964 | */ | 1984 | */ |
1965 | static void stop_control_loops(void) | 1985 | static void stop_control_loops(void) |
1966 | { | 1986 | { |
1967 | if (ctrl_task != 0) | 1987 | if (ctrl_task) |
1968 | wait_for_completion(&ctrl_complete); | 1988 | wait_for_completion(&ctrl_complete); |
1969 | } | 1989 | } |
1970 | 1990 | ||