aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/hdaps.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index 1e5dfc7805e2..c8c84e0819fb 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -60,9 +60,11 @@
60 60
61#define HDAPS_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */ 61#define HDAPS_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */
62#define HDAPS_INPUT_FUZZ 4 /* input event threshold */ 62#define HDAPS_INPUT_FUZZ 4 /* input event threshold */
63#define HDAPS_INPUT_FLAT 4
63 64
64static struct timer_list hdaps_timer; 65static struct timer_list hdaps_timer;
65static struct platform_device *pdev; 66static struct platform_device *pdev;
67static struct input_dev *hdaps_idev;
66static unsigned int hdaps_invert; 68static unsigned int hdaps_invert;
67static u8 km_activity; 69static u8 km_activity;
68static int rest_x; 70static int rest_x;
@@ -309,18 +311,6 @@ static struct device_driver hdaps_driver = {
309 .resume = hdaps_resume 311 .resume = hdaps_resume
310}; 312};
311 313
312/* Input class stuff */
313
314static struct input_dev hdaps_idev = {
315 .name = "hdaps",
316 .evbit = { BIT(EV_ABS) },
317 .absbit = { BIT(ABS_X) | BIT(ABS_Y) },
318 .absmin = { [ABS_X] = -256, [ABS_Y] = -256 },
319 .absmax = { [ABS_X] = 256, [ABS_Y] = 256 },
320 .absfuzz = { [ABS_X] = HDAPS_INPUT_FUZZ, [ABS_Y] = HDAPS_INPUT_FUZZ },
321 .absflat = { [ABS_X] = HDAPS_INPUT_FUZZ, [ABS_Y] = HDAPS_INPUT_FUZZ },
322};
323
324/* 314/*
325 * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem. 315 * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem.
326 */ 316 */
@@ -342,9 +332,9 @@ static void hdaps_mousedev_poll(unsigned long unused)
342 if (__hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y)) 332 if (__hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y))
343 goto out; 333 goto out;
344 334
345 input_report_abs(&hdaps_idev, ABS_X, x - rest_x); 335 input_report_abs(hdaps_idev, ABS_X, x - rest_x);
346 input_report_abs(&hdaps_idev, ABS_Y, y - rest_y); 336 input_report_abs(hdaps_idev, ABS_Y, y - rest_y);
347 input_sync(&hdaps_idev); 337 input_sync(hdaps_idev);
348 338
349 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); 339 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD);
350 340
@@ -564,12 +554,25 @@ static int __init hdaps_init(void)
564 if (ret) 554 if (ret)
565 goto out_device; 555 goto out_device;
566 556
557 hdaps_idev = input_allocate_device();
558 if (!hdaps_idev) {
559 ret = -ENOMEM;
560 goto out_group;
561 }
562
567 /* initial calibrate for the input device */ 563 /* initial calibrate for the input device */
568 hdaps_calibrate(); 564 hdaps_calibrate();
569 565
570 /* initialize the input class */ 566 /* initialize the input class */
571 hdaps_idev.dev = &pdev->dev; 567 hdaps_idev->name = "hdaps";
572 input_register_device(&hdaps_idev); 568 hdaps_idev->cdev.dev = &pdev->dev;
569 hdaps_idev->evbit[0] = BIT(EV_ABS);
570 input_set_abs_params(hdaps_idev, ABS_X,
571 -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
572 input_set_abs_params(hdaps_idev, ABS_X,
573 -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
574
575 input_register_device(hdaps_idev);
573 576
574 /* start up our timer for the input device */ 577 /* start up our timer for the input device */
575 init_timer(&hdaps_timer); 578 init_timer(&hdaps_timer);
@@ -580,6 +583,8 @@ static int __init hdaps_init(void)
580 printk(KERN_INFO "hdaps: driver successfully loaded.\n"); 583 printk(KERN_INFO "hdaps: driver successfully loaded.\n");
581 return 0; 584 return 0;
582 585
586out_group:
587 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
583out_device: 588out_device:
584 platform_device_unregister(pdev); 589 platform_device_unregister(pdev);
585out_driver: 590out_driver:
@@ -594,7 +599,7 @@ out:
594static void __exit hdaps_exit(void) 599static void __exit hdaps_exit(void)
595{ 600{
596 del_timer_sync(&hdaps_timer); 601 del_timer_sync(&hdaps_timer);
597 input_unregister_device(&hdaps_idev); 602 input_unregister_device(hdaps_idev);
598 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group); 603 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
599 platform_device_unregister(pdev); 604 platform_device_unregister(pdev);
600 driver_unregister(&hdaps_driver); 605 driver_unregister(&hdaps_driver);