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