diff options
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/gameport/gameport.c | 12 | ||||
-rw-r--r-- | drivers/input/input.c | 63 | ||||
-rw-r--r-- | drivers/input/joystick/warrior.c | 2 | ||||
-rw-r--r-- | drivers/input/keyboard/atkbd.c | 99 | ||||
-rw-r--r-- | drivers/input/keyboard/corgikbd.c | 29 | ||||
-rw-r--r-- | drivers/input/keyboard/spitzkbd.c | 29 | ||||
-rw-r--r-- | drivers/input/misc/Kconfig | 12 | ||||
-rw-r--r-- | drivers/input/misc/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/misc/uinput.c | 325 | ||||
-rw-r--r-- | drivers/input/misc/wistron_btns.c | 561 | ||||
-rw-r--r-- | drivers/input/mouse/alps.c | 2 | ||||
-rw-r--r-- | drivers/input/mouse/sermouse.c | 2 | ||||
-rw-r--r-- | drivers/input/serio/i8042.c | 19 | ||||
-rw-r--r-- | drivers/input/serio/i8042.h | 2 | ||||
-rw-r--r-- | drivers/input/serio/rpckbd.c | 21 | ||||
-rw-r--r-- | drivers/input/serio/serio.c | 12 | ||||
-rw-r--r-- | drivers/input/touchscreen/corgi_ts.c | 32 |
17 files changed, 936 insertions, 287 deletions
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index 0506934244f0..caac6d63d46f 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c | |||
@@ -339,14 +339,20 @@ static struct gameport_event *gameport_get_event(void) | |||
339 | return event; | 339 | return event; |
340 | } | 340 | } |
341 | 341 | ||
342 | static void gameport_handle_events(void) | 342 | static void gameport_handle_event(void) |
343 | { | 343 | { |
344 | struct gameport_event *event; | 344 | struct gameport_event *event; |
345 | struct gameport_driver *gameport_drv; | 345 | struct gameport_driver *gameport_drv; |
346 | 346 | ||
347 | down(&gameport_sem); | 347 | down(&gameport_sem); |
348 | 348 | ||
349 | while ((event = gameport_get_event())) { | 349 | /* |
350 | * Note that we handle only one event here to give swsusp | ||
351 | * a chance to freeze kgameportd thread. Gameport events | ||
352 | * should be pretty rare so we are not concerned about | ||
353 | * taking performance hit. | ||
354 | */ | ||
355 | if ((event = gameport_get_event())) { | ||
350 | 356 | ||
351 | switch (event->type) { | 357 | switch (event->type) { |
352 | case GAMEPORT_REGISTER_PORT: | 358 | case GAMEPORT_REGISTER_PORT: |
@@ -433,7 +439,7 @@ static struct gameport *gameport_get_pending_child(struct gameport *parent) | |||
433 | static int gameport_thread(void *nothing) | 439 | static int gameport_thread(void *nothing) |
434 | { | 440 | { |
435 | do { | 441 | do { |
436 | gameport_handle_events(); | 442 | gameport_handle_event(); |
437 | wait_event_interruptible(gameport_wait, | 443 | wait_event_interruptible(gameport_wait, |
438 | kthread_should_stop() || !list_empty(&gameport_event_list)); | 444 | kthread_should_stop() || !list_empty(&gameport_event_list)); |
439 | try_to_freeze(); | 445 | try_to_freeze(); |
diff --git a/drivers/input/input.c b/drivers/input/input.c index c8ae2bb054e0..bdd2a7fc268d 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -536,7 +536,7 @@ static struct attribute *input_dev_attrs[] = { | |||
536 | NULL | 536 | NULL |
537 | }; | 537 | }; |
538 | 538 | ||
539 | static struct attribute_group input_dev_group = { | 539 | static struct attribute_group input_dev_attr_group = { |
540 | .attrs = input_dev_attrs, | 540 | .attrs = input_dev_attrs, |
541 | }; | 541 | }; |
542 | 542 | ||
@@ -717,35 +717,14 @@ struct input_dev *input_allocate_device(void) | |||
717 | return dev; | 717 | return dev; |
718 | } | 718 | } |
719 | 719 | ||
720 | static void input_register_classdevice(struct input_dev *dev) | ||
721 | { | ||
722 | static atomic_t input_no = ATOMIC_INIT(0); | ||
723 | const char *path; | ||
724 | |||
725 | __module_get(THIS_MODULE); | ||
726 | |||
727 | dev->dev = dev->cdev.dev; | ||
728 | |||
729 | snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id), | ||
730 | "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1); | ||
731 | |||
732 | path = kobject_get_path(&dev->cdev.class->subsys.kset.kobj, GFP_KERNEL); | ||
733 | printk(KERN_INFO "input: %s as %s/%s\n", | ||
734 | dev->name ? dev->name : "Unspecified device", | ||
735 | path ? path : "", dev->cdev.class_id); | ||
736 | kfree(path); | ||
737 | |||
738 | class_device_add(&dev->cdev); | ||
739 | sysfs_create_group(&dev->cdev.kobj, &input_dev_group); | ||
740 | sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group); | ||
741 | sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group); | ||
742 | } | ||
743 | |||
744 | int input_register_device(struct input_dev *dev) | 720 | int input_register_device(struct input_dev *dev) |
745 | { | 721 | { |
722 | static atomic_t input_no = ATOMIC_INIT(0); | ||
746 | struct input_handle *handle; | 723 | struct input_handle *handle; |
747 | struct input_handler *handler; | 724 | struct input_handler *handler; |
748 | struct input_device_id *id; | 725 | struct input_device_id *id; |
726 | const char *path; | ||
727 | int error; | ||
749 | 728 | ||
750 | if (!dev->dynalloc) { | 729 | if (!dev->dynalloc) { |
751 | printk(KERN_WARNING "input: device %s is statically allocated, will not register\n" | 730 | printk(KERN_WARNING "input: device %s is statically allocated, will not register\n" |
@@ -773,7 +752,32 @@ int input_register_device(struct input_dev *dev) | |||
773 | INIT_LIST_HEAD(&dev->h_list); | 752 | INIT_LIST_HEAD(&dev->h_list); |
774 | list_add_tail(&dev->node, &input_dev_list); | 753 | list_add_tail(&dev->node, &input_dev_list); |
775 | 754 | ||
776 | input_register_classdevice(dev); | 755 | dev->cdev.class = &input_class; |
756 | snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id), | ||
757 | "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1); | ||
758 | |||
759 | error = class_device_add(&dev->cdev); | ||
760 | if (error) | ||
761 | return error; | ||
762 | |||
763 | error = sysfs_create_group(&dev->cdev.kobj, &input_dev_attr_group); | ||
764 | if (error) | ||
765 | goto fail1; | ||
766 | |||
767 | error = sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group); | ||
768 | if (error) | ||
769 | goto fail2; | ||
770 | |||
771 | error = sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group); | ||
772 | if (error) | ||
773 | goto fail3; | ||
774 | |||
775 | __module_get(THIS_MODULE); | ||
776 | |||
777 | path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL); | ||
778 | printk(KERN_INFO "input: %s as %s\n", | ||
779 | dev->name ? dev->name : "Unspecified device", path ? path : "N/A"); | ||
780 | kfree(path); | ||
777 | 781 | ||
778 | list_for_each_entry(handler, &input_handler_list, node) | 782 | list_for_each_entry(handler, &input_handler_list, node) |
779 | if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) | 783 | if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) |
@@ -784,6 +788,11 @@ int input_register_device(struct input_dev *dev) | |||
784 | input_wakeup_procfs_readers(); | 788 | input_wakeup_procfs_readers(); |
785 | 789 | ||
786 | return 0; | 790 | return 0; |
791 | |||
792 | fail3: sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); | ||
793 | fail2: sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group); | ||
794 | fail1: class_device_del(&dev->cdev); | ||
795 | return error; | ||
787 | } | 796 | } |
788 | 797 | ||
789 | void input_unregister_device(struct input_dev *dev) | 798 | void input_unregister_device(struct input_dev *dev) |
@@ -805,7 +814,7 @@ void input_unregister_device(struct input_dev *dev) | |||
805 | 814 | ||
806 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); | 815 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); |
807 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); | 816 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); |
808 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_group); | 817 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group); |
809 | class_device_unregister(&dev->cdev); | 818 | class_device_unregister(&dev->cdev); |
810 | 819 | ||
811 | input_wakeup_procfs_readers(); | 820 | input_wakeup_procfs_readers(); |
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c index 99a642d2a1fe..1849b176cf18 100644 --- a/drivers/input/joystick/warrior.c +++ b/drivers/input/joystick/warrior.c | |||
@@ -172,7 +172,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv) | |||
172 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 8); | 172 | input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 8); |
173 | input_set_abs_params(input_dev, ABS_THROTTLE, -112, 112, 0, 0); | 173 | input_set_abs_params(input_dev, ABS_THROTTLE, -112, 112, 0, 0); |
174 | input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0); | 174 | input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0); |
175 | input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0); | 175 | input_set_abs_params(input_dev, ABS_HAT0Y, -1, 1, 0, 0); |
176 | 176 | ||
177 | serio_set_drvdata(serio, warrior); | 177 | serio_set_drvdata(serio, warrior); |
178 | 178 | ||
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 820c7fd9a604..a0256f8de8ef 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -166,6 +166,9 @@ static unsigned char atkbd_unxlate_table[128] = { | |||
166 | 166 | ||
167 | #define ATKBD_SPECIAL 248 | 167 | #define ATKBD_SPECIAL 248 |
168 | 168 | ||
169 | #define ATKBD_LED_EVENT_BIT 0 | ||
170 | #define ATKBD_REP_EVENT_BIT 1 | ||
171 | |||
169 | static struct { | 172 | static struct { |
170 | unsigned char keycode; | 173 | unsigned char keycode; |
171 | unsigned char set2; | 174 | unsigned char set2; |
@@ -211,6 +214,10 @@ struct atkbd { | |||
211 | unsigned char err_xl; | 214 | unsigned char err_xl; |
212 | unsigned int last; | 215 | unsigned int last; |
213 | unsigned long time; | 216 | unsigned long time; |
217 | |||
218 | struct work_struct event_work; | ||
219 | struct semaphore event_sem; | ||
220 | unsigned long event_mask; | ||
214 | }; | 221 | }; |
215 | 222 | ||
216 | static ssize_t atkbd_attr_show_helper(struct device *dev, char *buf, | 223 | static ssize_t atkbd_attr_show_helper(struct device *dev, char *buf, |
@@ -424,58 +431,86 @@ out: | |||
424 | } | 431 | } |
425 | 432 | ||
426 | /* | 433 | /* |
427 | * Event callback from the input module. Events that change the state of | 434 | * atkbd_event_work() is used to complete processing of events that |
428 | * the hardware are processed here. | 435 | * can not be processed by input_event() which is often called from |
436 | * interrupt context. | ||
429 | */ | 437 | */ |
430 | 438 | ||
431 | static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 439 | static void atkbd_event_work(void *data) |
432 | { | 440 | { |
433 | struct atkbd *atkbd = dev->private; | ||
434 | const short period[32] = | 441 | const short period[32] = |
435 | { 33, 37, 42, 46, 50, 54, 58, 63, 67, 75, 83, 92, 100, 109, 116, 125, | 442 | { 33, 37, 42, 46, 50, 54, 58, 63, 67, 75, 83, 92, 100, 109, 116, 125, |
436 | 133, 149, 167, 182, 200, 217, 232, 250, 270, 303, 333, 370, 400, 435, 470, 500 }; | 443 | 133, 149, 167, 182, 200, 217, 232, 250, 270, 303, 333, 370, 400, 435, 470, 500 }; |
437 | const short delay[4] = | 444 | const short delay[4] = |
438 | { 250, 500, 750, 1000 }; | 445 | { 250, 500, 750, 1000 }; |
446 | |||
447 | struct atkbd *atkbd = data; | ||
448 | struct input_dev *dev = atkbd->dev; | ||
439 | unsigned char param[2]; | 449 | unsigned char param[2]; |
440 | int i, j; | 450 | int i, j; |
441 | 451 | ||
452 | down(&atkbd->event_sem); | ||
453 | |||
454 | if (test_and_clear_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask)) { | ||
455 | param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0) | ||
456 | | (test_bit(LED_NUML, dev->led) ? 2 : 0) | ||
457 | | (test_bit(LED_CAPSL, dev->led) ? 4 : 0); | ||
458 | ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS); | ||
459 | |||
460 | if (atkbd->extra) { | ||
461 | param[0] = 0; | ||
462 | param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0) | ||
463 | | (test_bit(LED_SLEEP, dev->led) ? 0x02 : 0) | ||
464 | | (test_bit(LED_SUSPEND, dev->led) ? 0x04 : 0) | ||
465 | | (test_bit(LED_MISC, dev->led) ? 0x10 : 0) | ||
466 | | (test_bit(LED_MUTE, dev->led) ? 0x20 : 0); | ||
467 | ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_EX_SETLEDS); | ||
468 | } | ||
469 | } | ||
470 | |||
471 | if (test_and_clear_bit(ATKBD_REP_EVENT_BIT, &atkbd->event_mask)) { | ||
472 | i = j = 0; | ||
473 | while (i < 31 && period[i] < dev->rep[REP_PERIOD]) | ||
474 | i++; | ||
475 | while (j < 3 && delay[j] < dev->rep[REP_DELAY]) | ||
476 | j++; | ||
477 | dev->rep[REP_PERIOD] = period[i]; | ||
478 | dev->rep[REP_DELAY] = delay[j]; | ||
479 | param[0] = i | (j << 5); | ||
480 | ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETREP); | ||
481 | } | ||
482 | |||
483 | up(&atkbd->event_sem); | ||
484 | } | ||
485 | |||
486 | /* | ||
487 | * Event callback from the input module. Events that change the state of | ||
488 | * the hardware are processed here. If action can not be performed in | ||
489 | * interrupt context it is offloaded to atkbd_event_work. | ||
490 | */ | ||
491 | |||
492 | static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | ||
493 | { | ||
494 | struct atkbd *atkbd = dev->private; | ||
495 | |||
442 | if (!atkbd->write) | 496 | if (!atkbd->write) |
443 | return -1; | 497 | return -1; |
444 | 498 | ||
445 | switch (type) { | 499 | switch (type) { |
446 | 500 | ||
447 | case EV_LED: | 501 | case EV_LED: |
448 | 502 | set_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask); | |
449 | param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0) | 503 | wmb(); |
450 | | (test_bit(LED_NUML, dev->led) ? 2 : 0) | 504 | schedule_work(&atkbd->event_work); |
451 | | (test_bit(LED_CAPSL, dev->led) ? 4 : 0); | ||
452 | ps2_schedule_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS); | ||
453 | |||
454 | if (atkbd->extra) { | ||
455 | param[0] = 0; | ||
456 | param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0) | ||
457 | | (test_bit(LED_SLEEP, dev->led) ? 0x02 : 0) | ||
458 | | (test_bit(LED_SUSPEND, dev->led) ? 0x04 : 0) | ||
459 | | (test_bit(LED_MISC, dev->led) ? 0x10 : 0) | ||
460 | | (test_bit(LED_MUTE, dev->led) ? 0x20 : 0); | ||
461 | ps2_schedule_command(&atkbd->ps2dev, param, ATKBD_CMD_EX_SETLEDS); | ||
462 | } | ||
463 | |||
464 | return 0; | 505 | return 0; |
465 | 506 | ||
466 | case EV_REP: | 507 | case EV_REP: |
467 | 508 | ||
468 | if (atkbd->softrepeat) return 0; | 509 | if (!atkbd->softrepeat) { |
469 | 510 | set_bit(ATKBD_REP_EVENT_BIT, &atkbd->event_mask); | |
470 | i = j = 0; | 511 | wmb(); |
471 | while (i < 31 && period[i] < dev->rep[REP_PERIOD]) | 512 | schedule_work(&atkbd->event_work); |
472 | i++; | 513 | } |
473 | while (j < 3 && delay[j] < dev->rep[REP_DELAY]) | ||
474 | j++; | ||
475 | dev->rep[REP_PERIOD] = period[i]; | ||
476 | dev->rep[REP_DELAY] = delay[j]; | ||
477 | param[0] = i | (j << 5); | ||
478 | ps2_schedule_command(&atkbd->ps2dev, param, ATKBD_CMD_SETREP); | ||
479 | 514 | ||
480 | return 0; | 515 | return 0; |
481 | } | 516 | } |
@@ -810,6 +845,8 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
810 | 845 | ||
811 | atkbd->dev = dev; | 846 | atkbd->dev = dev; |
812 | ps2_init(&atkbd->ps2dev, serio); | 847 | ps2_init(&atkbd->ps2dev, serio); |
848 | INIT_WORK(&atkbd->event_work, atkbd_event_work, atkbd); | ||
849 | init_MUTEX(&atkbd->event_sem); | ||
813 | 850 | ||
814 | switch (serio->id.type) { | 851 | switch (serio->id.type) { |
815 | 852 | ||
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index d00d14bb637a..64672d491222 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c | |||
@@ -259,17 +259,17 @@ static void corgikbd_hinge_timer(unsigned long data) | |||
259 | } | 259 | } |
260 | 260 | ||
261 | #ifdef CONFIG_PM | 261 | #ifdef CONFIG_PM |
262 | static int corgikbd_suspend(struct device *dev, pm_message_t state) | 262 | static int corgikbd_suspend(struct platform_device *dev, pm_message_t state) |
263 | { | 263 | { |
264 | struct corgikbd *corgikbd = dev_get_drvdata(dev); | 264 | struct corgikbd *corgikbd = platform_get_drvdata(dev); |
265 | corgikbd->suspended = 1; | 265 | corgikbd->suspended = 1; |
266 | 266 | ||
267 | return 0; | 267 | return 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | static int corgikbd_resume(struct device *dev) | 270 | static int corgikbd_resume(struct platform_device *dev) |
271 | { | 271 | { |
272 | struct corgikbd *corgikbd = dev_get_drvdata(dev); | 272 | struct corgikbd *corgikbd = platform_get_drvdata(dev); |
273 | 273 | ||
274 | /* Upon resume, ignore the suspend key for a short while */ | 274 | /* Upon resume, ignore the suspend key for a short while */ |
275 | corgikbd->suspend_jiffies=jiffies; | 275 | corgikbd->suspend_jiffies=jiffies; |
@@ -282,7 +282,7 @@ static int corgikbd_resume(struct device *dev) | |||
282 | #define corgikbd_resume NULL | 282 | #define corgikbd_resume NULL |
283 | #endif | 283 | #endif |
284 | 284 | ||
285 | static int __init corgikbd_probe(struct device *dev) | 285 | static int __init corgikbd_probe(struct platform_device *pdev) |
286 | { | 286 | { |
287 | struct corgikbd *corgikbd; | 287 | struct corgikbd *corgikbd; |
288 | struct input_dev *input_dev; | 288 | struct input_dev *input_dev; |
@@ -296,7 +296,7 @@ static int __init corgikbd_probe(struct device *dev) | |||
296 | return -ENOMEM; | 296 | return -ENOMEM; |
297 | } | 297 | } |
298 | 298 | ||
299 | dev_set_drvdata(dev, corgikbd); | 299 | platform_set_drvdata(pdev, corgikbd); |
300 | 300 | ||
301 | corgikbd->input = input_dev; | 301 | corgikbd->input = input_dev; |
302 | spin_lock_init(&corgikbd->lock); | 302 | spin_lock_init(&corgikbd->lock); |
@@ -321,7 +321,7 @@ static int __init corgikbd_probe(struct device *dev) | |||
321 | input_dev->id.vendor = 0x0001; | 321 | input_dev->id.vendor = 0x0001; |
322 | input_dev->id.product = 0x0001; | 322 | input_dev->id.product = 0x0001; |
323 | input_dev->id.version = 0x0100; | 323 | input_dev->id.version = 0x0100; |
324 | input_dev->cdev.dev = dev; | 324 | input_dev->cdev.dev = &pdev->dev; |
325 | input_dev->private = corgikbd; | 325 | input_dev->private = corgikbd; |
326 | 326 | ||
327 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | 327 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); |
@@ -356,10 +356,10 @@ static int __init corgikbd_probe(struct device *dev) | |||
356 | return 0; | 356 | return 0; |
357 | } | 357 | } |
358 | 358 | ||
359 | static int corgikbd_remove(struct device *dev) | 359 | static int corgikbd_remove(struct platform_device *pdev) |
360 | { | 360 | { |
361 | int i; | 361 | int i; |
362 | struct corgikbd *corgikbd = dev_get_drvdata(dev); | 362 | struct corgikbd *corgikbd = platform_get_drvdata(pdev); |
363 | 363 | ||
364 | for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) | 364 | for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) |
365 | free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd); | 365 | free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd); |
@@ -374,23 +374,24 @@ static int corgikbd_remove(struct device *dev) | |||
374 | return 0; | 374 | return 0; |
375 | } | 375 | } |
376 | 376 | ||
377 | static struct device_driver corgikbd_driver = { | 377 | static struct platform_driver corgikbd_driver = { |
378 | .name = "corgi-keyboard", | ||
379 | .bus = &platform_bus_type, | ||
380 | .probe = corgikbd_probe, | 378 | .probe = corgikbd_probe, |
381 | .remove = corgikbd_remove, | 379 | .remove = corgikbd_remove, |
382 | .suspend = corgikbd_suspend, | 380 | .suspend = corgikbd_suspend, |
383 | .resume = corgikbd_resume, | 381 | .resume = corgikbd_resume, |
382 | .driver = { | ||
383 | .name = "corgi-keyboard", | ||
384 | }, | ||
384 | }; | 385 | }; |
385 | 386 | ||
386 | static int __devinit corgikbd_init(void) | 387 | static int __devinit corgikbd_init(void) |
387 | { | 388 | { |
388 | return driver_register(&corgikbd_driver); | 389 | return platform_driver_register(&corgikbd_driver); |
389 | } | 390 | } |
390 | 391 | ||
391 | static void __exit corgikbd_exit(void) | 392 | static void __exit corgikbd_exit(void) |
392 | { | 393 | { |
393 | driver_unregister(&corgikbd_driver); | 394 | platform_driver_unregister(&corgikbd_driver); |
394 | } | 395 | } |
395 | 396 | ||
396 | module_init(corgikbd_init); | 397 | module_init(corgikbd_init); |
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index 0fa38a559cdf..6a15fe3bc527 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c | |||
@@ -309,10 +309,10 @@ static void spitzkbd_hinge_timer(unsigned long data) | |||
309 | } | 309 | } |
310 | 310 | ||
311 | #ifdef CONFIG_PM | 311 | #ifdef CONFIG_PM |
312 | static int spitzkbd_suspend(struct device *dev, pm_message_t state) | 312 | static int spitzkbd_suspend(struct platform_device *dev, pm_message_t state) |
313 | { | 313 | { |
314 | int i; | 314 | int i; |
315 | struct spitzkbd *spitzkbd = dev_get_drvdata(dev); | 315 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); |
316 | spitzkbd->suspended = 1; | 316 | spitzkbd->suspended = 1; |
317 | 317 | ||
318 | /* Set Strobe lines as inputs - *except* strobe line 0 leave this | 318 | /* Set Strobe lines as inputs - *except* strobe line 0 leave this |
@@ -323,10 +323,10 @@ static int spitzkbd_suspend(struct device *dev, pm_message_t state) | |||
323 | return 0; | 323 | return 0; |
324 | } | 324 | } |
325 | 325 | ||
326 | static int spitzkbd_resume(struct device *dev) | 326 | static int spitzkbd_resume(struct platform_device *dev) |
327 | { | 327 | { |
328 | int i; | 328 | int i; |
329 | struct spitzkbd *spitzkbd = dev_get_drvdata(dev); | 329 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); |
330 | 330 | ||
331 | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) | 331 | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) |
332 | pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); | 332 | pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); |
@@ -342,7 +342,7 @@ static int spitzkbd_resume(struct device *dev) | |||
342 | #define spitzkbd_resume NULL | 342 | #define spitzkbd_resume NULL |
343 | #endif | 343 | #endif |
344 | 344 | ||
345 | static int __init spitzkbd_probe(struct device *dev) | 345 | static int __init spitzkbd_probe(struct platform_device *dev) |
346 | { | 346 | { |
347 | struct spitzkbd *spitzkbd; | 347 | struct spitzkbd *spitzkbd; |
348 | struct input_dev *input_dev; | 348 | struct input_dev *input_dev; |
@@ -358,7 +358,7 @@ static int __init spitzkbd_probe(struct device *dev) | |||
358 | return -ENOMEM; | 358 | return -ENOMEM; |
359 | } | 359 | } |
360 | 360 | ||
361 | dev_set_drvdata(dev, spitzkbd); | 361 | platform_set_drvdata(dev, spitzkbd); |
362 | strcpy(spitzkbd->phys, "spitzkbd/input0"); | 362 | strcpy(spitzkbd->phys, "spitzkbd/input0"); |
363 | 363 | ||
364 | spin_lock_init(&spitzkbd->lock); | 364 | spin_lock_init(&spitzkbd->lock); |
@@ -380,7 +380,7 @@ static int __init spitzkbd_probe(struct device *dev) | |||
380 | input_dev->private = spitzkbd; | 380 | input_dev->private = spitzkbd; |
381 | input_dev->name = "Spitz Keyboard"; | 381 | input_dev->name = "Spitz Keyboard"; |
382 | input_dev->phys = spitzkbd->phys; | 382 | input_dev->phys = spitzkbd->phys; |
383 | input_dev->cdev.dev = dev; | 383 | input_dev->cdev.dev = &dev->dev; |
384 | 384 | ||
385 | input_dev->id.bustype = BUS_HOST; | 385 | input_dev->id.bustype = BUS_HOST; |
386 | input_dev->id.vendor = 0x0001; | 386 | input_dev->id.vendor = 0x0001; |
@@ -437,10 +437,10 @@ static int __init spitzkbd_probe(struct device *dev) | |||
437 | return 0; | 437 | return 0; |
438 | } | 438 | } |
439 | 439 | ||
440 | static int spitzkbd_remove(struct device *dev) | 440 | static int spitzkbd_remove(struct platform_device *dev) |
441 | { | 441 | { |
442 | int i; | 442 | int i; |
443 | struct spitzkbd *spitzkbd = dev_get_drvdata(dev); | 443 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); |
444 | 444 | ||
445 | for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) | 445 | for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) |
446 | free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd); | 446 | free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd); |
@@ -460,23 +460,24 @@ static int spitzkbd_remove(struct device *dev) | |||
460 | return 0; | 460 | return 0; |
461 | } | 461 | } |
462 | 462 | ||
463 | static struct device_driver spitzkbd_driver = { | 463 | static struct platform_driver spitzkbd_driver = { |
464 | .name = "spitz-keyboard", | ||
465 | .bus = &platform_bus_type, | ||
466 | .probe = spitzkbd_probe, | 464 | .probe = spitzkbd_probe, |
467 | .remove = spitzkbd_remove, | 465 | .remove = spitzkbd_remove, |
468 | .suspend = spitzkbd_suspend, | 466 | .suspend = spitzkbd_suspend, |
469 | .resume = spitzkbd_resume, | 467 | .resume = spitzkbd_resume, |
468 | .driver = { | ||
469 | .name = "spitz-keyboard", | ||
470 | }, | ||
470 | }; | 471 | }; |
471 | 472 | ||
472 | static int __devinit spitzkbd_init(void) | 473 | static int __devinit spitzkbd_init(void) |
473 | { | 474 | { |
474 | return driver_register(&spitzkbd_driver); | 475 | return platform_driver_register(&spitzkbd_driver); |
475 | } | 476 | } |
476 | 477 | ||
477 | static void __exit spitzkbd_exit(void) | 478 | static void __exit spitzkbd_exit(void) |
478 | { | 479 | { |
479 | driver_unregister(&spitzkbd_driver); | 480 | platform_driver_unregister(&spitzkbd_driver); |
480 | } | 481 | } |
481 | 482 | ||
482 | module_init(spitzkbd_init); | 483 | module_init(spitzkbd_init); |
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index b3eaac1b35b6..e08dbe08f46d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -26,7 +26,7 @@ config INPUT_PCSPKR | |||
26 | 26 | ||
27 | config INPUT_SPARCSPKR | 27 | config INPUT_SPARCSPKR |
28 | tristate "SPARC Speaker support" | 28 | tristate "SPARC Speaker support" |
29 | depends on PCI && (SPARC32 || SPARC64) | 29 | depends on PCI && SPARC |
30 | help | 30 | help |
31 | Say Y here if you want the standard Speaker on Sparc PCI systems | 31 | Say Y here if you want the standard Speaker on Sparc PCI systems |
32 | to be used for bells and whistles. | 32 | to be used for bells and whistles. |
@@ -40,6 +40,16 @@ config INPUT_M68K_BEEP | |||
40 | tristate "M68k Beeper support" | 40 | tristate "M68k Beeper support" |
41 | depends on M68K | 41 | depends on M68K |
42 | 42 | ||
43 | config INPUT_WISTRON_BTNS | ||
44 | tristate "x86 Wistron laptop button interface" | ||
45 | depends on X86 && !X86_64 | ||
46 | help | ||
47 | Say Y here for support of Winstron laptop button interface, used on | ||
48 | laptops of various brands, including Acer and Fujitsu-Siemens. | ||
49 | |||
50 | To compile this driver as a module, choose M here: the module will | ||
51 | be called wistron_btns. | ||
52 | |||
43 | config INPUT_UINPUT | 53 | config INPUT_UINPUT |
44 | tristate "User level driver support" | 54 | tristate "User level driver support" |
45 | help | 55 | help |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index f8d01c69f349..ce44cce01285 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
@@ -9,4 +9,5 @@ obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o | |||
9 | obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o | 9 | obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o |
10 | obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o | 10 | obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o |
11 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o | 11 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o |
12 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o | ||
12 | obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o | 13 | obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o |
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 948c1cc01bc9..546ed9b4901d 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -92,24 +92,19 @@ static void uinput_request_done(struct uinput_device *udev, struct uinput_reques | |||
92 | { | 92 | { |
93 | /* Mark slot as available */ | 93 | /* Mark slot as available */ |
94 | udev->requests[request->id] = NULL; | 94 | udev->requests[request->id] = NULL; |
95 | wake_up_interruptible(&udev->requests_waitq); | 95 | wake_up(&udev->requests_waitq); |
96 | 96 | ||
97 | complete(&request->done); | 97 | complete(&request->done); |
98 | } | 98 | } |
99 | 99 | ||
100 | static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request) | 100 | static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request) |
101 | { | 101 | { |
102 | int retval; | ||
103 | |||
104 | /* Tell our userspace app about this new request by queueing an input event */ | 102 | /* Tell our userspace app about this new request by queueing an input event */ |
105 | uinput_dev_event(dev, EV_UINPUT, request->code, request->id); | 103 | uinput_dev_event(dev, EV_UINPUT, request->code, request->id); |
106 | 104 | ||
107 | /* Wait for the request to complete */ | 105 | /* Wait for the request to complete */ |
108 | retval = wait_for_completion_interruptible(&request->done); | 106 | wait_for_completion(&request->done); |
109 | if (!retval) | 107 | return request->retval; |
110 | retval = request->retval; | ||
111 | |||
112 | return retval; | ||
113 | } | 108 | } |
114 | 109 | ||
115 | static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect) | 110 | static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect) |
@@ -152,67 +147,62 @@ static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id) | |||
152 | return retval; | 147 | return retval; |
153 | } | 148 | } |
154 | 149 | ||
155 | static int uinput_create_device(struct uinput_device *udev) | 150 | static void uinput_destroy_device(struct uinput_device *udev) |
156 | { | 151 | { |
157 | if (!udev->dev->name) { | 152 | const char *name, *phys; |
158 | printk(KERN_DEBUG "%s: write device info first\n", UINPUT_NAME); | 153 | |
159 | return -EINVAL; | 154 | if (udev->dev) { |
155 | name = udev->dev->name; | ||
156 | phys = udev->dev->phys; | ||
157 | if (udev->state == UIST_CREATED) | ||
158 | input_unregister_device(udev->dev); | ||
159 | else | ||
160 | input_free_device(udev->dev); | ||
161 | kfree(name); | ||
162 | kfree(phys); | ||
163 | udev->dev = NULL; | ||
160 | } | 164 | } |
161 | 165 | ||
162 | udev->dev->event = uinput_dev_event; | 166 | udev->state = UIST_NEW_DEVICE; |
163 | udev->dev->upload_effect = uinput_dev_upload_effect; | ||
164 | udev->dev->erase_effect = uinput_dev_erase_effect; | ||
165 | udev->dev->private = udev; | ||
166 | |||
167 | init_waitqueue_head(&udev->waitq); | ||
168 | |||
169 | input_register_device(udev->dev); | ||
170 | |||
171 | set_bit(UIST_CREATED, &udev->state); | ||
172 | |||
173 | return 0; | ||
174 | } | 167 | } |
175 | 168 | ||
176 | static int uinput_destroy_device(struct uinput_device *udev) | 169 | static int uinput_create_device(struct uinput_device *udev) |
177 | { | 170 | { |
178 | if (!test_bit(UIST_CREATED, &udev->state)) { | 171 | int error; |
179 | printk(KERN_WARNING "%s: create the device first\n", UINPUT_NAME); | 172 | |
173 | if (udev->state != UIST_SETUP_COMPLETE) { | ||
174 | printk(KERN_DEBUG "%s: write device info first\n", UINPUT_NAME); | ||
180 | return -EINVAL; | 175 | return -EINVAL; |
181 | } | 176 | } |
182 | 177 | ||
183 | input_unregister_device(udev->dev); | 178 | error = input_register_device(udev->dev); |
179 | if (error) { | ||
180 | uinput_destroy_device(udev); | ||
181 | return error; | ||
182 | } | ||
184 | 183 | ||
185 | clear_bit(UIST_CREATED, &udev->state); | 184 | udev->state = UIST_CREATED; |
186 | 185 | ||
187 | return 0; | 186 | return 0; |
188 | } | 187 | } |
189 | 188 | ||
190 | static int uinput_open(struct inode *inode, struct file *file) | 189 | static int uinput_open(struct inode *inode, struct file *file) |
191 | { | 190 | { |
192 | struct uinput_device *newdev; | 191 | struct uinput_device *newdev; |
193 | struct input_dev *newinput; | ||
194 | 192 | ||
195 | newdev = kmalloc(sizeof(struct uinput_device), GFP_KERNEL); | 193 | newdev = kzalloc(sizeof(struct uinput_device), GFP_KERNEL); |
196 | if (!newdev) | 194 | if (!newdev) |
197 | goto error; | 195 | return -ENOMEM; |
198 | memset(newdev, 0, sizeof(struct uinput_device)); | 196 | |
197 | init_MUTEX(&newdev->sem); | ||
199 | spin_lock_init(&newdev->requests_lock); | 198 | spin_lock_init(&newdev->requests_lock); |
200 | init_waitqueue_head(&newdev->requests_waitq); | 199 | init_waitqueue_head(&newdev->requests_waitq); |
201 | 200 | init_waitqueue_head(&newdev->waitq); | |
202 | newinput = kmalloc(sizeof(struct input_dev), GFP_KERNEL); | 201 | newdev->state = UIST_NEW_DEVICE; |
203 | if (!newinput) | ||
204 | goto cleanup; | ||
205 | memset(newinput, 0, sizeof(struct input_dev)); | ||
206 | |||
207 | newdev->dev = newinput; | ||
208 | 202 | ||
209 | file->private_data = newdev; | 203 | file->private_data = newdev; |
210 | 204 | ||
211 | return 0; | 205 | return 0; |
212 | cleanup: | ||
213 | kfree(newdev); | ||
214 | error: | ||
215 | return -ENOMEM; | ||
216 | } | 206 | } |
217 | 207 | ||
218 | static int uinput_validate_absbits(struct input_dev *dev) | 208 | static int uinput_validate_absbits(struct input_dev *dev) |
@@ -246,34 +236,55 @@ static int uinput_validate_absbits(struct input_dev *dev) | |||
246 | return retval; | 236 | return retval; |
247 | } | 237 | } |
248 | 238 | ||
249 | static int uinput_alloc_device(struct file *file, const char __user *buffer, size_t count) | 239 | static int uinput_allocate_device(struct uinput_device *udev) |
240 | { | ||
241 | udev->dev = input_allocate_device(); | ||
242 | if (!udev->dev) | ||
243 | return -ENOMEM; | ||
244 | |||
245 | udev->dev->event = uinput_dev_event; | ||
246 | udev->dev->upload_effect = uinput_dev_upload_effect; | ||
247 | udev->dev->erase_effect = uinput_dev_erase_effect; | ||
248 | udev->dev->private = udev; | ||
249 | |||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | static int uinput_setup_device(struct uinput_device *udev, const char __user *buffer, size_t count) | ||
250 | { | 254 | { |
251 | struct uinput_user_dev *user_dev; | 255 | struct uinput_user_dev *user_dev; |
252 | struct input_dev *dev; | 256 | struct input_dev *dev; |
253 | struct uinput_device *udev; | ||
254 | char *name; | 257 | char *name; |
255 | int size; | 258 | int size; |
256 | int retval; | 259 | int retval; |
257 | 260 | ||
258 | retval = count; | 261 | if (count != sizeof(struct uinput_user_dev)) |
262 | return -EINVAL; | ||
263 | |||
264 | if (!udev->dev) { | ||
265 | retval = uinput_allocate_device(udev); | ||
266 | if (retval) | ||
267 | return retval; | ||
268 | } | ||
259 | 269 | ||
260 | udev = file->private_data; | ||
261 | dev = udev->dev; | 270 | dev = udev->dev; |
262 | 271 | ||
263 | user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL); | 272 | user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL); |
264 | if (!user_dev) { | 273 | if (!user_dev) |
265 | retval = -ENOMEM; | 274 | return -ENOMEM; |
266 | goto exit; | ||
267 | } | ||
268 | 275 | ||
269 | if (copy_from_user(user_dev, buffer, sizeof(struct uinput_user_dev))) { | 276 | if (copy_from_user(user_dev, buffer, sizeof(struct uinput_user_dev))) { |
270 | retval = -EFAULT; | 277 | retval = -EFAULT; |
271 | goto exit; | 278 | goto exit; |
272 | } | 279 | } |
273 | 280 | ||
274 | kfree(dev->name); | ||
275 | |||
276 | size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; | 281 | size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; |
282 | if (!size) { | ||
283 | retval = -EINVAL; | ||
284 | goto exit; | ||
285 | } | ||
286 | |||
287 | kfree(dev->name); | ||
277 | dev->name = name = kmalloc(size, GFP_KERNEL); | 288 | dev->name = name = kmalloc(size, GFP_KERNEL); |
278 | if (!name) { | 289 | if (!name) { |
279 | retval = -ENOMEM; | 290 | retval = -ENOMEM; |
@@ -296,32 +307,50 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz | |||
296 | /* check if absmin/absmax/absfuzz/absflat are filled as | 307 | /* check if absmin/absmax/absfuzz/absflat are filled as |
297 | * told in Documentation/input/input-programming.txt */ | 308 | * told in Documentation/input/input-programming.txt */ |
298 | if (test_bit(EV_ABS, dev->evbit)) { | 309 | if (test_bit(EV_ABS, dev->evbit)) { |
299 | int err = uinput_validate_absbits(dev); | 310 | retval = uinput_validate_absbits(dev); |
300 | if (err < 0) { | 311 | if (retval < 0) |
301 | retval = err; | 312 | goto exit; |
302 | kfree(dev->name); | ||
303 | } | ||
304 | } | 313 | } |
305 | 314 | ||
306 | exit: | 315 | udev->state = UIST_SETUP_COMPLETE; |
316 | retval = count; | ||
317 | |||
318 | exit: | ||
307 | kfree(user_dev); | 319 | kfree(user_dev); |
308 | return retval; | 320 | return retval; |
309 | } | 321 | } |
310 | 322 | ||
323 | static inline ssize_t uinput_inject_event(struct uinput_device *udev, const char __user *buffer, size_t count) | ||
324 | { | ||
325 | struct input_event ev; | ||
326 | |||
327 | if (count != sizeof(struct input_event)) | ||
328 | return -EINVAL; | ||
329 | |||
330 | if (copy_from_user(&ev, buffer, sizeof(struct input_event))) | ||
331 | return -EFAULT; | ||
332 | |||
333 | input_event(udev->dev, ev.type, ev.code, ev.value); | ||
334 | |||
335 | return sizeof(struct input_event); | ||
336 | } | ||
337 | |||
311 | static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) | 338 | static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) |
312 | { | 339 | { |
313 | struct uinput_device *udev = file->private_data; | 340 | struct uinput_device *udev = file->private_data; |
341 | int retval; | ||
342 | |||
343 | retval = down_interruptible(&udev->sem); | ||
344 | if (retval) | ||
345 | return retval; | ||
314 | 346 | ||
315 | if (test_bit(UIST_CREATED, &udev->state)) { | 347 | retval = udev->state == UIST_CREATED ? |
316 | struct input_event ev; | 348 | uinput_inject_event(udev, buffer, count) : |
349 | uinput_setup_device(udev, buffer, count); | ||
317 | 350 | ||
318 | if (copy_from_user(&ev, buffer, sizeof(struct input_event))) | 351 | up(&udev->sem); |
319 | return -EFAULT; | ||
320 | input_event(udev->dev, ev.type, ev.code, ev.value); | ||
321 | } else | ||
322 | count = uinput_alloc_device(file, buffer, count); | ||
323 | 352 | ||
324 | return count; | 353 | return retval; |
325 | } | 354 | } |
326 | 355 | ||
327 | static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) | 356 | static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
@@ -329,28 +358,38 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count, | |||
329 | struct uinput_device *udev = file->private_data; | 358 | struct uinput_device *udev = file->private_data; |
330 | int retval = 0; | 359 | int retval = 0; |
331 | 360 | ||
332 | if (!test_bit(UIST_CREATED, &udev->state)) | 361 | if (udev->state != UIST_CREATED) |
333 | return -ENODEV; | 362 | return -ENODEV; |
334 | 363 | ||
335 | if (udev->head == udev->tail && (file->f_flags & O_NONBLOCK)) | 364 | if (udev->head == udev->tail && (file->f_flags & O_NONBLOCK)) |
336 | return -EAGAIN; | 365 | return -EAGAIN; |
337 | 366 | ||
338 | retval = wait_event_interruptible(udev->waitq, | 367 | retval = wait_event_interruptible(udev->waitq, |
339 | udev->head != udev->tail || !test_bit(UIST_CREATED, &udev->state)); | 368 | udev->head != udev->tail || udev->state != UIST_CREATED); |
340 | if (retval) | 369 | if (retval) |
341 | return retval; | 370 | return retval; |
342 | 371 | ||
343 | if (!test_bit(UIST_CREATED, &udev->state)) | 372 | retval = down_interruptible(&udev->sem); |
344 | return -ENODEV; | 373 | if (retval) |
374 | return retval; | ||
345 | 375 | ||
346 | while ((udev->head != udev->tail) && | 376 | if (udev->state != UIST_CREATED) { |
347 | (retval + sizeof(struct input_event) <= count)) { | 377 | retval = -ENODEV; |
348 | if (copy_to_user(buffer + retval, &udev->buff[udev->tail], sizeof(struct input_event))) | 378 | goto out; |
349 | return -EFAULT; | 379 | } |
380 | |||
381 | while (udev->head != udev->tail && retval + sizeof(struct input_event) <= count) { | ||
382 | if (copy_to_user(buffer + retval, &udev->buff[udev->tail], sizeof(struct input_event))) { | ||
383 | retval = -EFAULT; | ||
384 | goto out; | ||
385 | } | ||
350 | udev->tail = (udev->tail + 1) % UINPUT_BUFFER_SIZE; | 386 | udev->tail = (udev->tail + 1) % UINPUT_BUFFER_SIZE; |
351 | retval += sizeof(struct input_event); | 387 | retval += sizeof(struct input_event); |
352 | } | 388 | } |
353 | 389 | ||
390 | out: | ||
391 | up(&udev->sem); | ||
392 | |||
354 | return retval; | 393 | return retval; |
355 | } | 394 | } |
356 | 395 | ||
@@ -366,28 +405,30 @@ static unsigned int uinput_poll(struct file *file, poll_table *wait) | |||
366 | return 0; | 405 | return 0; |
367 | } | 406 | } |
368 | 407 | ||
369 | static int uinput_burn_device(struct uinput_device *udev) | 408 | static int uinput_release(struct inode *inode, struct file *file) |
370 | { | 409 | { |
371 | if (test_bit(UIST_CREATED, &udev->state)) | 410 | struct uinput_device *udev = file->private_data; |
372 | uinput_destroy_device(udev); | ||
373 | 411 | ||
374 | kfree(udev->dev->name); | 412 | uinput_destroy_device(udev); |
375 | kfree(udev->dev->phys); | ||
376 | kfree(udev->dev); | ||
377 | kfree(udev); | 413 | kfree(udev); |
378 | 414 | ||
379 | return 0; | 415 | return 0; |
380 | } | 416 | } |
381 | 417 | ||
382 | static int uinput_close(struct inode *inode, struct file *file) | 418 | #define uinput_set_bit(_arg, _bit, _max) \ |
419 | ({ \ | ||
420 | int __ret = 0; \ | ||
421 | if (udev->state == UIST_CREATED) \ | ||
422 | __ret = -EINVAL; \ | ||
423 | else if ((_arg) > (_max)) \ | ||
424 | __ret = -EINVAL; \ | ||
425 | else set_bit((_arg), udev->dev->_bit); \ | ||
426 | __ret; \ | ||
427 | }) | ||
428 | |||
429 | static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
383 | { | 430 | { |
384 | uinput_burn_device(file->private_data); | 431 | int retval; |
385 | return 0; | ||
386 | } | ||
387 | |||
388 | static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | ||
389 | { | ||
390 | int retval = 0; | ||
391 | struct uinput_device *udev; | 432 | struct uinput_device *udev; |
392 | void __user *p = (void __user *)arg; | 433 | void __user *p = (void __user *)arg; |
393 | struct uinput_ff_upload ff_up; | 434 | struct uinput_ff_upload ff_up; |
@@ -398,19 +439,14 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
398 | 439 | ||
399 | udev = file->private_data; | 440 | udev = file->private_data; |
400 | 441 | ||
401 | /* device attributes can not be changed after the device is created */ | 442 | retval = down_interruptible(&udev->sem); |
402 | switch (cmd) { | 443 | if (retval) |
403 | case UI_SET_EVBIT: | 444 | return retval; |
404 | case UI_SET_KEYBIT: | 445 | |
405 | case UI_SET_RELBIT: | 446 | if (!udev->dev) { |
406 | case UI_SET_ABSBIT: | 447 | retval = uinput_allocate_device(udev); |
407 | case UI_SET_MSCBIT: | 448 | if (retval) |
408 | case UI_SET_LEDBIT: | 449 | goto out; |
409 | case UI_SET_SNDBIT: | ||
410 | case UI_SET_FFBIT: | ||
411 | case UI_SET_PHYS: | ||
412 | if (test_bit(UIST_CREATED, &udev->state)) | ||
413 | return -EINVAL; | ||
414 | } | 450 | } |
415 | 451 | ||
416 | switch (cmd) { | 452 | switch (cmd) { |
@@ -419,74 +455,50 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
419 | break; | 455 | break; |
420 | 456 | ||
421 | case UI_DEV_DESTROY: | 457 | case UI_DEV_DESTROY: |
422 | retval = uinput_destroy_device(udev); | 458 | uinput_destroy_device(udev); |
423 | break; | 459 | break; |
424 | 460 | ||
425 | case UI_SET_EVBIT: | 461 | case UI_SET_EVBIT: |
426 | if (arg > EV_MAX) { | 462 | retval = uinput_set_bit(arg, evbit, EV_MAX); |
427 | retval = -EINVAL; | ||
428 | break; | ||
429 | } | ||
430 | set_bit(arg, udev->dev->evbit); | ||
431 | break; | 463 | break; |
432 | 464 | ||
433 | case UI_SET_KEYBIT: | 465 | case UI_SET_KEYBIT: |
434 | if (arg > KEY_MAX) { | 466 | retval = uinput_set_bit(arg, keybit, KEY_MAX); |
435 | retval = -EINVAL; | ||
436 | break; | ||
437 | } | ||
438 | set_bit(arg, udev->dev->keybit); | ||
439 | break; | 467 | break; |
440 | 468 | ||
441 | case UI_SET_RELBIT: | 469 | case UI_SET_RELBIT: |
442 | if (arg > REL_MAX) { | 470 | retval = uinput_set_bit(arg, relbit, REL_MAX); |
443 | retval = -EINVAL; | ||
444 | break; | ||
445 | } | ||
446 | set_bit(arg, udev->dev->relbit); | ||
447 | break; | 471 | break; |
448 | 472 | ||
449 | case UI_SET_ABSBIT: | 473 | case UI_SET_ABSBIT: |
450 | if (arg > ABS_MAX) { | 474 | retval = uinput_set_bit(arg, absbit, ABS_MAX); |
451 | retval = -EINVAL; | ||
452 | break; | ||
453 | } | ||
454 | set_bit(arg, udev->dev->absbit); | ||
455 | break; | 475 | break; |
456 | 476 | ||
457 | case UI_SET_MSCBIT: | 477 | case UI_SET_MSCBIT: |
458 | if (arg > MSC_MAX) { | 478 | retval = uinput_set_bit(arg, mscbit, MSC_MAX); |
459 | retval = -EINVAL; | ||
460 | break; | ||
461 | } | ||
462 | set_bit(arg, udev->dev->mscbit); | ||
463 | break; | 479 | break; |
464 | 480 | ||
465 | case UI_SET_LEDBIT: | 481 | case UI_SET_LEDBIT: |
466 | if (arg > LED_MAX) { | 482 | retval = uinput_set_bit(arg, ledbit, LED_MAX); |
467 | retval = -EINVAL; | ||
468 | break; | ||
469 | } | ||
470 | set_bit(arg, udev->dev->ledbit); | ||
471 | break; | 483 | break; |
472 | 484 | ||
473 | case UI_SET_SNDBIT: | 485 | case UI_SET_SNDBIT: |
474 | if (arg > SND_MAX) { | 486 | retval = uinput_set_bit(arg, sndbit, SND_MAX); |
475 | retval = -EINVAL; | ||
476 | break; | ||
477 | } | ||
478 | set_bit(arg, udev->dev->sndbit); | ||
479 | break; | 487 | break; |
480 | 488 | ||
481 | case UI_SET_FFBIT: | 489 | case UI_SET_FFBIT: |
482 | if (arg > FF_MAX) { | 490 | retval = uinput_set_bit(arg, ffbit, FF_MAX); |
483 | retval = -EINVAL; | 491 | break; |
484 | break; | 492 | |
485 | } | 493 | case UI_SET_SWBIT: |
486 | set_bit(arg, udev->dev->ffbit); | 494 | retval = uinput_set_bit(arg, swbit, SW_MAX); |
487 | break; | 495 | break; |
488 | 496 | ||
489 | case UI_SET_PHYS: | 497 | case UI_SET_PHYS: |
498 | if (udev->state == UIST_CREATED) { | ||
499 | retval = -EINVAL; | ||
500 | goto out; | ||
501 | } | ||
490 | length = strnlen_user(p, 1024); | 502 | length = strnlen_user(p, 1024); |
491 | if (length <= 0) { | 503 | if (length <= 0) { |
492 | retval = -EFAULT; | 504 | retval = -EFAULT; |
@@ -575,23 +587,26 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
575 | default: | 587 | default: |
576 | retval = -EINVAL; | 588 | retval = -EINVAL; |
577 | } | 589 | } |
590 | |||
591 | out: | ||
592 | up(&udev->sem); | ||
578 | return retval; | 593 | return retval; |
579 | } | 594 | } |
580 | 595 | ||
581 | static struct file_operations uinput_fops = { | 596 | static struct file_operations uinput_fops = { |
582 | .owner = THIS_MODULE, | 597 | .owner = THIS_MODULE, |
583 | .open = uinput_open, | 598 | .open = uinput_open, |
584 | .release = uinput_close, | 599 | .release = uinput_release, |
585 | .read = uinput_read, | 600 | .read = uinput_read, |
586 | .write = uinput_write, | 601 | .write = uinput_write, |
587 | .poll = uinput_poll, | 602 | .poll = uinput_poll, |
588 | .ioctl = uinput_ioctl, | 603 | .unlocked_ioctl = uinput_ioctl, |
589 | }; | 604 | }; |
590 | 605 | ||
591 | static struct miscdevice uinput_misc = { | 606 | static struct miscdevice uinput_misc = { |
592 | .fops = &uinput_fops, | 607 | .fops = &uinput_fops, |
593 | .minor = UINPUT_MINOR, | 608 | .minor = UINPUT_MINOR, |
594 | .name = UINPUT_NAME, | 609 | .name = UINPUT_NAME, |
595 | }; | 610 | }; |
596 | 611 | ||
597 | static int __init uinput_init(void) | 612 | static int __init uinput_init(void) |
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c new file mode 100644 index 000000000000..bac3085185fe --- /dev/null +++ b/drivers/input/misc/wistron_btns.c | |||
@@ -0,0 +1,561 @@ | |||
1 | /* | ||
2 | * Wistron laptop button driver | ||
3 | * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> | ||
4 | * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> | ||
5 | * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> | ||
6 | * | ||
7 | * You can redistribute and/or modify this program under the terms of the | ||
8 | * GNU General Public License version 2 as published by the Free Software | ||
9 | * Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
14 | * Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | #include <asm/io.h> | ||
21 | #include <linux/dmi.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/input.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/mc146818rtc.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/preempt.h> | ||
29 | #include <linux/string.h> | ||
30 | #include <linux/timer.h> | ||
31 | #include <linux/types.h> | ||
32 | #include <linux/platform_device.h> | ||
33 | |||
34 | /* | ||
35 | * Number of attempts to read data from queue per poll; | ||
36 | * the queue can hold up to 31 entries | ||
37 | */ | ||
38 | #define MAX_POLL_ITERATIONS 64 | ||
39 | |||
40 | #define POLL_FREQUENCY 10 /* Number of polls per second */ | ||
41 | |||
42 | #if POLL_FREQUENCY > HZ | ||
43 | #error "POLL_FREQUENCY too high" | ||
44 | #endif | ||
45 | |||
46 | /* BIOS subsystem IDs */ | ||
47 | #define WIFI 0x35 | ||
48 | #define BLUETOOTH 0x34 | ||
49 | |||
50 | MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>"); | ||
51 | MODULE_DESCRIPTION("Wistron laptop button driver"); | ||
52 | MODULE_LICENSE("GPL v2"); | ||
53 | MODULE_VERSION("0.1"); | ||
54 | |||
55 | static int force; /* = 0; */ | ||
56 | module_param(force, bool, 0); | ||
57 | MODULE_PARM_DESC(force, "Load even if computer is not in database"); | ||
58 | |||
59 | static char *keymap_name; /* = NULL; */ | ||
60 | module_param_named(keymap, keymap_name, charp, 0); | ||
61 | MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected"); | ||
62 | |||
63 | static struct platform_device *wistron_device; | ||
64 | |||
65 | /* BIOS interface implementation */ | ||
66 | |||
67 | static void __iomem *bios_entry_point; /* BIOS routine entry point */ | ||
68 | static void __iomem *bios_code_map_base; | ||
69 | static void __iomem *bios_data_map_base; | ||
70 | |||
71 | static u8 cmos_address; | ||
72 | |||
73 | struct regs { | ||
74 | u32 eax, ebx, ecx; | ||
75 | }; | ||
76 | |||
77 | static void call_bios(struct regs *regs) | ||
78 | { | ||
79 | unsigned long flags; | ||
80 | |||
81 | preempt_disable(); | ||
82 | local_irq_save(flags); | ||
83 | asm volatile ("pushl %%ebp;" | ||
84 | "movl %7, %%ebp;" | ||
85 | "call *%6;" | ||
86 | "popl %%ebp" | ||
87 | : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx) | ||
88 | : "0" (regs->eax), "1" (regs->ebx), "2" (regs->ecx), | ||
89 | "m" (bios_entry_point), "m" (bios_data_map_base) | ||
90 | : "edx", "edi", "esi", "memory"); | ||
91 | local_irq_restore(flags); | ||
92 | preempt_enable(); | ||
93 | } | ||
94 | |||
95 | static size_t __init locate_wistron_bios(void __iomem *base) | ||
96 | { | ||
97 | static const unsigned char __initdata signature[] = | ||
98 | { 0x42, 0x21, 0x55, 0x30 }; | ||
99 | size_t offset; | ||
100 | |||
101 | for (offset = 0; offset < 0x10000; offset += 0x10) { | ||
102 | if (check_signature(base + offset, signature, | ||
103 | sizeof(signature)) != 0) | ||
104 | return offset; | ||
105 | } | ||
106 | return -1; | ||
107 | } | ||
108 | |||
109 | static int __init map_bios(void) | ||
110 | { | ||
111 | void __iomem *base; | ||
112 | size_t offset; | ||
113 | u32 entry_point; | ||
114 | |||
115 | base = ioremap(0xF0000, 0x10000); /* Can't fail */ | ||
116 | offset = locate_wistron_bios(base); | ||
117 | if (offset < 0) { | ||
118 | printk(KERN_ERR "wistron_btns: BIOS entry point not found\n"); | ||
119 | iounmap(base); | ||
120 | return -ENODEV; | ||
121 | } | ||
122 | |||
123 | entry_point = readl(base + offset + 5); | ||
124 | printk(KERN_DEBUG | ||
125 | "wistron_btns: BIOS signature found at %p, entry point %08X\n", | ||
126 | base + offset, entry_point); | ||
127 | |||
128 | if (entry_point >= 0xF0000) { | ||
129 | bios_code_map_base = base; | ||
130 | bios_entry_point = bios_code_map_base + (entry_point & 0xFFFF); | ||
131 | } else { | ||
132 | iounmap(base); | ||
133 | bios_code_map_base = ioremap(entry_point & ~0x3FFF, 0x4000); | ||
134 | if (bios_code_map_base == NULL) { | ||
135 | printk(KERN_ERR | ||
136 | "wistron_btns: Can't map BIOS code at %08X\n", | ||
137 | entry_point & ~0x3FFF); | ||
138 | goto err; | ||
139 | } | ||
140 | bios_entry_point = bios_code_map_base + (entry_point & 0x3FFF); | ||
141 | } | ||
142 | /* The Windows driver maps 0x10000 bytes, we keep only one page... */ | ||
143 | bios_data_map_base = ioremap(0x400, 0xc00); | ||
144 | if (bios_data_map_base == NULL) { | ||
145 | printk(KERN_ERR "wistron_btns: Can't map BIOS data\n"); | ||
146 | goto err_code; | ||
147 | } | ||
148 | return 0; | ||
149 | |||
150 | err_code: | ||
151 | iounmap(bios_code_map_base); | ||
152 | err: | ||
153 | return -ENOMEM; | ||
154 | } | ||
155 | |||
156 | static inline void unmap_bios(void) | ||
157 | { | ||
158 | iounmap(bios_code_map_base); | ||
159 | iounmap(bios_data_map_base); | ||
160 | } | ||
161 | |||
162 | /* BIOS calls */ | ||
163 | |||
164 | static u16 bios_pop_queue(void) | ||
165 | { | ||
166 | struct regs regs; | ||
167 | |||
168 | memset(®s, 0, sizeof (regs)); | ||
169 | regs.eax = 0x9610; | ||
170 | regs.ebx = 0x061C; | ||
171 | regs.ecx = 0x0000; | ||
172 | call_bios(®s); | ||
173 | |||
174 | return regs.eax; | ||
175 | } | ||
176 | |||
177 | static void __init bios_attach(void) | ||
178 | { | ||
179 | struct regs regs; | ||
180 | |||
181 | memset(®s, 0, sizeof (regs)); | ||
182 | regs.eax = 0x9610; | ||
183 | regs.ebx = 0x012E; | ||
184 | call_bios(®s); | ||
185 | } | ||
186 | |||
187 | static void bios_detach(void) | ||
188 | { | ||
189 | struct regs regs; | ||
190 | |||
191 | memset(®s, 0, sizeof (regs)); | ||
192 | regs.eax = 0x9610; | ||
193 | regs.ebx = 0x002E; | ||
194 | call_bios(®s); | ||
195 | } | ||
196 | |||
197 | static u8 __init bios_get_cmos_address(void) | ||
198 | { | ||
199 | struct regs regs; | ||
200 | |||
201 | memset(®s, 0, sizeof (regs)); | ||
202 | regs.eax = 0x9610; | ||
203 | regs.ebx = 0x051C; | ||
204 | call_bios(®s); | ||
205 | |||
206 | return regs.ecx; | ||
207 | } | ||
208 | |||
209 | static u16 __init bios_get_default_setting(u8 subsys) | ||
210 | { | ||
211 | struct regs regs; | ||
212 | |||
213 | memset(®s, 0, sizeof (regs)); | ||
214 | regs.eax = 0x9610; | ||
215 | regs.ebx = 0x0200 | subsys; | ||
216 | call_bios(®s); | ||
217 | |||
218 | return regs.eax; | ||
219 | } | ||
220 | |||
221 | static void bios_set_state(u8 subsys, int enable) | ||
222 | { | ||
223 | struct regs regs; | ||
224 | |||
225 | memset(®s, 0, sizeof (regs)); | ||
226 | regs.eax = 0x9610; | ||
227 | regs.ebx = (enable ? 0x0100 : 0x0000) | subsys; | ||
228 | call_bios(®s); | ||
229 | } | ||
230 | |||
231 | /* Hardware database */ | ||
232 | |||
233 | struct key_entry { | ||
234 | char type; /* See KE_* below */ | ||
235 | u8 code; | ||
236 | unsigned keycode; /* For KE_KEY */ | ||
237 | }; | ||
238 | |||
239 | enum { KE_END, KE_KEY, KE_WIFI, KE_BLUETOOTH }; | ||
240 | |||
241 | static const struct key_entry *keymap; /* = NULL; Current key map */ | ||
242 | static int have_wifi; | ||
243 | static int have_bluetooth; | ||
244 | |||
245 | static int __init dmi_matched(struct dmi_system_id *dmi) | ||
246 | { | ||
247 | const struct key_entry *key; | ||
248 | |||
249 | keymap = dmi->driver_data; | ||
250 | for (key = keymap; key->type != KE_END; key++) { | ||
251 | if (key->type == KE_WIFI) { | ||
252 | have_wifi = 1; | ||
253 | break; | ||
254 | } else if (key->type == KE_BLUETOOTH) { | ||
255 | have_bluetooth = 1; | ||
256 | break; | ||
257 | } | ||
258 | } | ||
259 | return 1; | ||
260 | } | ||
261 | |||
262 | static struct key_entry keymap_empty[] = { | ||
263 | { KE_END, 0 } | ||
264 | }; | ||
265 | |||
266 | static struct key_entry keymap_fs_amilo_pro_v2000[] = { | ||
267 | { KE_KEY, 0x01, KEY_HELP }, | ||
268 | { KE_KEY, 0x11, KEY_PROG1 }, | ||
269 | { KE_KEY, 0x12, KEY_PROG2 }, | ||
270 | { KE_WIFI, 0x30, 0 }, | ||
271 | { KE_KEY, 0x31, KEY_MAIL }, | ||
272 | { KE_KEY, 0x36, KEY_WWW }, | ||
273 | { KE_END, 0 } | ||
274 | }; | ||
275 | |||
276 | static struct key_entry keymap_wistron_ms2141[] = { | ||
277 | { KE_KEY, 0x11, KEY_PROG1 }, | ||
278 | { KE_KEY, 0x12, KEY_PROG2 }, | ||
279 | { KE_WIFI, 0x30, 0 }, | ||
280 | { KE_KEY, 0x22, KEY_REWIND }, | ||
281 | { KE_KEY, 0x23, KEY_FORWARD }, | ||
282 | { KE_KEY, 0x24, KEY_PLAYPAUSE }, | ||
283 | { KE_KEY, 0x25, KEY_STOPCD }, | ||
284 | { KE_KEY, 0x31, KEY_MAIL }, | ||
285 | { KE_KEY, 0x36, KEY_WWW }, | ||
286 | { KE_END, 0 } | ||
287 | }; | ||
288 | |||
289 | static struct key_entry keymap_acer_aspire_1500[] = { | ||
290 | { KE_KEY, 0x11, KEY_PROG1 }, | ||
291 | { KE_KEY, 0x12, KEY_PROG2 }, | ||
292 | { KE_WIFI, 0x30, 0 }, | ||
293 | { KE_KEY, 0x31, KEY_MAIL }, | ||
294 | { KE_KEY, 0x36, KEY_WWW }, | ||
295 | { KE_BLUETOOTH, 0x44, 0 }, | ||
296 | { KE_END, 0 } | ||
297 | }; | ||
298 | |||
299 | /* | ||
300 | * If your machine is not here (which is currently rather likely), please send | ||
301 | * a list of buttons and their key codes (reported when loading this module | ||
302 | * with force=1) and the output of dmidecode to $MODULE_AUTHOR. | ||
303 | */ | ||
304 | static struct dmi_system_id dmi_ids[] = { | ||
305 | { | ||
306 | .callback = dmi_matched, | ||
307 | .ident = "Fujitsu-Siemens Amilo Pro V2000", | ||
308 | .matches = { | ||
309 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | ||
310 | DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"), | ||
311 | }, | ||
312 | .driver_data = keymap_fs_amilo_pro_v2000 | ||
313 | }, | ||
314 | { | ||
315 | .callback = dmi_matched, | ||
316 | .ident = "Acer Aspire 1500", | ||
317 | .matches = { | ||
318 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
319 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1500"), | ||
320 | }, | ||
321 | .driver_data = keymap_acer_aspire_1500 | ||
322 | }, | ||
323 | { NULL, } | ||
324 | }; | ||
325 | |||
326 | static int __init select_keymap(void) | ||
327 | { | ||
328 | if (keymap_name != NULL) { | ||
329 | if (strcmp (keymap_name, "1557/MS2141") == 0) | ||
330 | keymap = keymap_wistron_ms2141; | ||
331 | else { | ||
332 | printk(KERN_ERR "wistron_btns: Keymap unknown\n"); | ||
333 | return -EINVAL; | ||
334 | } | ||
335 | } | ||
336 | dmi_check_system(dmi_ids); | ||
337 | if (keymap == NULL) { | ||
338 | if (!force) { | ||
339 | printk(KERN_ERR "wistron_btns: System unknown\n"); | ||
340 | return -ENODEV; | ||
341 | } | ||
342 | keymap = keymap_empty; | ||
343 | } | ||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | /* Input layer interface */ | ||
348 | |||
349 | static struct input_dev *input_dev; | ||
350 | |||
351 | static int __init setup_input_dev(void) | ||
352 | { | ||
353 | const struct key_entry *key; | ||
354 | int error; | ||
355 | |||
356 | input_dev = input_allocate_device(); | ||
357 | if (!input_dev) | ||
358 | return -ENOMEM; | ||
359 | |||
360 | input_dev->name = "Wistron laptop buttons"; | ||
361 | input_dev->phys = "wistron/input0"; | ||
362 | input_dev->id.bustype = BUS_HOST; | ||
363 | input_dev->cdev.dev = &wistron_device->dev; | ||
364 | |||
365 | for (key = keymap; key->type != KE_END; key++) { | ||
366 | if (key->type == KE_KEY) { | ||
367 | input_dev->evbit[LONG(EV_KEY)] = BIT(EV_KEY); | ||
368 | set_bit(key->keycode, input_dev->keybit); | ||
369 | } | ||
370 | } | ||
371 | |||
372 | error = input_register_device(input_dev); | ||
373 | if (error) { | ||
374 | input_free_device(input_dev); | ||
375 | return error; | ||
376 | } | ||
377 | |||
378 | return 0; | ||
379 | } | ||
380 | |||
381 | static void report_key(unsigned keycode) | ||
382 | { | ||
383 | input_report_key(input_dev, keycode, 1); | ||
384 | input_sync(input_dev); | ||
385 | input_report_key(input_dev, keycode, 0); | ||
386 | input_sync(input_dev); | ||
387 | } | ||
388 | |||
389 | /* Driver core */ | ||
390 | |||
391 | static int wifi_enabled; | ||
392 | static int bluetooth_enabled; | ||
393 | |||
394 | static void poll_bios(unsigned long); | ||
395 | |||
396 | static struct timer_list poll_timer = TIMER_INITIALIZER(poll_bios, 0, 0); | ||
397 | |||
398 | static void handle_key(u8 code) | ||
399 | { | ||
400 | const struct key_entry *key; | ||
401 | |||
402 | for (key = keymap; key->type != KE_END; key++) { | ||
403 | if (code == key->code) { | ||
404 | switch (key->type) { | ||
405 | case KE_KEY: | ||
406 | report_key(key->keycode); | ||
407 | break; | ||
408 | |||
409 | case KE_WIFI: | ||
410 | if (have_wifi) { | ||
411 | wifi_enabled = !wifi_enabled; | ||
412 | bios_set_state(WIFI, wifi_enabled); | ||
413 | } | ||
414 | break; | ||
415 | |||
416 | case KE_BLUETOOTH: | ||
417 | if (have_bluetooth) { | ||
418 | bluetooth_enabled = !bluetooth_enabled; | ||
419 | bios_set_state(BLUETOOTH, bluetooth_enabled); | ||
420 | } | ||
421 | break; | ||
422 | |||
423 | case KE_END: | ||
424 | default: | ||
425 | BUG(); | ||
426 | } | ||
427 | return; | ||
428 | } | ||
429 | } | ||
430 | printk(KERN_NOTICE "wistron_btns: Unknown key code %02X\n", code); | ||
431 | } | ||
432 | |||
433 | static void poll_bios(unsigned long discard) | ||
434 | { | ||
435 | u8 qlen; | ||
436 | u16 val; | ||
437 | |||
438 | for (;;) { | ||
439 | qlen = CMOS_READ(cmos_address); | ||
440 | if (qlen == 0) | ||
441 | break; | ||
442 | val = bios_pop_queue(); | ||
443 | if (val != 0 && !discard) | ||
444 | handle_key((u8)val); | ||
445 | } | ||
446 | |||
447 | mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY); | ||
448 | } | ||
449 | |||
450 | static int wistron_suspend(struct platform_device *dev, pm_message_t state) | ||
451 | { | ||
452 | del_timer_sync(&poll_timer); | ||
453 | |||
454 | if (have_wifi) | ||
455 | bios_set_state(WIFI, 0); | ||
456 | |||
457 | if (have_bluetooth) | ||
458 | bios_set_state(BLUETOOTH, 0); | ||
459 | |||
460 | return 0; | ||
461 | } | ||
462 | |||
463 | static int wistron_resume(struct platform_device *dev) | ||
464 | { | ||
465 | if (have_wifi) | ||
466 | bios_set_state(WIFI, wifi_enabled); | ||
467 | |||
468 | if (have_bluetooth) | ||
469 | bios_set_state(BLUETOOTH, bluetooth_enabled); | ||
470 | |||
471 | poll_bios(1); | ||
472 | |||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | static struct platform_driver wistron_driver = { | ||
477 | .suspend = wistron_suspend, | ||
478 | .resume = wistron_resume, | ||
479 | .driver = { | ||
480 | .name = "wistron-bios", | ||
481 | }, | ||
482 | }; | ||
483 | |||
484 | static int __init wb_module_init(void) | ||
485 | { | ||
486 | int err; | ||
487 | |||
488 | err = select_keymap(); | ||
489 | if (err) | ||
490 | return err; | ||
491 | |||
492 | err = map_bios(); | ||
493 | if (err) | ||
494 | return err; | ||
495 | |||
496 | bios_attach(); | ||
497 | cmos_address = bios_get_cmos_address(); | ||
498 | |||
499 | err = platform_driver_register(&wistron_driver); | ||
500 | if (err) | ||
501 | goto err_detach_bios; | ||
502 | |||
503 | wistron_device = platform_device_register_simple("wistron-bios", -1, NULL, 0); | ||
504 | if (IS_ERR(wistron_device)) { | ||
505 | err = PTR_ERR(wistron_device); | ||
506 | goto err_unregister_driver; | ||
507 | } | ||
508 | |||
509 | if (have_wifi) { | ||
510 | u16 wifi = bios_get_default_setting(WIFI); | ||
511 | if (wifi & 1) | ||
512 | wifi_enabled = (wifi & 2) ? 1 : 0; | ||
513 | else | ||
514 | have_wifi = 0; | ||
515 | |||
516 | if (have_wifi) | ||
517 | bios_set_state(WIFI, wifi_enabled); | ||
518 | } | ||
519 | |||
520 | if (have_bluetooth) { | ||
521 | u16 bt = bios_get_default_setting(BLUETOOTH); | ||
522 | if (bt & 1) | ||
523 | bluetooth_enabled = (bt & 2) ? 1 : 0; | ||
524 | else | ||
525 | have_bluetooth = 0; | ||
526 | |||
527 | if (have_bluetooth) | ||
528 | bios_set_state(BLUETOOTH, bluetooth_enabled); | ||
529 | } | ||
530 | |||
531 | err = setup_input_dev(); | ||
532 | if (err) | ||
533 | goto err_unregister_device; | ||
534 | |||
535 | poll_bios(1); /* Flush stale event queue and arm timer */ | ||
536 | |||
537 | return 0; | ||
538 | |||
539 | err_unregister_device: | ||
540 | platform_device_unregister(wistron_device); | ||
541 | err_unregister_driver: | ||
542 | platform_driver_unregister(&wistron_driver); | ||
543 | err_detach_bios: | ||
544 | bios_detach(); | ||
545 | unmap_bios(); | ||
546 | |||
547 | return err; | ||
548 | } | ||
549 | |||
550 | static void __exit wb_module_exit(void) | ||
551 | { | ||
552 | del_timer_sync(&poll_timer); | ||
553 | input_unregister_device(input_dev); | ||
554 | platform_device_unregister(wistron_device); | ||
555 | platform_driver_unregister(&wistron_driver); | ||
556 | bios_detach(); | ||
557 | unmap_bios(); | ||
558 | } | ||
559 | |||
560 | module_init(wb_module_init); | ||
561 | module_exit(wb_module_exit); | ||
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 4acc7fd4cd0f..4f41ec3e4332 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -42,7 +42,7 @@ static struct alps_model_info alps_model_data[] = { | |||
42 | { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, | 42 | { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, |
43 | { { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, | 43 | { { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, |
44 | { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, | 44 | { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, |
45 | { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, 0 }, | 45 | { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */ |
46 | { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ | 46 | { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ |
47 | { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ | 47 | { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ |
48 | { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 }, | 48 | { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 }, |
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c index 4bf584364d28..2f9a04ae725f 100644 --- a/drivers/input/mouse/sermouse.c +++ b/drivers/input/mouse/sermouse.c | |||
@@ -95,7 +95,7 @@ static void sermouse_process_msc(struct sermouse *sermouse, signed char data, st | |||
95 | 95 | ||
96 | input_sync(dev); | 96 | input_sync(dev); |
97 | 97 | ||
98 | if (++sermouse->count == (5 - ((sermouse->type == SERIO_SUN) << 1))) | 98 | if (++sermouse->count == 5) |
99 | sermouse->count = 0; | 99 | sermouse->count = 0; |
100 | } | 100 | } |
101 | 101 | ||
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 01e186422021..ac86c1d1d83e 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
@@ -912,7 +912,7 @@ static long i8042_panic_blink(long count) | |||
912 | * Here we try to restore the original BIOS settings | 912 | * Here we try to restore the original BIOS settings |
913 | */ | 913 | */ |
914 | 914 | ||
915 | static int i8042_suspend(struct device *dev, pm_message_t state) | 915 | static int i8042_suspend(struct platform_device *dev, pm_message_t state) |
916 | { | 916 | { |
917 | del_timer_sync(&i8042_timer); | 917 | del_timer_sync(&i8042_timer); |
918 | i8042_controller_reset(); | 918 | i8042_controller_reset(); |
@@ -925,7 +925,7 @@ static int i8042_suspend(struct device *dev, pm_message_t state) | |||
925 | * Here we try to reset everything back to a state in which suspended | 925 | * Here we try to reset everything back to a state in which suspended |
926 | */ | 926 | */ |
927 | 927 | ||
928 | static int i8042_resume(struct device *dev) | 928 | static int i8042_resume(struct platform_device *dev) |
929 | { | 929 | { |
930 | int i; | 930 | int i; |
931 | 931 | ||
@@ -964,17 +964,18 @@ static int i8042_resume(struct device *dev) | |||
964 | * because otherwise BIOSes will be confused. | 964 | * because otherwise BIOSes will be confused. |
965 | */ | 965 | */ |
966 | 966 | ||
967 | static void i8042_shutdown(struct device *dev) | 967 | static void i8042_shutdown(struct platform_device *dev) |
968 | { | 968 | { |
969 | i8042_controller_cleanup(); | 969 | i8042_controller_cleanup(); |
970 | } | 970 | } |
971 | 971 | ||
972 | static struct device_driver i8042_driver = { | 972 | static struct platform_driver i8042_driver = { |
973 | .name = "i8042", | ||
974 | .bus = &platform_bus_type, | ||
975 | .suspend = i8042_suspend, | 973 | .suspend = i8042_suspend, |
976 | .resume = i8042_resume, | 974 | .resume = i8042_resume, |
977 | .shutdown = i8042_shutdown, | 975 | .shutdown = i8042_shutdown, |
976 | .driver = { | ||
977 | .name = "i8042", | ||
978 | }, | ||
978 | }; | 979 | }; |
979 | 980 | ||
980 | static int __init i8042_create_kbd_port(void) | 981 | static int __init i8042_create_kbd_port(void) |
@@ -1078,7 +1079,7 @@ static int __init i8042_init(void) | |||
1078 | goto err_platform_exit; | 1079 | goto err_platform_exit; |
1079 | } | 1080 | } |
1080 | 1081 | ||
1081 | err = driver_register(&i8042_driver); | 1082 | err = platform_driver_register(&i8042_driver); |
1082 | if (err) | 1083 | if (err) |
1083 | goto err_controller_cleanup; | 1084 | goto err_controller_cleanup; |
1084 | 1085 | ||
@@ -1126,7 +1127,7 @@ static int __init i8042_init(void) | |||
1126 | err_unregister_device: | 1127 | err_unregister_device: |
1127 | platform_device_unregister(i8042_platform_device); | 1128 | platform_device_unregister(i8042_platform_device); |
1128 | err_unregister_driver: | 1129 | err_unregister_driver: |
1129 | driver_unregister(&i8042_driver); | 1130 | platform_driver_unregister(&i8042_driver); |
1130 | err_controller_cleanup: | 1131 | err_controller_cleanup: |
1131 | i8042_controller_cleanup(); | 1132 | i8042_controller_cleanup(); |
1132 | err_platform_exit: | 1133 | err_platform_exit: |
@@ -1148,7 +1149,7 @@ static void __exit i8042_exit(void) | |||
1148 | del_timer_sync(&i8042_timer); | 1149 | del_timer_sync(&i8042_timer); |
1149 | 1150 | ||
1150 | platform_device_unregister(i8042_platform_device); | 1151 | platform_device_unregister(i8042_platform_device); |
1151 | driver_unregister(&i8042_driver); | 1152 | platform_driver_unregister(&i8042_driver); |
1152 | 1153 | ||
1153 | i8042_platform_exit(); | 1154 | i8042_platform_exit(); |
1154 | 1155 | ||
diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h index 13835039a2a7..cbbf3842da5b 100644 --- a/drivers/input/serio/i8042.h +++ b/drivers/input/serio/i8042.h | |||
@@ -21,7 +21,7 @@ | |||
21 | #include "i8042-ip22io.h" | 21 | #include "i8042-ip22io.h" |
22 | #elif defined(CONFIG_PPC) | 22 | #elif defined(CONFIG_PPC) |
23 | #include "i8042-ppcio.h" | 23 | #include "i8042-ppcio.h" |
24 | #elif defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64) | 24 | #elif defined(CONFIG_SPARC) |
25 | #include "i8042-sparcio.h" | 25 | #include "i8042-sparcio.h" |
26 | #elif defined(CONFIG_X86) || defined(CONFIG_IA64) | 26 | #elif defined(CONFIG_X86) || defined(CONFIG_IA64) |
27 | #include "i8042-x86ia64io.h" | 27 | #include "i8042-x86ia64io.h" |
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c index 52c49258f8a4..a3bd11589bc3 100644 --- a/drivers/input/serio/rpckbd.c +++ b/drivers/input/serio/rpckbd.c | |||
@@ -107,7 +107,7 @@ static void rpckbd_close(struct serio *port) | |||
107 | * Allocate and initialize serio structure for subsequent registration | 107 | * Allocate and initialize serio structure for subsequent registration |
108 | * with serio core. | 108 | * with serio core. |
109 | */ | 109 | */ |
110 | static int __devinit rpckbd_probe(struct device *dev) | 110 | static int __devinit rpckbd_probe(struct platform_device *dev) |
111 | { | 111 | { |
112 | struct serio *serio; | 112 | struct serio *serio; |
113 | 113 | ||
@@ -120,37 +120,38 @@ static int __devinit rpckbd_probe(struct device *dev) | |||
120 | serio->write = rpckbd_write; | 120 | serio->write = rpckbd_write; |
121 | serio->open = rpckbd_open; | 121 | serio->open = rpckbd_open; |
122 | serio->close = rpckbd_close; | 122 | serio->close = rpckbd_close; |
123 | serio->dev.parent = dev; | 123 | serio->dev.parent = &dev->dev; |
124 | strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name)); | 124 | strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name)); |
125 | strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys)); | 125 | strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys)); |
126 | 126 | ||
127 | dev_set_drvdata(dev, serio); | 127 | platform_set_drvdata(dev, serio); |
128 | serio_register_port(serio); | 128 | serio_register_port(serio); |
129 | return 0; | 129 | return 0; |
130 | } | 130 | } |
131 | 131 | ||
132 | static int __devexit rpckbd_remove(struct device *dev) | 132 | static int __devexit rpckbd_remove(struct platform_device *dev) |
133 | { | 133 | { |
134 | struct serio *serio = dev_get_drvdata(dev); | 134 | struct serio *serio = platform_get_drvdata(dev); |
135 | serio_unregister_port(serio); | 135 | serio_unregister_port(serio); |
136 | return 0; | 136 | return 0; |
137 | } | 137 | } |
138 | 138 | ||
139 | static struct device_driver rpckbd_driver = { | 139 | static struct platform_driver rpckbd_driver = { |
140 | .name = "kart", | ||
141 | .bus = &platform_bus_type, | ||
142 | .probe = rpckbd_probe, | 140 | .probe = rpckbd_probe, |
143 | .remove = __devexit_p(rpckbd_remove), | 141 | .remove = __devexit_p(rpckbd_remove), |
142 | .driver = { | ||
143 | .name = "kart", | ||
144 | }, | ||
144 | }; | 145 | }; |
145 | 146 | ||
146 | static int __init rpckbd_init(void) | 147 | static int __init rpckbd_init(void) |
147 | { | 148 | { |
148 | return driver_register(&rpckbd_driver); | 149 | return platform_driver_register(&rpckbd_driver); |
149 | } | 150 | } |
150 | 151 | ||
151 | static void __exit rpckbd_exit(void) | 152 | static void __exit rpckbd_exit(void) |
152 | { | 153 | { |
153 | driver_unregister(&rpckbd_driver); | 154 | platform_driver_unregister(&rpckbd_driver); |
154 | } | 155 | } |
155 | 156 | ||
156 | module_init(rpckbd_init); | 157 | module_init(rpckbd_init); |
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index edd15db17715..fbb69ef6a77b 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
@@ -269,14 +269,20 @@ static struct serio_event *serio_get_event(void) | |||
269 | return event; | 269 | return event; |
270 | } | 270 | } |
271 | 271 | ||
272 | static void serio_handle_events(void) | 272 | static void serio_handle_event(void) |
273 | { | 273 | { |
274 | struct serio_event *event; | 274 | struct serio_event *event; |
275 | struct serio_driver *serio_drv; | 275 | struct serio_driver *serio_drv; |
276 | 276 | ||
277 | down(&serio_sem); | 277 | down(&serio_sem); |
278 | 278 | ||
279 | while ((event = serio_get_event())) { | 279 | /* |
280 | * Note that we handle only one event here to give swsusp | ||
281 | * a chance to freeze kseriod thread. Serio events should | ||
282 | * be pretty rare so we are not concerned about taking | ||
283 | * performance hit. | ||
284 | */ | ||
285 | if ((event = serio_get_event())) { | ||
280 | 286 | ||
281 | switch (event->type) { | 287 | switch (event->type) { |
282 | case SERIO_REGISTER_PORT: | 288 | case SERIO_REGISTER_PORT: |
@@ -368,7 +374,7 @@ static struct serio *serio_get_pending_child(struct serio *parent) | |||
368 | static int serio_thread(void *nothing) | 374 | static int serio_thread(void *nothing) |
369 | { | 375 | { |
370 | do { | 376 | do { |
371 | serio_handle_events(); | 377 | serio_handle_event(); |
372 | wait_event_interruptible(serio_wait, | 378 | wait_event_interruptible(serio_wait, |
373 | kthread_should_stop() || !list_empty(&serio_event_list)); | 379 | kthread_should_stop() || !list_empty(&serio_event_list)); |
374 | try_to_freeze(); | 380 | try_to_freeze(); |
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 15e88eeae8d6..1042987856f7 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c | |||
@@ -231,9 +231,9 @@ static irqreturn_t ts_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
231 | } | 231 | } |
232 | 232 | ||
233 | #ifdef CONFIG_PM | 233 | #ifdef CONFIG_PM |
234 | static int corgits_suspend(struct device *dev, pm_message_t state) | 234 | static int corgits_suspend(struct platform_device *dev, pm_message_t state) |
235 | { | 235 | { |
236 | struct corgi_ts *corgi_ts = dev_get_drvdata(dev); | 236 | struct corgi_ts *corgi_ts = platform_get_drvdata(dev); |
237 | 237 | ||
238 | if (corgi_ts->pendown) { | 238 | if (corgi_ts->pendown) { |
239 | del_timer_sync(&corgi_ts->timer); | 239 | del_timer_sync(&corgi_ts->timer); |
@@ -248,9 +248,9 @@ static int corgits_suspend(struct device *dev, pm_message_t state) | |||
248 | return 0; | 248 | return 0; |
249 | } | 249 | } |
250 | 250 | ||
251 | static int corgits_resume(struct device *dev) | 251 | static int corgits_resume(struct platform_device *dev) |
252 | { | 252 | { |
253 | struct corgi_ts *corgi_ts = dev_get_drvdata(dev); | 253 | struct corgi_ts *corgi_ts = platform_get_drvdata(dev); |
254 | 254 | ||
255 | corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | 255 | corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); |
256 | /* Enable Falling Edge */ | 256 | /* Enable Falling Edge */ |
@@ -264,10 +264,9 @@ static int corgits_resume(struct device *dev) | |||
264 | #define corgits_resume NULL | 264 | #define corgits_resume NULL |
265 | #endif | 265 | #endif |
266 | 266 | ||
267 | static int __init corgits_probe(struct device *dev) | 267 | static int __init corgits_probe(struct platform_device *pdev) |
268 | { | 268 | { |
269 | struct corgi_ts *corgi_ts; | 269 | struct corgi_ts *corgi_ts; |
270 | struct platform_device *pdev = to_platform_device(dev); | ||
271 | struct input_dev *input_dev; | 270 | struct input_dev *input_dev; |
272 | int err = -ENOMEM; | 271 | int err = -ENOMEM; |
273 | 272 | ||
@@ -276,9 +275,9 @@ static int __init corgits_probe(struct device *dev) | |||
276 | if (!corgi_ts || !input_dev) | 275 | if (!corgi_ts || !input_dev) |
277 | goto fail; | 276 | goto fail; |
278 | 277 | ||
279 | dev_set_drvdata(dev, corgi_ts); | 278 | platform_set_drvdata(pdev, corgi_ts); |
280 | 279 | ||
281 | corgi_ts->machinfo = dev->platform_data; | 280 | corgi_ts->machinfo = pdev->dev.platform_data; |
282 | corgi_ts->irq_gpio = platform_get_irq(pdev, 0); | 281 | corgi_ts->irq_gpio = platform_get_irq(pdev, 0); |
283 | 282 | ||
284 | if (corgi_ts->irq_gpio < 0) { | 283 | if (corgi_ts->irq_gpio < 0) { |
@@ -298,7 +297,7 @@ static int __init corgits_probe(struct device *dev) | |||
298 | input_dev->id.vendor = 0x0001; | 297 | input_dev->id.vendor = 0x0001; |
299 | input_dev->id.product = 0x0002; | 298 | input_dev->id.product = 0x0002; |
300 | input_dev->id.version = 0x0100; | 299 | input_dev->id.version = 0x0100; |
301 | input_dev->cdev.dev = dev; | 300 | input_dev->cdev.dev = &pdev->dev; |
302 | input_dev->private = corgi_ts; | 301 | input_dev->private = corgi_ts; |
303 | 302 | ||
304 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 303 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
@@ -339,9 +338,9 @@ static int __init corgits_probe(struct device *dev) | |||
339 | 338 | ||
340 | } | 339 | } |
341 | 340 | ||
342 | static int corgits_remove(struct device *dev) | 341 | static int corgits_remove(struct platform_device *pdev) |
343 | { | 342 | { |
344 | struct corgi_ts *corgi_ts = dev_get_drvdata(dev); | 343 | struct corgi_ts *corgi_ts = platform_get_drvdata(pdev); |
345 | 344 | ||
346 | free_irq(corgi_ts->irq_gpio, NULL); | 345 | free_irq(corgi_ts->irq_gpio, NULL); |
347 | del_timer_sync(&corgi_ts->timer); | 346 | del_timer_sync(&corgi_ts->timer); |
@@ -351,23 +350,24 @@ static int corgits_remove(struct device *dev) | |||
351 | return 0; | 350 | return 0; |
352 | } | 351 | } |
353 | 352 | ||
354 | static struct device_driver corgits_driver = { | 353 | static struct platform_driver corgits_driver = { |
355 | .name = "corgi-ts", | ||
356 | .bus = &platform_bus_type, | ||
357 | .probe = corgits_probe, | 354 | .probe = corgits_probe, |
358 | .remove = corgits_remove, | 355 | .remove = corgits_remove, |
359 | .suspend = corgits_suspend, | 356 | .suspend = corgits_suspend, |
360 | .resume = corgits_resume, | 357 | .resume = corgits_resume, |
358 | .driver = { | ||
359 | .name = "corgi-ts", | ||
360 | }, | ||
361 | }; | 361 | }; |
362 | 362 | ||
363 | static int __devinit corgits_init(void) | 363 | static int __devinit corgits_init(void) |
364 | { | 364 | { |
365 | return driver_register(&corgits_driver); | 365 | return platform_driver_register(&corgits_driver); |
366 | } | 366 | } |
367 | 367 | ||
368 | static void __exit corgits_exit(void) | 368 | static void __exit corgits_exit(void) |
369 | { | 369 | { |
370 | driver_unregister(&corgits_driver); | 370 | platform_driver_unregister(&corgits_driver); |
371 | } | 371 | } |
372 | 372 | ||
373 | module_init(corgits_init); | 373 | module_init(corgits_init); |