diff options
Diffstat (limited to 'drivers/hwmon/hdaps.c')
-rw-r--r-- | drivers/hwmon/hdaps.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 1e5dfc7805e2..23a9e1ea8e32 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; |
@@ -284,7 +286,7 @@ out: | |||
284 | 286 | ||
285 | /* Device model stuff */ | 287 | /* Device model stuff */ |
286 | 288 | ||
287 | static int hdaps_probe(struct device *dev) | 289 | static int hdaps_probe(struct platform_device *dev) |
288 | { | 290 | { |
289 | int ret; | 291 | int ret; |
290 | 292 | ||
@@ -296,29 +298,18 @@ static int hdaps_probe(struct device *dev) | |||
296 | return 0; | 298 | return 0; |
297 | } | 299 | } |
298 | 300 | ||
299 | static int hdaps_resume(struct device *dev) | 301 | static int hdaps_resume(struct platform_device *dev) |
300 | { | 302 | { |
301 | return hdaps_device_init(); | 303 | return hdaps_device_init(); |
302 | } | 304 | } |
303 | 305 | ||
304 | static struct device_driver hdaps_driver = { | 306 | static struct platform_driver hdaps_driver = { |
305 | .name = "hdaps", | ||
306 | .bus = &platform_bus_type, | ||
307 | .owner = THIS_MODULE, | ||
308 | .probe = hdaps_probe, | 307 | .probe = hdaps_probe, |
309 | .resume = hdaps_resume | 308 | .resume = hdaps_resume, |
310 | }; | 309 | .driver = { |
311 | 310 | .name = "hdaps", | |
312 | /* Input class stuff */ | 311 | .owner = THIS_MODULE, |
313 | 312 | }, | |
314 | static 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 | }; | 313 | }; |
323 | 314 | ||
324 | /* | 315 | /* |
@@ -342,9 +333,9 @@ static void hdaps_mousedev_poll(unsigned long unused) | |||
342 | 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)) |
343 | goto out; | 334 | goto out; |
344 | 335 | ||
345 | input_report_abs(&hdaps_idev, ABS_X, x - rest_x); | 336 | input_report_abs(hdaps_idev, ABS_X, x - rest_x); |
346 | input_report_abs(&hdaps_idev, ABS_Y, y - rest_y); | 337 | input_report_abs(hdaps_idev, ABS_Y, y - rest_y); |
347 | input_sync(&hdaps_idev); | 338 | input_sync(hdaps_idev); |
348 | 339 | ||
349 | mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); | 340 | mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); |
350 | 341 | ||
@@ -550,7 +541,7 @@ static int __init hdaps_init(void) | |||
550 | goto out; | 541 | goto out; |
551 | } | 542 | } |
552 | 543 | ||
553 | ret = driver_register(&hdaps_driver); | 544 | ret = platform_driver_register(&hdaps_driver); |
554 | if (ret) | 545 | if (ret) |
555 | goto out_region; | 546 | goto out_region; |
556 | 547 | ||
@@ -564,12 +555,25 @@ static int __init hdaps_init(void) | |||
564 | if (ret) | 555 | if (ret) |
565 | goto out_device; | 556 | goto out_device; |
566 | 557 | ||
558 | hdaps_idev = input_allocate_device(); | ||
559 | if (!hdaps_idev) { | ||
560 | ret = -ENOMEM; | ||
561 | goto out_group; | ||
562 | } | ||
563 | |||
567 | /* initial calibrate for the input device */ | 564 | /* initial calibrate for the input device */ |
568 | hdaps_calibrate(); | 565 | hdaps_calibrate(); |
569 | 566 | ||
570 | /* initialize the input class */ | 567 | /* initialize the input class */ |
571 | hdaps_idev.dev = &pdev->dev; | 568 | hdaps_idev->name = "hdaps"; |
572 | 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_Y, | ||
574 | -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT); | ||
575 | |||
576 | input_register_device(hdaps_idev); | ||
573 | 577 | ||
574 | /* start up our timer for the input device */ | 578 | /* start up our timer for the input device */ |
575 | init_timer(&hdaps_timer); | 579 | init_timer(&hdaps_timer); |
@@ -580,10 +584,12 @@ static int __init hdaps_init(void) | |||
580 | printk(KERN_INFO "hdaps: driver successfully loaded.\n"); | 584 | printk(KERN_INFO "hdaps: driver successfully loaded.\n"); |
581 | return 0; | 585 | return 0; |
582 | 586 | ||
587 | out_group: | ||
588 | sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group); | ||
583 | out_device: | 589 | out_device: |
584 | platform_device_unregister(pdev); | 590 | platform_device_unregister(pdev); |
585 | out_driver: | 591 | out_driver: |
586 | driver_unregister(&hdaps_driver); | 592 | platform_driver_unregister(&hdaps_driver); |
587 | out_region: | 593 | out_region: |
588 | release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS); | 594 | release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS); |
589 | out: | 595 | out: |
@@ -594,10 +600,10 @@ out: | |||
594 | static void __exit hdaps_exit(void) | 600 | static void __exit hdaps_exit(void) |
595 | { | 601 | { |
596 | del_timer_sync(&hdaps_timer); | 602 | del_timer_sync(&hdaps_timer); |
597 | input_unregister_device(&hdaps_idev); | 603 | input_unregister_device(hdaps_idev); |
598 | sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group); | 604 | sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group); |
599 | platform_device_unregister(pdev); | 605 | platform_device_unregister(pdev); |
600 | driver_unregister(&hdaps_driver); | 606 | platform_driver_unregister(&hdaps_driver); |
601 | release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS); | 607 | release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS); |
602 | 608 | ||
603 | printk(KERN_INFO "hdaps: driver unloaded.\n"); | 609 | printk(KERN_INFO "hdaps: driver unloaded.\n"); |