aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/Kconfig2
-rw-r--r--drivers/hwmon/ams/ams-input.c76
-rw-r--r--drivers/hwmon/ams/ams.h5
-rw-r--r--drivers/hwmon/applesmc.c83
4 files changed, 66 insertions, 100 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 192953b29b28..e8f44b580f0a 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -148,6 +148,7 @@ config SENSORS_K8TEMP
148config SENSORS_AMS 148config SENSORS_AMS
149 tristate "Apple Motion Sensor driver" 149 tristate "Apple Motion Sensor driver"
150 depends on PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL 150 depends on PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL
151 select INPUT_POLLDEV
151 help 152 help
152 Support for the motion sensor included in PowerBooks. Includes 153 Support for the motion sensor included in PowerBooks. Includes
153 implementations for PMU and I2C. 154 implementations for PMU and I2C.
@@ -665,6 +666,7 @@ config SENSORS_APPLESMC
665 depends on INPUT && X86 666 depends on INPUT && X86
666 select NEW_LEDS 667 select NEW_LEDS
667 select LEDS_CLASS 668 select LEDS_CLASS
669 select INPUT_POLLDEV
668 default n 670 default n
669 help 671 help
670 This driver provides support for the Apple System Management 672 This driver provides support for the Apple System Management
diff --git a/drivers/hwmon/ams/ams-input.c b/drivers/hwmon/ams/ams-input.c
index ca7095d96ad0..7b81e0c2c2d9 100644
--- a/drivers/hwmon/ams/ams-input.c
+++ b/drivers/hwmon/ams/ams-input.c
@@ -27,47 +27,32 @@ static unsigned int invert;
27module_param(invert, bool, 0644); 27module_param(invert, bool, 0644);
28MODULE_PARM_DESC(invert, "Invert input data on X and Y axis"); 28MODULE_PARM_DESC(invert, "Invert input data on X and Y axis");
29 29
30static int ams_input_kthread(void *data) 30static void ams_idev_poll(struct input_polled_dev *dev)
31{ 31{
32 struct input_dev *idev = dev->input;
32 s8 x, y, z; 33 s8 x, y, z;
33 34
34 while (!kthread_should_stop()) { 35 mutex_lock(&ams_info.lock);
35 mutex_lock(&ams_info.lock);
36
37 ams_sensors(&x, &y, &z);
38
39 x -= ams_info.xcalib;
40 y -= ams_info.ycalib;
41 z -= ams_info.zcalib;
42
43 input_report_abs(ams_info.idev, ABS_X, invert ? -x : x);
44 input_report_abs(ams_info.idev, ABS_Y, invert ? -y : y);
45 input_report_abs(ams_info.idev, ABS_Z, z);
46 36
47 input_sync(ams_info.idev); 37 ams_sensors(&x, &y, &z);
48 38
49 mutex_unlock(&ams_info.lock); 39 x -= ams_info.xcalib;
40 y -= ams_info.ycalib;
41 z -= ams_info.zcalib;
50 42
51 msleep(25); 43 input_report_abs(idev, ABS_X, invert ? -x : x);
52 } 44 input_report_abs(idev, ABS_Y, invert ? -y : y);
45 input_report_abs(idev, ABS_Z, z);
53 46
54 return 0; 47 input_sync(idev);
55}
56 48
57static int ams_input_open(struct input_dev *dev) 49 mutex_unlock(&ams_info.lock);
58{
59 ams_info.kthread = kthread_run(ams_input_kthread, NULL, "kams");
60 return IS_ERR(ams_info.kthread) ? PTR_ERR(ams_info.kthread) : 0;
61}
62
63static void ams_input_close(struct input_dev *dev)
64{
65 kthread_stop(ams_info.kthread);
66} 50}
67 51
68/* Call with ams_info.lock held! */ 52/* Call with ams_info.lock held! */
69static void ams_input_enable(void) 53static void ams_input_enable(void)
70{ 54{
55 struct input_dev *input;
71 s8 x, y, z; 56 s8 x, y, z;
72 57
73 if (ams_info.idev) 58 if (ams_info.idev)
@@ -78,27 +63,29 @@ static void ams_input_enable(void)
78 ams_info.ycalib = y; 63 ams_info.ycalib = y;
79 ams_info.zcalib = z; 64 ams_info.zcalib = z;
80 65
81 ams_info.idev = input_allocate_device(); 66 ams_info.idev = input_allocate_polled_device();
82 if (!ams_info.idev) 67 if (!ams_info.idev)
83 return; 68 return;
84 69
85 ams_info.idev->name = "Apple Motion Sensor"; 70 ams_info.idev->poll = ams_idev_poll;
86 ams_info.idev->id.bustype = ams_info.bustype; 71 ams_info.idev->poll_interval = 25;
87 ams_info.idev->id.vendor = 0; 72
88 ams_info.idev->open = ams_input_open; 73 input = ams_info.idev->input;
89 ams_info.idev->close = ams_input_close; 74 input->name = "Apple Motion Sensor";
90 ams_info.idev->dev.parent = &ams_info.of_dev->dev; 75 input->id.bustype = ams_info.bustype;
76 input->id.vendor = 0;
77 input->dev.parent = &ams_info.of_dev->dev;
91 78
92 input_set_abs_params(ams_info.idev, ABS_X, -50, 50, 3, 0); 79 input_set_abs_params(input, ABS_X, -50, 50, 3, 0);
93 input_set_abs_params(ams_info.idev, ABS_Y, -50, 50, 3, 0); 80 input_set_abs_params(input, ABS_Y, -50, 50, 3, 0);
94 input_set_abs_params(ams_info.idev, ABS_Z, -50, 50, 3, 0); 81 input_set_abs_params(input, ABS_Z, -50, 50, 3, 0);
95 82
96 set_bit(EV_ABS, ams_info.idev->evbit); 83 set_bit(EV_ABS, input->evbit);
97 set_bit(EV_KEY, ams_info.idev->evbit); 84 set_bit(EV_KEY, input->evbit);
98 set_bit(BTN_TOUCH, ams_info.idev->keybit); 85 set_bit(BTN_TOUCH, input->keybit);
99 86
100 if (input_register_device(ams_info.idev)) { 87 if (input_register_polled_device(ams_info.idev)) {
101 input_free_device(ams_info.idev); 88 input_free_polled_device(ams_info.idev);
102 ams_info.idev = NULL; 89 ams_info.idev = NULL;
103 return; 90 return;
104 } 91 }
@@ -108,7 +95,8 @@ static void ams_input_enable(void)
108static void ams_input_disable(void) 95static void ams_input_disable(void)
109{ 96{
110 if (ams_info.idev) { 97 if (ams_info.idev) {
111 input_unregister_device(ams_info.idev); 98 input_unregister_polled_device(ams_info.idev);
99 input_free_polled_device(ams_info.idev);
112 ams_info.idev = NULL; 100 ams_info.idev = NULL;
113 } 101 }
114} 102}
diff --git a/drivers/hwmon/ams/ams.h b/drivers/hwmon/ams/ams.h
index 240730e6bcde..a6221e5dd984 100644
--- a/drivers/hwmon/ams/ams.h
+++ b/drivers/hwmon/ams/ams.h
@@ -1,5 +1,5 @@
1#include <linux/i2c.h> 1#include <linux/i2c.h>
2#include <linux/input.h> 2#include <linux/input-polldev.h>
3#include <linux/kthread.h> 3#include <linux/kthread.h>
4#include <linux/mutex.h> 4#include <linux/mutex.h>
5#include <linux/spinlock.h> 5#include <linux/spinlock.h>
@@ -52,8 +52,7 @@ struct ams {
52#endif 52#endif
53 53
54 /* Joystick emulation */ 54 /* Joystick emulation */
55 struct task_struct *kthread; 55 struct input_polled_dev *idev;
56 struct input_dev *idev;
57 __u16 bustype; 56 __u16 bustype;
58 57
59 /* calibrated null values */ 58 /* calibrated null values */
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 56213b7f8188..571f49e80277 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -28,7 +28,7 @@
28 28
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/input.h> 31#include <linux/input-polldev.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/timer.h> 34#include <linux/timer.h>
@@ -59,9 +59,9 @@
59 59
60#define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o {alv (6 bytes) */ 60#define LIGHT_SENSOR_LEFT_KEY "ALV0" /* r-o {alv (6 bytes) */
61#define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o {alv (6 bytes) */ 61#define LIGHT_SENSOR_RIGHT_KEY "ALV1" /* r-o {alv (6 bytes) */
62#define BACKLIGHT_KEY "LKSB" /* w-o {lkb (2 bytes) */ 62#define BACKLIGHT_KEY "LKSB" /* w-o {lkb (2 bytes) */
63 63
64#define CLAMSHELL_KEY "MSLD" /* r-o ui8 (unused) */ 64#define CLAMSHELL_KEY "MSLD" /* r-o ui8 (unused) */
65 65
66#define MOTION_SENSOR_X_KEY "MO_X" /* r-o sp78 (2 bytes) */ 66#define MOTION_SENSOR_X_KEY "MO_X" /* r-o sp78 (2 bytes) */
67#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o sp78 (2 bytes) */ 67#define MOTION_SENSOR_Y_KEY "MO_Y" /* r-o sp78 (2 bytes) */
@@ -103,7 +103,7 @@ static const char* fan_speed_keys[] = {
103#define INIT_TIMEOUT_MSECS 5000 /* wait up to 5s for device init ... */ 103#define INIT_TIMEOUT_MSECS 5000 /* wait up to 5s for device init ... */
104#define INIT_WAIT_MSECS 50 /* ... in 50ms increments */ 104#define INIT_WAIT_MSECS 50 /* ... in 50ms increments */
105 105
106#define APPLESMC_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */ 106#define APPLESMC_POLL_INTERVAL 50 /* msecs */
107#define APPLESMC_INPUT_FUZZ 4 /* input event threshold */ 107#define APPLESMC_INPUT_FUZZ 4 /* input event threshold */
108#define APPLESMC_INPUT_FLAT 4 108#define APPLESMC_INPUT_FLAT 4
109 109
@@ -125,8 +125,7 @@ static const int debug;
125static struct platform_device *pdev; 125static struct platform_device *pdev;
126static s16 rest_x; 126static s16 rest_x;
127static s16 rest_y; 127static s16 rest_y;
128static struct timer_list applesmc_timer; 128static struct input_polled_dev *applesmc_idev;
129static struct input_dev *applesmc_idev;
130static struct class_device *hwmon_class_dev; 129static struct class_device *hwmon_class_dev;
131 130
132/* Indicates whether this computer has an accelerometer. */ 131/* Indicates whether this computer has an accelerometer. */
@@ -138,7 +137,7 @@ static unsigned int applesmc_light;
138/* Indicates which temperature sensors set to use. */ 137/* Indicates which temperature sensors set to use. */
139static unsigned int applesmc_temperature_set; 138static unsigned int applesmc_temperature_set;
140 139
141static struct mutex applesmc_lock; 140static DEFINE_MUTEX(applesmc_lock);
142 141
143/* 142/*
144 * Last index written to key_at_index sysfs file, and value to use for all other 143 * Last index written to key_at_index sysfs file, and value to use for all other
@@ -455,27 +454,12 @@ static void applesmc_calibrate(void)
455 rest_x = -rest_x; 454 rest_x = -rest_x;
456} 455}
457 456
458static int applesmc_idev_open(struct input_dev *dev) 457static void applesmc_idev_poll(struct input_polled_dev *dev)
459{
460 add_timer(&applesmc_timer);
461
462 return 0;
463}
464
465static void applesmc_idev_close(struct input_dev *dev)
466{
467 del_timer_sync(&applesmc_timer);
468}
469
470static void applesmc_idev_poll(unsigned long unused)
471{ 458{
459 struct input_dev *idev = dev->input;
472 s16 x, y; 460 s16 x, y;
473 461
474 /* Cannot sleep. Try nonblockingly. If we fail, try again later. */ 462 mutex_lock(&applesmc_lock);
475 if (!mutex_trylock(&applesmc_lock)) {
476 mod_timer(&applesmc_timer, jiffies + APPLESMC_POLL_PERIOD);
477 return;
478 }
479 463
480 if (applesmc_read_motion_sensor(SENSOR_X, &x)) 464 if (applesmc_read_motion_sensor(SENSOR_X, &x))
481 goto out; 465 goto out;
@@ -483,13 +467,11 @@ static void applesmc_idev_poll(unsigned long unused)
483 goto out; 467 goto out;
484 468
485 x = -x; 469 x = -x;
486 input_report_abs(applesmc_idev, ABS_X, x - rest_x); 470 input_report_abs(idev, ABS_X, x - rest_x);
487 input_report_abs(applesmc_idev, ABS_Y, y - rest_y); 471 input_report_abs(idev, ABS_Y, y - rest_y);
488 input_sync(applesmc_idev); 472 input_sync(idev);
489 473
490out: 474out:
491 mod_timer(&applesmc_timer, jiffies + APPLESMC_POLL_PERIOD);
492
493 mutex_unlock(&applesmc_lock); 475 mutex_unlock(&applesmc_lock);
494} 476}
495 477
@@ -821,8 +803,7 @@ static ssize_t applesmc_key_at_index_read_show(struct device *dev,
821 803
822 if (!ret) { 804 if (!ret) {
823 return info[0]; 805 return info[0];
824 } 806 } else {
825 else {
826 return ret; 807 return ret;
827 } 808 }
828} 809}
@@ -1093,6 +1074,7 @@ static int applesmc_dmi_match(const struct dmi_system_id *id)
1093/* Create accelerometer ressources */ 1074/* Create accelerometer ressources */
1094static int applesmc_create_accelerometer(void) 1075static int applesmc_create_accelerometer(void)
1095{ 1076{
1077 struct input_dev *idev;
1096 int ret; 1078 int ret;
1097 1079
1098 ret = sysfs_create_group(&pdev->dev.kobj, 1080 ret = sysfs_create_group(&pdev->dev.kobj,
@@ -1100,40 +1082,37 @@ static int applesmc_create_accelerometer(void)
1100 if (ret) 1082 if (ret)
1101 goto out; 1083 goto out;
1102 1084
1103 applesmc_idev = input_allocate_device(); 1085 applesmc_idev = input_allocate_polled_device();
1104 if (!applesmc_idev) { 1086 if (!applesmc_idev) {
1105 ret = -ENOMEM; 1087 ret = -ENOMEM;
1106 goto out_sysfs; 1088 goto out_sysfs;
1107 } 1089 }
1108 1090
1091 applesmc_idev->poll = applesmc_idev_poll;
1092 applesmc_idev->poll_interval = APPLESMC_POLL_INTERVAL;
1093
1109 /* initial calibrate for the input device */ 1094 /* initial calibrate for the input device */
1110 applesmc_calibrate(); 1095 applesmc_calibrate();
1111 1096
1112 /* initialize the input class */ 1097 /* initialize the input device */
1113 applesmc_idev->name = "applesmc"; 1098 idev = applesmc_idev->input;
1114 applesmc_idev->id.bustype = BUS_HOST; 1099 idev->name = "applesmc";
1115 applesmc_idev->dev.parent = &pdev->dev; 1100 idev->id.bustype = BUS_HOST;
1116 applesmc_idev->evbit[0] = BIT(EV_ABS); 1101 idev->dev.parent = &pdev->dev;
1117 applesmc_idev->open = applesmc_idev_open; 1102 idev->evbit[0] = BIT(EV_ABS);
1118 applesmc_idev->close = applesmc_idev_close; 1103 input_set_abs_params(idev, ABS_X,
1119 input_set_abs_params(applesmc_idev, ABS_X,
1120 -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); 1104 -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
1121 input_set_abs_params(applesmc_idev, ABS_Y, 1105 input_set_abs_params(idev, ABS_Y,
1122 -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); 1106 -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
1123 1107
1124 ret = input_register_device(applesmc_idev); 1108 ret = input_register_polled_device(applesmc_idev);
1125 if (ret) 1109 if (ret)
1126 goto out_idev; 1110 goto out_idev;
1127 1111
1128 /* start up our timer for the input device */
1129 init_timer(&applesmc_timer);
1130 applesmc_timer.function = applesmc_idev_poll;
1131 applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD;
1132
1133 return 0; 1112 return 0;
1134 1113
1135out_idev: 1114out_idev:
1136 input_free_device(applesmc_idev); 1115 input_free_polled_device(applesmc_idev);
1137 1116
1138out_sysfs: 1117out_sysfs:
1139 sysfs_remove_group(&pdev->dev.kobj, &accelerometer_attributes_group); 1118 sysfs_remove_group(&pdev->dev.kobj, &accelerometer_attributes_group);
@@ -1146,8 +1125,8 @@ out:
1146/* Release all ressources used by the accelerometer */ 1125/* Release all ressources used by the accelerometer */
1147static void applesmc_release_accelerometer(void) 1126static void applesmc_release_accelerometer(void)
1148{ 1127{
1149 del_timer_sync(&applesmc_timer); 1128 input_unregister_polled_device(applesmc_idev);
1150 input_unregister_device(applesmc_idev); 1129 input_free_polled_device(applesmc_idev);
1151 sysfs_remove_group(&pdev->dev.kobj, &accelerometer_attributes_group); 1130 sysfs_remove_group(&pdev->dev.kobj, &accelerometer_attributes_group);
1152} 1131}
1153 1132
@@ -1184,8 +1163,6 @@ static int __init applesmc_init(void)
1184 int count; 1163 int count;
1185 int i; 1164 int i;
1186 1165
1187 mutex_init(&applesmc_lock);
1188
1189 if (!dmi_check_system(applesmc_whitelist)) { 1166 if (!dmi_check_system(applesmc_whitelist)) {
1190 printk(KERN_WARNING "applesmc: supported laptop not found!\n"); 1167 printk(KERN_WARNING "applesmc: supported laptop not found!\n");
1191 ret = -ENODEV; 1168 ret = -ENODEV;