diff options
-rw-r--r-- | drivers/hwmon/Kconfig | 2 | ||||
-rw-r--r-- | drivers/hwmon/hp_accel.c | 3 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d.c | 74 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d.h | 5 |
4 files changed, 29 insertions, 55 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index d73f5f473e38..eec7dca6b2f9 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -940,6 +940,7 @@ config SENSORS_HDAPS | |||
940 | config SENSORS_LIS3LV02D | 940 | config SENSORS_LIS3LV02D |
941 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer" | 941 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer" |
942 | depends on ACPI && INPUT | 942 | depends on ACPI && INPUT |
943 | select INPUT_POLLDEV | ||
943 | select NEW_LEDS | 944 | select NEW_LEDS |
944 | select LEDS_CLASS | 945 | select LEDS_CLASS |
945 | default n | 946 | default n |
@@ -967,6 +968,7 @@ config SENSORS_LIS3LV02D | |||
967 | config SENSORS_LIS3_SPI | 968 | config SENSORS_LIS3_SPI |
968 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer (SPI)" | 969 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer (SPI)" |
969 | depends on !ACPI && SPI_MASTER && INPUT | 970 | depends on !ACPI && SPI_MASTER && INPUT |
971 | select INPUT_POLLDEV | ||
970 | default n | 972 | default n |
971 | help | 973 | help |
972 | This driver provides support for the LIS3LV02Dx accelerometer connected | 974 | This driver provides support for the LIS3LV02Dx accelerometer connected |
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c index 0ebd0099e602..92db68ea948a 100644 --- a/drivers/hwmon/hp_accel.c +++ b/drivers/hwmon/hp_accel.c | |||
@@ -27,9 +27,6 @@ | |||
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/input.h> | ||
31 | #include <linux/kthread.h> | ||
32 | #include <linux/semaphore.h> | ||
33 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
34 | #include <linux/wait.h> | 31 | #include <linux/wait.h> |
35 | #include <linux/poll.h> | 32 | #include <linux/poll.h> |
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c index df3f58613f7b..366190609c73 100644 --- a/drivers/hwmon/lis3lv02d.c +++ b/drivers/hwmon/lis3lv02d.c | |||
@@ -27,9 +27,7 @@ | |||
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/input.h> | 30 | #include <linux/input-polldev.h> |
31 | #include <linux/kthread.h> | ||
32 | #include <linux/semaphore.h> | ||
33 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
34 | #include <linux/wait.h> | 32 | #include <linux/wait.h> |
35 | #include <linux/poll.h> | 33 | #include <linux/poll.h> |
@@ -270,43 +268,16 @@ static struct miscdevice lis3lv02d_misc_device = { | |||
270 | .fops = &lis3lv02d_misc_fops, | 268 | .fops = &lis3lv02d_misc_fops, |
271 | }; | 269 | }; |
272 | 270 | ||
273 | /** | 271 | static void lis3lv02d_joystick_poll(struct input_polled_dev *pidev) |
274 | * lis3lv02d_joystick_kthread - Kthread polling function | ||
275 | * @data: unused - here to conform to threadfn prototype | ||
276 | */ | ||
277 | static int lis3lv02d_joystick_kthread(void *data) | ||
278 | { | 272 | { |
279 | int x, y, z; | 273 | int x, y, z; |
280 | 274 | ||
281 | while (!kthread_should_stop()) { | 275 | lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z); |
282 | lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z); | 276 | input_report_abs(pidev->input, ABS_X, x - lis3_dev.xcalib); |
283 | input_report_abs(lis3_dev.idev, ABS_X, x - lis3_dev.xcalib); | 277 | input_report_abs(pidev->input, ABS_Y, y - lis3_dev.ycalib); |
284 | input_report_abs(lis3_dev.idev, ABS_Y, y - lis3_dev.ycalib); | 278 | input_report_abs(pidev->input, ABS_Z, z - lis3_dev.zcalib); |
285 | input_report_abs(lis3_dev.idev, ABS_Z, z - lis3_dev.zcalib); | ||
286 | |||
287 | input_sync(lis3_dev.idev); | ||
288 | |||
289 | try_to_freeze(); | ||
290 | msleep_interruptible(MDPS_POLL_INTERVAL); | ||
291 | } | ||
292 | |||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | static int lis3lv02d_joystick_open(struct input_dev *input) | ||
297 | { | ||
298 | lis3_dev.kthread = kthread_run(lis3lv02d_joystick_kthread, NULL, "klis3lv02d"); | ||
299 | if (IS_ERR(lis3_dev.kthread)) { | ||
300 | return PTR_ERR(lis3_dev.kthread); | ||
301 | } | ||
302 | |||
303 | return 0; | ||
304 | } | 279 | } |
305 | 280 | ||
306 | static void lis3lv02d_joystick_close(struct input_dev *input) | ||
307 | { | ||
308 | kthread_stop(lis3_dev.kthread); | ||
309 | } | ||
310 | 281 | ||
311 | static inline void lis3lv02d_calibrate_joystick(void) | 282 | static inline void lis3lv02d_calibrate_joystick(void) |
312 | { | 283 | { |
@@ -316,33 +287,36 @@ static inline void lis3lv02d_calibrate_joystick(void) | |||
316 | 287 | ||
317 | int lis3lv02d_joystick_enable(void) | 288 | int lis3lv02d_joystick_enable(void) |
318 | { | 289 | { |
290 | struct input_dev *input_dev; | ||
319 | int err; | 291 | int err; |
320 | 292 | ||
321 | if (lis3_dev.idev) | 293 | if (lis3_dev.idev) |
322 | return -EINVAL; | 294 | return -EINVAL; |
323 | 295 | ||
324 | lis3_dev.idev = input_allocate_device(); | 296 | lis3_dev.idev = input_allocate_polled_device(); |
325 | if (!lis3_dev.idev) | 297 | if (!lis3_dev.idev) |
326 | return -ENOMEM; | 298 | return -ENOMEM; |
327 | 299 | ||
300 | lis3_dev.idev->poll = lis3lv02d_joystick_poll; | ||
301 | lis3_dev.idev->poll_interval = MDPS_POLL_INTERVAL; | ||
302 | input_dev = lis3_dev.idev->input; | ||
303 | |||
328 | lis3lv02d_calibrate_joystick(); | 304 | lis3lv02d_calibrate_joystick(); |
329 | 305 | ||
330 | lis3_dev.idev->name = "ST LIS3LV02DL Accelerometer"; | 306 | input_dev->name = "ST LIS3LV02DL Accelerometer"; |
331 | lis3_dev.idev->phys = DRIVER_NAME "/input0"; | 307 | input_dev->phys = DRIVER_NAME "/input0"; |
332 | lis3_dev.idev->id.bustype = BUS_HOST; | 308 | input_dev->id.bustype = BUS_HOST; |
333 | lis3_dev.idev->id.vendor = 0; | 309 | input_dev->id.vendor = 0; |
334 | lis3_dev.idev->dev.parent = &lis3_dev.pdev->dev; | 310 | input_dev->dev.parent = &lis3_dev.pdev->dev; |
335 | lis3_dev.idev->open = lis3lv02d_joystick_open; | ||
336 | lis3_dev.idev->close = lis3lv02d_joystick_close; | ||
337 | 311 | ||
338 | set_bit(EV_ABS, lis3_dev.idev->evbit); | 312 | set_bit(EV_ABS, input_dev->evbit); |
339 | input_set_abs_params(lis3_dev.idev, ABS_X, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); | 313 | input_set_abs_params(input_dev, ABS_X, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); |
340 | input_set_abs_params(lis3_dev.idev, ABS_Y, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); | 314 | input_set_abs_params(input_dev, ABS_Y, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); |
341 | input_set_abs_params(lis3_dev.idev, ABS_Z, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); | 315 | input_set_abs_params(input_dev, ABS_Z, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3); |
342 | 316 | ||
343 | err = input_register_device(lis3_dev.idev); | 317 | err = input_register_polled_device(lis3_dev.idev); |
344 | if (err) { | 318 | if (err) { |
345 | input_free_device(lis3_dev.idev); | 319 | input_free_polled_device(lis3_dev.idev); |
346 | lis3_dev.idev = NULL; | 320 | lis3_dev.idev = NULL; |
347 | } | 321 | } |
348 | 322 | ||
@@ -357,7 +331,7 @@ void lis3lv02d_joystick_disable(void) | |||
357 | 331 | ||
358 | if (lis3_dev.irq) | 332 | if (lis3_dev.irq) |
359 | misc_deregister(&lis3lv02d_misc_device); | 333 | misc_deregister(&lis3lv02d_misc_device); |
360 | input_unregister_device(lis3_dev.idev); | 334 | input_unregister_polled_device(lis3_dev.idev); |
361 | lis3_dev.idev = NULL; | 335 | lis3_dev.idev = NULL; |
362 | } | 336 | } |
363 | EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable); | 337 | EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable); |
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h index b007d8184212..5a5a196e6a66 100644 --- a/drivers/hwmon/lis3lv02d.h +++ b/drivers/hwmon/lis3lv02d.h | |||
@@ -18,6 +18,8 @@ | |||
18 | * along with this program; if not, write to the Free Software | 18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/input-polldev.h> | ||
21 | 23 | ||
22 | /* | 24 | /* |
23 | * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to | 25 | * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to |
@@ -169,8 +171,7 @@ struct lis3lv02d { | |||
169 | s16 (*read_data) (struct lis3lv02d *lis3, int reg); | 171 | s16 (*read_data) (struct lis3lv02d *lis3, int reg); |
170 | int mdps_max_val; | 172 | int mdps_max_val; |
171 | 173 | ||
172 | struct input_dev *idev; /* input device */ | 174 | struct input_polled_dev *idev; /* input device */ |
173 | struct task_struct *kthread; /* kthread for input */ | ||
174 | struct platform_device *pdev; /* platform device */ | 175 | struct platform_device *pdev; /* platform device */ |
175 | atomic_t count; /* interrupt count after last read */ | 176 | atomic_t count; /* interrupt count after last read */ |
176 | int xcalib; /* calibrated null value for x */ | 177 | int xcalib; /* calibrated null value for x */ |