git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vserver 1.9.3
[linux-2.6.git]
/
drivers
/
macintosh
/
therm_adt746x.c
diff --git
a/drivers/macintosh/therm_adt746x.c
b/drivers/macintosh/therm_adt746x.c
index
05bd57a
..
8feba38
100644
(file)
--- a/
drivers/macintosh/therm_adt746x.c
+++ b/
drivers/macintosh/therm_adt746x.c
@@
-28,6
+28,7
@@
#include <asm/system.h>
#include <asm/sections.h>
#include <asm/of_device.h>
#include <asm/system.h>
#include <asm/sections.h>
#include <asm/of_device.h>
+#include <linux/kthread.h>
#undef DEBUG
#undef DEBUG
@@
-53,7
+54,7
@@
MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and Powerbook G4 A
MODULE_LICENSE("GPL");
MODULE_PARM(limit_adjust,"i");
MODULE_LICENSE("GPL");
MODULE_PARM(limit_adjust,"i");
-MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50
°C cpu, 70°C gpu) by N °C
.");
+MODULE_PARM_DESC(limit_adjust,"Adjust maximum temperatures (50
cpu, 70 gpu) by N degrees
.");
MODULE_PARM(fan_speed,"i");
MODULE_PARM_DESC(fan_speed,"Specify fan speed (0-255) when lim < temp < lim+8 (default 128)");
MODULE_PARM(fan_speed,"i");
MODULE_PARM_DESC(fan_speed,"Specify fan speed (0-255) when lim < temp < lim+8 (default 128)");
@@
-70,9
+71,7
@@
static enum {ADT7460, ADT7467} therm_type;
static int therm_bus, therm_address;
static struct of_device * of_dev;
static struct thermostat* thermostat;
static int therm_bus, therm_address;
static struct of_device * of_dev;
static struct thermostat* thermostat;
-static pid_t monitor_thread_id;
-static int monitor_running;
-static struct completion monitor_task_compl;
+static struct task_struct *thread_therm = NULL;
static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno);
static void write_both_fan_speed(struct thermostat *th, int speed);
static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno);
static void write_both_fan_speed(struct thermostat *th, int speed);
@@
-136,13
+135,12
@@
detach_thermostat(struct i2c_adapter *adapter)
th = thermostat;
th = thermostat;
- if (monitor_running) {
- monitor_running = 0;
- wait_for_completion(&monitor_task_compl);
+ if (thread_therm != NULL) {
+ kthread_stop(thread_therm);
}
printk(KERN_INFO "adt746x: Putting max temperatures back from %d, %d, %d,"
}
printk(KERN_INFO "adt746x: Putting max temperatures back from %d, %d, %d,"
- " to %d, %d, %d
, (°C)\n",
+ " to %d, %d, %d
\n",
th->limits[0], th->limits[1], th->limits[2],
th->initial_limits[0], th->initial_limits[1], th->initial_limits[2]);
th->limits[0], th->limits[1], th->limits[2],
th->initial_limits[0], th->initial_limits[1], th->initial_limits[2]);
@@
-178,7
+176,8
@@
static int read_fan_speed(struct thermostat *th, u8 addr)
tmp[0] = read_reg(th, addr + 1);
res = tmp[1] + (tmp[0] << 8);
tmp[0] = read_reg(th, addr + 1);
res = tmp[1] + (tmp[0] << 8);
- return (90000*60)/res;
+ /* "a value of 0xffff means that the fan has stopped" */
+ return (res == 0xffff ? 0 : (90000*60)/res);
}
static void write_both_fan_speed(struct thermostat *th, int speed)
}
static void write_both_fan_speed(struct thermostat *th, int speed)
@@
-237,17
+236,9
@@
static int monitor_task(void *arg)
#ifdef DEBUG
int mfan_speed;
#endif
#ifdef DEBUG
int mfan_speed;
#endif
-
- lock_kernel();
- daemonize("kfand");
- unlock_kernel();
- strcpy(current->comm, "thermostat");
- monitor_running = 1;
-
- while(monitor_running)
+ while(!kthread_should_stop())
{
{
- set_task_state(current, TASK_UNINTERRUPTIBLE);
- schedule_timeout(2*HZ);
+ msleep_interruptible(2000);
/* Check status */
/* local : chip */
/* Check status */
/* local : chip */
@@
-271,14
+262,14
@@
static int monitor_task(void *arg)
int var = temps[i] - lims[i];
if (var > 8) {
if (th->overriding[fan_number] == 0)
int var = temps[i] - lims[i];
if (var > 8) {
if (th->overriding[fan_number] == 0)
- printk(KERN_INFO "adt746x: Limit exceeded by %d
°C
, overriding specified fan speed for %s.\n",
+ printk(KERN_INFO "adt746x: Limit exceeded by %d, overriding specified fan speed for %s.\n",
var, fan_number?"GPU":"CPU");
th->overriding[fan_number] = 1;
write_fan_speed(th, 255, fan_number);
started = 1;
} else if ((!th->overriding[fan_number] || var < 6) && var > 0) {
if (th->overriding[fan_number] == 1)
var, fan_number?"GPU":"CPU");
th->overriding[fan_number] = 1;
write_fan_speed(th, 255, fan_number);
started = 1;
} else if ((!th->overriding[fan_number] || var < 6) && var > 0) {
if (th->overriding[fan_number] == 1)
- printk(KERN_INFO "adt746x: Limit exceeded by %d
°C
, setting speed to specified for %s.\n",
+ printk(KERN_INFO "adt746x: Limit exceeded by %d, setting speed to specified for %s.\n",
var, fan_number?"GPU":"CPU");
th->overriding[fan_number] = 0;
write_fan_speed(th, fan_speed, fan_number);
var, fan_number?"GPU":"CPU");
th->overriding[fan_number] = 0;
write_fan_speed(th, fan_speed, fan_number);
@@
-309,8
+300,8
@@
static int monitor_task(void *arg)
|| temps[1] != th->cached_temp[1]
|| temps[2] != th->cached_temp[2]) {
printk(KERN_INFO "adt746x: Temperature infos:"
|| temps[1] != th->cached_temp[1]
|| temps[2] != th->cached_temp[2]) {
printk(KERN_INFO "adt746x: Temperature infos:"
- " thermostats: %d,%d,%d
°C
;"
- " limits: %d,%d,%d
°C
;"
+ " thermostats: %d,%d,%d;"
+ " limits: %d,%d,%d;"
" fan speed: %d RPM\n",
temps[0], temps[1], temps[2],
lims[0], lims[1], lims[2],
" fan speed: %d RPM\n",
temps[0], temps[1], temps[2],
lims[0], lims[1], lims[2],
@@
-322,7
+313,6
@@
static int monitor_task(void *arg)
#endif
}
#endif
}
- complete_and_exit(&monitor_task_compl, 0);
return 0;
}
return 0;
}
@@
-381,14
+371,14
@@
attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
}
printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d"
}
printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d"
- " to %d, %d, %d
(°C)\n",
+ " to %d, %d, %d
\n",
th->initial_limits[0], th->initial_limits[1], th->initial_limits[2],
th->limits[0], th->limits[1], th->limits[2]);
thermostat = th;
if (i2c_attach_client(&th->clt)) {
th->initial_limits[0], th->initial_limits[1], th->initial_limits[2],
th->limits[0], th->limits[1], th->limits[2]);
thermostat = th;
if (i2c_attach_client(&th->clt)) {
- printk("adt746x: Thermostat failed to attach client !\n");
+ printk(
KERN_INFO
"adt746x: Thermostat failed to attach client !\n");
thermostat = NULL;
kfree(th);
return -ENODEV;
thermostat = NULL;
kfree(th);
return -ENODEV;
@@
-404,10
+394,13
@@
attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
write_both_fan_speed(th, -1);
}
write_both_fan_speed(th, -1);
}
- init_completion(&monitor_task_compl);
-
- monitor_thread_id = kernel_thread(monitor_task, th,
- SIGCHLD | CLONE_KERNEL);
+ thread_therm = kthread_run(monitor_task, th, "kfand");
+
+ if (thread_therm == ERR_PTR(-ENOMEM)) {
+ printk(KERN_INFO "adt746x: Kthread creation failed\n");
+ thread_therm = NULL;
+ return -ENOMEM;
+ }
return 0;
}
return 0;
}
@@
-418,17
+411,21
@@
attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
* choice but implement a bunch of them...
*
*/
* choice but implement a bunch of them...
*
*/
-#define BUILD_SHOW_FUNC_DEG(name, data) \
-static ssize_t show_##name(struct device *dev, char *buf) \
-{ \
- return sprintf(buf, "%d°C\n", data); \
-}
#define BUILD_SHOW_FUNC_INT(name, data) \
static ssize_t show_##name(struct device *dev, char *buf) \
{ \
return sprintf(buf, "%d\n", data); \
}
#define BUILD_SHOW_FUNC_INT(name, data) \
static ssize_t show_##name(struct device *dev, char *buf) \
{ \
return sprintf(buf, "%d\n", data); \
}
+#define BUILD_SHOW_FUNC_FAN(name, data) \
+static ssize_t show_##name(struct device *dev, char *buf) \
+{ \
+ return sprintf(buf, "%d (%d rpm)\n", \
+ thermostat->last_speed[data], \
+ read_fan_speed(thermostat, FAN_SPEED[data]) \
+ ); \
+}
+
#define BUILD_STORE_FUNC_DEG(name, data) \
static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \
{ \
#define BUILD_STORE_FUNC_DEG(name, data) \
static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \
{ \
@@
-449,19
+446,19
@@
static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \
val = simple_strtoul(buf, NULL, 10); \
if (val < 0 || val > 255) \
return -EINVAL; \
val = simple_strtoul(buf, NULL, 10); \
if (val < 0 || val > 255) \
return -EINVAL; \
- printk(KERN_INFO "Setting
fan speed to %d\n", val);
\
+ printk(KERN_INFO "Setting
specified fan speed to %d\n", val);
\
data = val; \
return n; \
}
data = val; \
return n; \
}
-BUILD_SHOW_FUNC_
DEG
(cpu_temperature, (read_reg(thermostat, TEMP_REG[1])))
-BUILD_SHOW_FUNC_
DEG
(gpu_temperature, (read_reg(thermostat, TEMP_REG[2])))
-BUILD_SHOW_FUNC_
DEG
(cpu_limit, thermostat->limits[1])
-BUILD_SHOW_FUNC_
DEG
(gpu_limit, thermostat->limits[2])
+BUILD_SHOW_FUNC_
INT
(cpu_temperature, (read_reg(thermostat, TEMP_REG[1])))
+BUILD_SHOW_FUNC_
INT
(gpu_temperature, (read_reg(thermostat, TEMP_REG[2])))
+BUILD_SHOW_FUNC_
INT
(cpu_limit, thermostat->limits[1])
+BUILD_SHOW_FUNC_
INT
(gpu_limit, thermostat->limits[2])
BUILD_SHOW_FUNC_INT(specified_fan_speed, fan_speed)
BUILD_SHOW_FUNC_INT(specified_fan_speed, fan_speed)
-BUILD_SHOW_FUNC_
INT(cpu_fan_speed, (read_fan_speed(thermostat, FAN_SPEED[0]))
)
-BUILD_SHOW_FUNC_
INT(gpu_fan_speed, (read_fan_speed(thermostat, FAN_SPEED[1]))
)
+BUILD_SHOW_FUNC_
FAN(cpu_fan_speed, 0
)
+BUILD_SHOW_FUNC_
FAN(gpu_fan_speed, 1
)
BUILD_STORE_FUNC_INT(specified_fan_speed,fan_speed)
BUILD_SHOW_FUNC_INT(limit_adjust, limit_adjust)
BUILD_STORE_FUNC_INT(specified_fan_speed,fan_speed)
BUILD_SHOW_FUNC_INT(limit_adjust, limit_adjust)