diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-10-01 17:20:58 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-10-01 17:20:58 -0400 |
commit | dde3ada3d0069855eeb353707b2b0f946191cfd6 (patch) | |
tree | bdc2d358f8dc7fc29000149ebc4db949934b15b2 /drivers/input/keyboard | |
parent | 5e056ef4ddeb6129f6bb170f2c26b8f370bbcda7 (diff) | |
parent | fb4f552e895cec29934d94a99cbd1f1f00448a88 (diff) |
Merge branch 'next' into for-linus
Prepare first set of updates for 3.7 merge window.
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 169 | ||||
-rw-r--r-- | drivers/input/keyboard/gpio_keys_polled.c | 147 | ||||
-rw-r--r-- | drivers/input/keyboard/omap-keypad.c | 8 | ||||
-rw-r--r-- | drivers/input/keyboard/samsung-keypad.c | 10 | ||||
-rw-r--r-- | drivers/input/keyboard/tegra-kbc.c | 2 |
5 files changed, 231 insertions, 105 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index cbb1add43d5e..6a68041c261d 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -43,11 +43,9 @@ struct gpio_button_data { | |||
43 | }; | 43 | }; |
44 | 44 | ||
45 | struct gpio_keys_drvdata { | 45 | struct gpio_keys_drvdata { |
46 | const struct gpio_keys_platform_data *pdata; | ||
46 | struct input_dev *input; | 47 | struct input_dev *input; |
47 | struct mutex disable_lock; | 48 | struct mutex disable_lock; |
48 | unsigned int n_buttons; | ||
49 | int (*enable)(struct device *dev); | ||
50 | void (*disable)(struct device *dev); | ||
51 | struct gpio_button_data data[0]; | 49 | struct gpio_button_data data[0]; |
52 | }; | 50 | }; |
53 | 51 | ||
@@ -171,7 +169,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata, | |||
171 | if (!bits) | 169 | if (!bits) |
172 | return -ENOMEM; | 170 | return -ENOMEM; |
173 | 171 | ||
174 | for (i = 0; i < ddata->n_buttons; i++) { | 172 | for (i = 0; i < ddata->pdata->nbuttons; i++) { |
175 | struct gpio_button_data *bdata = &ddata->data[i]; | 173 | struct gpio_button_data *bdata = &ddata->data[i]; |
176 | 174 | ||
177 | if (bdata->button->type != type) | 175 | if (bdata->button->type != type) |
@@ -219,7 +217,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, | |||
219 | goto out; | 217 | goto out; |
220 | 218 | ||
221 | /* First validate */ | 219 | /* First validate */ |
222 | for (i = 0; i < ddata->n_buttons; i++) { | 220 | for (i = 0; i < ddata->pdata->nbuttons; i++) { |
223 | struct gpio_button_data *bdata = &ddata->data[i]; | 221 | struct gpio_button_data *bdata = &ddata->data[i]; |
224 | 222 | ||
225 | if (bdata->button->type != type) | 223 | if (bdata->button->type != type) |
@@ -234,7 +232,7 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, | |||
234 | 232 | ||
235 | mutex_lock(&ddata->disable_lock); | 233 | mutex_lock(&ddata->disable_lock); |
236 | 234 | ||
237 | for (i = 0; i < ddata->n_buttons; i++) { | 235 | for (i = 0; i < ddata->pdata->nbuttons; i++) { |
238 | struct gpio_button_data *bdata = &ddata->data[i]; | 236 | struct gpio_button_data *bdata = &ddata->data[i]; |
239 | 237 | ||
240 | if (bdata->button->type != type) | 238 | if (bdata->button->type != type) |
@@ -346,6 +344,9 @@ static void gpio_keys_gpio_work_func(struct work_struct *work) | |||
346 | container_of(work, struct gpio_button_data, work); | 344 | container_of(work, struct gpio_button_data, work); |
347 | 345 | ||
348 | gpio_keys_gpio_report_event(bdata); | 346 | gpio_keys_gpio_report_event(bdata); |
347 | |||
348 | if (bdata->button->wakeup) | ||
349 | pm_relax(bdata->input->dev.parent); | ||
349 | } | 350 | } |
350 | 351 | ||
351 | static void gpio_keys_gpio_timer(unsigned long _data) | 352 | static void gpio_keys_gpio_timer(unsigned long _data) |
@@ -361,6 +362,8 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) | |||
361 | 362 | ||
362 | BUG_ON(irq != bdata->irq); | 363 | BUG_ON(irq != bdata->irq); |
363 | 364 | ||
365 | if (bdata->button->wakeup) | ||
366 | pm_stay_awake(bdata->input->dev.parent); | ||
364 | if (bdata->timer_debounce) | 367 | if (bdata->timer_debounce) |
365 | mod_timer(&bdata->timer, | 368 | mod_timer(&bdata->timer, |
366 | jiffies + msecs_to_jiffies(bdata->timer_debounce)); | 369 | jiffies + msecs_to_jiffies(bdata->timer_debounce)); |
@@ -397,6 +400,9 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) | |||
397 | spin_lock_irqsave(&bdata->lock, flags); | 400 | spin_lock_irqsave(&bdata->lock, flags); |
398 | 401 | ||
399 | if (!bdata->key_pressed) { | 402 | if (!bdata->key_pressed) { |
403 | if (bdata->button->wakeup) | ||
404 | pm_wakeup_event(bdata->input->dev.parent, 0); | ||
405 | |||
400 | input_event(input, EV_KEY, button->code, 1); | 406 | input_event(input, EV_KEY, button->code, 1); |
401 | input_sync(input); | 407 | input_sync(input); |
402 | 408 | ||
@@ -523,56 +529,64 @@ fail: | |||
523 | static int gpio_keys_open(struct input_dev *input) | 529 | static int gpio_keys_open(struct input_dev *input) |
524 | { | 530 | { |
525 | struct gpio_keys_drvdata *ddata = input_get_drvdata(input); | 531 | struct gpio_keys_drvdata *ddata = input_get_drvdata(input); |
532 | const struct gpio_keys_platform_data *pdata = ddata->pdata; | ||
526 | 533 | ||
527 | return ddata->enable ? ddata->enable(input->dev.parent) : 0; | 534 | return pdata->enable ? pdata->enable(input->dev.parent) : 0; |
528 | } | 535 | } |
529 | 536 | ||
530 | static void gpio_keys_close(struct input_dev *input) | 537 | static void gpio_keys_close(struct input_dev *input) |
531 | { | 538 | { |
532 | struct gpio_keys_drvdata *ddata = input_get_drvdata(input); | 539 | struct gpio_keys_drvdata *ddata = input_get_drvdata(input); |
540 | const struct gpio_keys_platform_data *pdata = ddata->pdata; | ||
533 | 541 | ||
534 | if (ddata->disable) | 542 | if (pdata->disable) |
535 | ddata->disable(input->dev.parent); | 543 | pdata->disable(input->dev.parent); |
536 | } | 544 | } |
537 | 545 | ||
538 | /* | 546 | /* |
539 | * Handlers for alternative sources of platform_data | 547 | * Handlers for alternative sources of platform_data |
540 | */ | 548 | */ |
549 | |||
541 | #ifdef CONFIG_OF | 550 | #ifdef CONFIG_OF |
542 | /* | 551 | /* |
543 | * Translate OpenFirmware node properties into platform_data | 552 | * Translate OpenFirmware node properties into platform_data |
544 | */ | 553 | */ |
545 | static int gpio_keys_get_devtree_pdata(struct device *dev, | 554 | static struct gpio_keys_platform_data * __devinit |
546 | struct gpio_keys_platform_data *pdata) | 555 | gpio_keys_get_devtree_pdata(struct device *dev) |
547 | { | 556 | { |
548 | struct device_node *node, *pp; | 557 | struct device_node *node, *pp; |
558 | struct gpio_keys_platform_data *pdata; | ||
559 | struct gpio_keys_button *button; | ||
560 | int error; | ||
561 | int nbuttons; | ||
549 | int i; | 562 | int i; |
550 | struct gpio_keys_button *buttons; | ||
551 | u32 reg; | ||
552 | 563 | ||
553 | node = dev->of_node; | 564 | node = dev->of_node; |
554 | if (node == NULL) | 565 | if (!node) { |
555 | return -ENODEV; | 566 | error = -ENODEV; |
556 | 567 | goto err_out; | |
557 | memset(pdata, 0, sizeof *pdata); | 568 | } |
558 | 569 | ||
559 | pdata->rep = !!of_get_property(node, "autorepeat", NULL); | 570 | nbuttons = of_get_child_count(node); |
571 | if (nbuttons == 0) { | ||
572 | error = -ENODEV; | ||
573 | goto err_out; | ||
574 | } | ||
560 | 575 | ||
561 | /* First count the subnodes */ | 576 | pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button), |
562 | pp = NULL; | 577 | GFP_KERNEL); |
563 | while ((pp = of_get_next_child(node, pp))) | 578 | if (!pdata) { |
564 | pdata->nbuttons++; | 579 | error = -ENOMEM; |
580 | goto err_out; | ||
581 | } | ||
565 | 582 | ||
566 | if (pdata->nbuttons == 0) | 583 | pdata->buttons = (struct gpio_keys_button *)(pdata + 1); |
567 | return -ENODEV; | 584 | pdata->nbuttons = nbuttons; |
568 | 585 | ||
569 | buttons = kzalloc(pdata->nbuttons * (sizeof *buttons), GFP_KERNEL); | 586 | pdata->rep = !!of_get_property(node, "autorepeat", NULL); |
570 | if (!buttons) | ||
571 | return -ENOMEM; | ||
572 | 587 | ||
573 | pp = NULL; | ||
574 | i = 0; | 588 | i = 0; |
575 | while ((pp = of_get_next_child(node, pp))) { | 589 | for_each_child_of_node(node, pp) { |
576 | enum of_gpio_flags flags; | 590 | enum of_gpio_flags flags; |
577 | 591 | ||
578 | if (!of_find_property(pp, "gpios", NULL)) { | 592 | if (!of_find_property(pp, "gpios", NULL)) { |
@@ -580,39 +594,42 @@ static int gpio_keys_get_devtree_pdata(struct device *dev, | |||
580 | dev_warn(dev, "Found button without gpios\n"); | 594 | dev_warn(dev, "Found button without gpios\n"); |
581 | continue; | 595 | continue; |
582 | } | 596 | } |
583 | buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags); | ||
584 | buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW; | ||
585 | 597 | ||
586 | if (of_property_read_u32(pp, "linux,code", ®)) { | 598 | button = &pdata->buttons[i++]; |
587 | dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio); | ||
588 | goto out_fail; | ||
589 | } | ||
590 | buttons[i].code = reg; | ||
591 | 599 | ||
592 | buttons[i].desc = of_get_property(pp, "label", NULL); | 600 | button->gpio = of_get_gpio_flags(pp, 0, &flags); |
601 | button->active_low = flags & OF_GPIO_ACTIVE_LOW; | ||
593 | 602 | ||
594 | if (of_property_read_u32(pp, "linux,input-type", ®) == 0) | 603 | if (of_property_read_u32(pp, "linux,code", &button->code)) { |
595 | buttons[i].type = reg; | 604 | dev_err(dev, "Button without keycode: 0x%x\n", |
596 | else | 605 | button->gpio); |
597 | buttons[i].type = EV_KEY; | 606 | error = -EINVAL; |
607 | goto err_free_pdata; | ||
608 | } | ||
598 | 609 | ||
599 | buttons[i].wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); | 610 | button->desc = of_get_property(pp, "label", NULL); |
600 | 611 | ||
601 | if (of_property_read_u32(pp, "debounce-interval", ®) == 0) | 612 | if (of_property_read_u32(pp, "linux,input-type", &button->type)) |
602 | buttons[i].debounce_interval = reg; | 613 | button->type = EV_KEY; |
603 | else | ||
604 | buttons[i].debounce_interval = 5; | ||
605 | 614 | ||
606 | i++; | 615 | button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); |
616 | |||
617 | if (of_property_read_u32(pp, "debounce-interval", | ||
618 | &button->debounce_interval)) | ||
619 | button->debounce_interval = 5; | ||
607 | } | 620 | } |
608 | 621 | ||
609 | pdata->buttons = buttons; | 622 | if (pdata->nbuttons == 0) { |
623 | error = -EINVAL; | ||
624 | goto err_free_pdata; | ||
625 | } | ||
610 | 626 | ||
611 | return 0; | 627 | return pdata; |
612 | 628 | ||
613 | out_fail: | 629 | err_free_pdata: |
614 | kfree(buttons); | 630 | kfree(pdata); |
615 | return -ENODEV; | 631 | err_out: |
632 | return ERR_PTR(error); | ||
616 | } | 633 | } |
617 | 634 | ||
618 | static struct of_device_id gpio_keys_of_match[] = { | 635 | static struct of_device_id gpio_keys_of_match[] = { |
@@ -623,14 +640,12 @@ MODULE_DEVICE_TABLE(of, gpio_keys_of_match); | |||
623 | 640 | ||
624 | #else | 641 | #else |
625 | 642 | ||
626 | static int gpio_keys_get_devtree_pdata(struct device *dev, | 643 | static inline struct gpio_keys_platform_data * |
627 | struct gpio_keys_platform_data *altp) | 644 | gpio_keys_get_devtree_pdata(struct device *dev) |
628 | { | 645 | { |
629 | return -ENODEV; | 646 | return ERR_PTR(-ENODEV); |
630 | } | 647 | } |
631 | 648 | ||
632 | #define gpio_keys_of_match NULL | ||
633 | |||
634 | #endif | 649 | #endif |
635 | 650 | ||
636 | static void gpio_remove_key(struct gpio_button_data *bdata) | 651 | static void gpio_remove_key(struct gpio_button_data *bdata) |
@@ -645,19 +660,17 @@ static void gpio_remove_key(struct gpio_button_data *bdata) | |||
645 | 660 | ||
646 | static int __devinit gpio_keys_probe(struct platform_device *pdev) | 661 | static int __devinit gpio_keys_probe(struct platform_device *pdev) |
647 | { | 662 | { |
648 | const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; | ||
649 | struct gpio_keys_drvdata *ddata; | ||
650 | struct device *dev = &pdev->dev; | 663 | struct device *dev = &pdev->dev; |
651 | struct gpio_keys_platform_data alt_pdata; | 664 | const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev); |
665 | struct gpio_keys_drvdata *ddata; | ||
652 | struct input_dev *input; | 666 | struct input_dev *input; |
653 | int i, error; | 667 | int i, error; |
654 | int wakeup = 0; | 668 | int wakeup = 0; |
655 | 669 | ||
656 | if (!pdata) { | 670 | if (!pdata) { |
657 | error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); | 671 | pdata = gpio_keys_get_devtree_pdata(dev); |
658 | if (error) | 672 | if (IS_ERR(pdata)) |
659 | return error; | 673 | return PTR_ERR(pdata); |
660 | pdata = &alt_pdata; | ||
661 | } | 674 | } |
662 | 675 | ||
663 | ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + | 676 | ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + |
@@ -670,10 +683,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
670 | goto fail1; | 683 | goto fail1; |
671 | } | 684 | } |
672 | 685 | ||
686 | ddata->pdata = pdata; | ||
673 | ddata->input = input; | 687 | ddata->input = input; |
674 | ddata->n_buttons = pdata->nbuttons; | ||
675 | ddata->enable = pdata->enable; | ||
676 | ddata->disable = pdata->disable; | ||
677 | mutex_init(&ddata->disable_lock); | 688 | mutex_init(&ddata->disable_lock); |
678 | 689 | ||
679 | platform_set_drvdata(pdev, ddata); | 690 | platform_set_drvdata(pdev, ddata); |
@@ -742,9 +753,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
742 | fail1: | 753 | fail1: |
743 | input_free_device(input); | 754 | input_free_device(input); |
744 | kfree(ddata); | 755 | kfree(ddata); |
745 | /* If we have no platform_data, we allocated buttons dynamically. */ | 756 | /* If we have no platform data, we allocated pdata dynamically. */ |
746 | if (!pdev->dev.platform_data) | 757 | if (!dev_get_platdata(&pdev->dev)) |
747 | kfree(pdata->buttons); | 758 | kfree(pdata); |
748 | 759 | ||
749 | return error; | 760 | return error; |
750 | } | 761 | } |
@@ -759,18 +770,14 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) | |||
759 | 770 | ||
760 | device_init_wakeup(&pdev->dev, 0); | 771 | device_init_wakeup(&pdev->dev, 0); |
761 | 772 | ||
762 | for (i = 0; i < ddata->n_buttons; i++) | 773 | for (i = 0; i < ddata->pdata->nbuttons; i++) |
763 | gpio_remove_key(&ddata->data[i]); | 774 | gpio_remove_key(&ddata->data[i]); |
764 | 775 | ||
765 | input_unregister_device(input); | 776 | input_unregister_device(input); |
766 | 777 | ||
767 | /* | 778 | /* If we have no platform data, we allocated pdata dynamically. */ |
768 | * If we had no platform_data, we allocated buttons dynamically, and | 779 | if (!dev_get_platdata(&pdev->dev)) |
769 | * must free them here. ddata->data[0].button is the pointer to the | 780 | kfree(ddata->pdata); |
770 | * beginning of the allocated array. | ||
771 | */ | ||
772 | if (!pdev->dev.platform_data) | ||
773 | kfree(ddata->data[0].button); | ||
774 | 781 | ||
775 | kfree(ddata); | 782 | kfree(ddata); |
776 | 783 | ||
@@ -784,7 +791,7 @@ static int gpio_keys_suspend(struct device *dev) | |||
784 | int i; | 791 | int i; |
785 | 792 | ||
786 | if (device_may_wakeup(dev)) { | 793 | if (device_may_wakeup(dev)) { |
787 | for (i = 0; i < ddata->n_buttons; i++) { | 794 | for (i = 0; i < ddata->pdata->nbuttons; i++) { |
788 | struct gpio_button_data *bdata = &ddata->data[i]; | 795 | struct gpio_button_data *bdata = &ddata->data[i]; |
789 | if (bdata->button->wakeup) | 796 | if (bdata->button->wakeup) |
790 | enable_irq_wake(bdata->irq); | 797 | enable_irq_wake(bdata->irq); |
@@ -799,7 +806,7 @@ static int gpio_keys_resume(struct device *dev) | |||
799 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); | 806 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); |
800 | int i; | 807 | int i; |
801 | 808 | ||
802 | for (i = 0; i < ddata->n_buttons; i++) { | 809 | for (i = 0; i < ddata->pdata->nbuttons; i++) { |
803 | struct gpio_button_data *bdata = &ddata->data[i]; | 810 | struct gpio_button_data *bdata = &ddata->data[i]; |
804 | if (bdata->button->wakeup && device_may_wakeup(dev)) | 811 | if (bdata->button->wakeup && device_may_wakeup(dev)) |
805 | disable_irq_wake(bdata->irq); | 812 | disable_irq_wake(bdata->irq); |
@@ -822,7 +829,7 @@ static struct platform_driver gpio_keys_device_driver = { | |||
822 | .name = "gpio-keys", | 829 | .name = "gpio-keys", |
823 | .owner = THIS_MODULE, | 830 | .owner = THIS_MODULE, |
824 | .pm = &gpio_keys_pm_ops, | 831 | .pm = &gpio_keys_pm_ops, |
825 | .of_match_table = gpio_keys_of_match, | 832 | .of_match_table = of_match_ptr(gpio_keys_of_match), |
826 | } | 833 | } |
827 | }; | 834 | }; |
828 | 835 | ||
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index 20c8ab172214..f2142de789e7 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
27 | #include <linux/gpio_keys.h> | 27 | #include <linux/gpio_keys.h> |
28 | #include <linux/of_platform.h> | ||
29 | #include <linux/of_gpio.h> | ||
28 | 30 | ||
29 | #define DRV_NAME "gpio-keys-polled" | 31 | #define DRV_NAME "gpio-keys-polled" |
30 | 32 | ||
@@ -38,7 +40,7 @@ struct gpio_keys_button_data { | |||
38 | struct gpio_keys_polled_dev { | 40 | struct gpio_keys_polled_dev { |
39 | struct input_polled_dev *poll_dev; | 41 | struct input_polled_dev *poll_dev; |
40 | struct device *dev; | 42 | struct device *dev; |
41 | struct gpio_keys_platform_data *pdata; | 43 | const struct gpio_keys_platform_data *pdata; |
42 | struct gpio_keys_button_data data[0]; | 44 | struct gpio_keys_button_data data[0]; |
43 | }; | 45 | }; |
44 | 46 | ||
@@ -67,11 +69,11 @@ static void gpio_keys_polled_check_state(struct input_dev *input, | |||
67 | static void gpio_keys_polled_poll(struct input_polled_dev *dev) | 69 | static void gpio_keys_polled_poll(struct input_polled_dev *dev) |
68 | { | 70 | { |
69 | struct gpio_keys_polled_dev *bdev = dev->private; | 71 | struct gpio_keys_polled_dev *bdev = dev->private; |
70 | struct gpio_keys_platform_data *pdata = bdev->pdata; | 72 | const struct gpio_keys_platform_data *pdata = bdev->pdata; |
71 | struct input_dev *input = dev->input; | 73 | struct input_dev *input = dev->input; |
72 | int i; | 74 | int i; |
73 | 75 | ||
74 | for (i = 0; i < bdev->pdata->nbuttons; i++) { | 76 | for (i = 0; i < pdata->nbuttons; i++) { |
75 | struct gpio_keys_button_data *bdata = &bdev->data[i]; | 77 | struct gpio_keys_button_data *bdata = &bdev->data[i]; |
76 | 78 | ||
77 | if (bdata->count < bdata->threshold) | 79 | if (bdata->count < bdata->threshold) |
@@ -85,7 +87,7 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev) | |||
85 | static void gpio_keys_polled_open(struct input_polled_dev *dev) | 87 | static void gpio_keys_polled_open(struct input_polled_dev *dev) |
86 | { | 88 | { |
87 | struct gpio_keys_polled_dev *bdev = dev->private; | 89 | struct gpio_keys_polled_dev *bdev = dev->private; |
88 | struct gpio_keys_platform_data *pdata = bdev->pdata; | 90 | const struct gpio_keys_platform_data *pdata = bdev->pdata; |
89 | 91 | ||
90 | if (pdata->enable) | 92 | if (pdata->enable) |
91 | pdata->enable(bdev->dev); | 93 | pdata->enable(bdev->dev); |
@@ -94,31 +96,139 @@ static void gpio_keys_polled_open(struct input_polled_dev *dev) | |||
94 | static void gpio_keys_polled_close(struct input_polled_dev *dev) | 96 | static void gpio_keys_polled_close(struct input_polled_dev *dev) |
95 | { | 97 | { |
96 | struct gpio_keys_polled_dev *bdev = dev->private; | 98 | struct gpio_keys_polled_dev *bdev = dev->private; |
97 | struct gpio_keys_platform_data *pdata = bdev->pdata; | 99 | const struct gpio_keys_platform_data *pdata = bdev->pdata; |
98 | 100 | ||
99 | if (pdata->disable) | 101 | if (pdata->disable) |
100 | pdata->disable(bdev->dev); | 102 | pdata->disable(bdev->dev); |
101 | } | 103 | } |
102 | 104 | ||
105 | #ifdef CONFIG_OF | ||
106 | static struct gpio_keys_platform_data * __devinit | ||
107 | gpio_keys_polled_get_devtree_pdata(struct device *dev) | ||
108 | { | ||
109 | struct device_node *node, *pp; | ||
110 | struct gpio_keys_platform_data *pdata; | ||
111 | struct gpio_keys_button *button; | ||
112 | int error; | ||
113 | int nbuttons; | ||
114 | int i; | ||
115 | |||
116 | node = dev->of_node; | ||
117 | if (!node) | ||
118 | return NULL; | ||
119 | |||
120 | nbuttons = of_get_child_count(node); | ||
121 | if (nbuttons == 0) | ||
122 | return NULL; | ||
123 | |||
124 | pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button), | ||
125 | GFP_KERNEL); | ||
126 | if (!pdata) { | ||
127 | error = -ENOMEM; | ||
128 | goto err_out; | ||
129 | } | ||
130 | |||
131 | pdata->buttons = (struct gpio_keys_button *)(pdata + 1); | ||
132 | pdata->nbuttons = nbuttons; | ||
133 | |||
134 | pdata->rep = !!of_get_property(node, "autorepeat", NULL); | ||
135 | of_property_read_u32(node, "poll-interval", &pdata->poll_interval); | ||
136 | |||
137 | i = 0; | ||
138 | for_each_child_of_node(node, pp) { | ||
139 | enum of_gpio_flags flags; | ||
140 | |||
141 | if (!of_find_property(pp, "gpios", NULL)) { | ||
142 | pdata->nbuttons--; | ||
143 | dev_warn(dev, "Found button without gpios\n"); | ||
144 | continue; | ||
145 | } | ||
146 | |||
147 | button = &pdata->buttons[i++]; | ||
148 | |||
149 | button->gpio = of_get_gpio_flags(pp, 0, &flags); | ||
150 | button->active_low = flags & OF_GPIO_ACTIVE_LOW; | ||
151 | |||
152 | if (of_property_read_u32(pp, "linux,code", &button->code)) { | ||
153 | dev_err(dev, "Button without keycode: 0x%x\n", | ||
154 | button->gpio); | ||
155 | error = -EINVAL; | ||
156 | goto err_free_pdata; | ||
157 | } | ||
158 | |||
159 | button->desc = of_get_property(pp, "label", NULL); | ||
160 | |||
161 | if (of_property_read_u32(pp, "linux,input-type", &button->type)) | ||
162 | button->type = EV_KEY; | ||
163 | |||
164 | button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); | ||
165 | |||
166 | if (of_property_read_u32(pp, "debounce-interval", | ||
167 | &button->debounce_interval)) | ||
168 | button->debounce_interval = 5; | ||
169 | } | ||
170 | |||
171 | if (pdata->nbuttons == 0) { | ||
172 | error = -EINVAL; | ||
173 | goto err_free_pdata; | ||
174 | } | ||
175 | |||
176 | return pdata; | ||
177 | |||
178 | err_free_pdata: | ||
179 | kfree(pdata); | ||
180 | err_out: | ||
181 | return ERR_PTR(error); | ||
182 | } | ||
183 | |||
184 | static struct of_device_id gpio_keys_polled_of_match[] = { | ||
185 | { .compatible = "gpio-keys-polled", }, | ||
186 | { }, | ||
187 | }; | ||
188 | MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match); | ||
189 | |||
190 | #else | ||
191 | |||
192 | static inline struct gpio_keys_platform_data * | ||
193 | gpio_keys_polled_get_devtree_pdata(struct device *dev) | ||
194 | { | ||
195 | return NULL; | ||
196 | } | ||
197 | #endif | ||
198 | |||
103 | static int __devinit gpio_keys_polled_probe(struct platform_device *pdev) | 199 | static int __devinit gpio_keys_polled_probe(struct platform_device *pdev) |
104 | { | 200 | { |
105 | struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; | ||
106 | struct device *dev = &pdev->dev; | 201 | struct device *dev = &pdev->dev; |
202 | const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev); | ||
107 | struct gpio_keys_polled_dev *bdev; | 203 | struct gpio_keys_polled_dev *bdev; |
108 | struct input_polled_dev *poll_dev; | 204 | struct input_polled_dev *poll_dev; |
109 | struct input_dev *input; | 205 | struct input_dev *input; |
110 | int error; | 206 | int error; |
111 | int i; | 207 | int i; |
112 | 208 | ||
113 | if (!pdata || !pdata->poll_interval) | 209 | if (!pdata) { |
114 | return -EINVAL; | 210 | pdata = gpio_keys_polled_get_devtree_pdata(dev); |
211 | if (IS_ERR(pdata)) | ||
212 | return PTR_ERR(pdata); | ||
213 | if (!pdata) { | ||
214 | dev_err(dev, "missing platform data\n"); | ||
215 | return -EINVAL; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | if (!pdata->poll_interval) { | ||
220 | dev_err(dev, "missing poll_interval value\n"); | ||
221 | error = -EINVAL; | ||
222 | goto err_free_pdata; | ||
223 | } | ||
115 | 224 | ||
116 | bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) + | 225 | bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) + |
117 | pdata->nbuttons * sizeof(struct gpio_keys_button_data), | 226 | pdata->nbuttons * sizeof(struct gpio_keys_button_data), |
118 | GFP_KERNEL); | 227 | GFP_KERNEL); |
119 | if (!bdev) { | 228 | if (!bdev) { |
120 | dev_err(dev, "no memory for private data\n"); | 229 | dev_err(dev, "no memory for private data\n"); |
121 | return -ENOMEM; | 230 | error = -ENOMEM; |
231 | goto err_free_pdata; | ||
122 | } | 232 | } |
123 | 233 | ||
124 | poll_dev = input_allocate_polled_device(); | 234 | poll_dev = input_allocate_polled_device(); |
@@ -197,7 +307,7 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev) | |||
197 | /* report initial state of the buttons */ | 307 | /* report initial state of the buttons */ |
198 | for (i = 0; i < pdata->nbuttons; i++) | 308 | for (i = 0; i < pdata->nbuttons; i++) |
199 | gpio_keys_polled_check_state(input, &pdata->buttons[i], | 309 | gpio_keys_polled_check_state(input, &pdata->buttons[i], |
200 | &bdev->data[i]); | 310 | &bdev->data[i]); |
201 | 311 | ||
202 | return 0; | 312 | return 0; |
203 | 313 | ||
@@ -209,15 +319,20 @@ err_free_gpio: | |||
209 | 319 | ||
210 | err_free_bdev: | 320 | err_free_bdev: |
211 | kfree(bdev); | 321 | kfree(bdev); |
212 | |||
213 | platform_set_drvdata(pdev, NULL); | 322 | platform_set_drvdata(pdev, NULL); |
323 | |||
324 | err_free_pdata: | ||
325 | /* If we have no platform_data, we allocated pdata dynamically. */ | ||
326 | if (!dev_get_platdata(&pdev->dev)) | ||
327 | kfree(pdata); | ||
328 | |||
214 | return error; | 329 | return error; |
215 | } | 330 | } |
216 | 331 | ||
217 | static int __devexit gpio_keys_polled_remove(struct platform_device *pdev) | 332 | static int __devexit gpio_keys_polled_remove(struct platform_device *pdev) |
218 | { | 333 | { |
219 | struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev); | 334 | struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev); |
220 | struct gpio_keys_platform_data *pdata = bdev->pdata; | 335 | const struct gpio_keys_platform_data *pdata = bdev->pdata; |
221 | int i; | 336 | int i; |
222 | 337 | ||
223 | input_unregister_polled_device(bdev->poll_dev); | 338 | input_unregister_polled_device(bdev->poll_dev); |
@@ -227,6 +342,13 @@ static int __devexit gpio_keys_polled_remove(struct platform_device *pdev) | |||
227 | 342 | ||
228 | input_free_polled_device(bdev->poll_dev); | 343 | input_free_polled_device(bdev->poll_dev); |
229 | 344 | ||
345 | /* | ||
346 | * If we had no platform_data, we allocated pdata dynamically and | ||
347 | * must free it here. | ||
348 | */ | ||
349 | if (!dev_get_platdata(&pdev->dev)) | ||
350 | kfree(pdata); | ||
351 | |||
230 | kfree(bdev); | 352 | kfree(bdev); |
231 | platform_set_drvdata(pdev, NULL); | 353 | platform_set_drvdata(pdev, NULL); |
232 | 354 | ||
@@ -239,6 +361,7 @@ static struct platform_driver gpio_keys_polled_driver = { | |||
239 | .driver = { | 361 | .driver = { |
240 | .name = DRV_NAME, | 362 | .name = DRV_NAME, |
241 | .owner = THIS_MODULE, | 363 | .owner = THIS_MODULE, |
364 | .of_match_table = of_match_ptr(gpio_keys_polled_of_match), | ||
242 | }, | 365 | }, |
243 | }; | 366 | }; |
244 | module_platform_driver(gpio_keys_polled_driver); | 367 | module_platform_driver(gpio_keys_polled_driver); |
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c index a0222db4dc86..b03c5b954864 100644 --- a/drivers/input/keyboard/omap-keypad.c +++ b/drivers/input/keyboard/omap-keypad.c | |||
@@ -214,7 +214,7 @@ static void omap_kp_tasklet(unsigned long data) | |||
214 | memcpy(keypad_state, new_state, sizeof(keypad_state)); | 214 | memcpy(keypad_state, new_state, sizeof(keypad_state)); |
215 | 215 | ||
216 | if (key_down) { | 216 | if (key_down) { |
217 | int delay = HZ / 20; | 217 | int delay = HZ / 20; |
218 | /* some key is pressed - keep irq disabled and use timer | 218 | /* some key is pressed - keep irq disabled and use timer |
219 | * to poll the keypad */ | 219 | * to poll the keypad */ |
220 | if (spurious) | 220 | if (spurious) |
@@ -413,7 +413,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) | |||
413 | } | 413 | } |
414 | return 0; | 414 | return 0; |
415 | err5: | 415 | err5: |
416 | for (i = irq_idx - 1; i >=0; i--) | 416 | for (i = irq_idx - 1; i >= 0; i--) |
417 | free_irq(row_gpios[i], omap_kp); | 417 | free_irq(row_gpios[i], omap_kp); |
418 | err4: | 418 | err4: |
419 | input_unregister_device(omap_kp->input); | 419 | input_unregister_device(omap_kp->input); |
@@ -421,10 +421,10 @@ err4: | |||
421 | err3: | 421 | err3: |
422 | device_remove_file(&pdev->dev, &dev_attr_enable); | 422 | device_remove_file(&pdev->dev, &dev_attr_enable); |
423 | err2: | 423 | err2: |
424 | for (i = row_idx - 1; i >=0; i--) | 424 | for (i = row_idx - 1; i >= 0; i--) |
425 | gpio_free(row_gpios[i]); | 425 | gpio_free(row_gpios[i]); |
426 | err1: | 426 | err1: |
427 | for (i = col_idx - 1; i >=0; i--) | 427 | for (i = col_idx - 1; i >= 0; i--) |
428 | gpio_free(col_gpios[i]); | 428 | gpio_free(col_gpios[i]); |
429 | 429 | ||
430 | kfree(omap_kp); | 430 | kfree(omap_kp); |
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index a061ba603a29..277e26dc910e 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c | |||
@@ -256,7 +256,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt( | |||
256 | struct matrix_keymap_data *keymap_data; | 256 | struct matrix_keymap_data *keymap_data; |
257 | uint32_t *keymap, num_rows = 0, num_cols = 0; | 257 | uint32_t *keymap, num_rows = 0, num_cols = 0; |
258 | struct device_node *np = dev->of_node, *key_np; | 258 | struct device_node *np = dev->of_node, *key_np; |
259 | unsigned int key_count = 0; | 259 | unsigned int key_count; |
260 | 260 | ||
261 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | 261 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); |
262 | if (!pdata) { | 262 | if (!pdata) { |
@@ -280,9 +280,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt( | |||
280 | } | 280 | } |
281 | pdata->keymap_data = keymap_data; | 281 | pdata->keymap_data = keymap_data; |
282 | 282 | ||
283 | for_each_child_of_node(np, key_np) | 283 | key_count = of_get_child_count(np); |
284 | key_count++; | ||
285 | |||
286 | keymap_data->keymap_size = key_count; | 284 | keymap_data->keymap_size = key_count; |
287 | keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL); | 285 | keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL); |
288 | if (!keymap) { | 286 | if (!keymap) { |
@@ -662,8 +660,6 @@ static const struct of_device_id samsung_keypad_dt_match[] = { | |||
662 | {}, | 660 | {}, |
663 | }; | 661 | }; |
664 | MODULE_DEVICE_TABLE(of, samsung_keypad_dt_match); | 662 | MODULE_DEVICE_TABLE(of, samsung_keypad_dt_match); |
665 | #else | ||
666 | #define samsung_keypad_dt_match NULL | ||
667 | #endif | 663 | #endif |
668 | 664 | ||
669 | static struct platform_device_id samsung_keypad_driver_ids[] = { | 665 | static struct platform_device_id samsung_keypad_driver_ids[] = { |
@@ -684,7 +680,7 @@ static struct platform_driver samsung_keypad_driver = { | |||
684 | .driver = { | 680 | .driver = { |
685 | .name = "samsung-keypad", | 681 | .name = "samsung-keypad", |
686 | .owner = THIS_MODULE, | 682 | .owner = THIS_MODULE, |
687 | .of_match_table = samsung_keypad_dt_match, | 683 | .of_match_table = of_match_ptr(samsung_keypad_dt_match), |
688 | .pm = &samsung_keypad_pm_ops, | 684 | .pm = &samsung_keypad_pm_ops, |
689 | }, | 685 | }, |
690 | .id_table = samsung_keypad_driver_ids, | 686 | .id_table = samsung_keypad_driver_ids, |
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index 2c1c9ed1bd9f..5faaf2553e33 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c | |||
@@ -29,8 +29,8 @@ | |||
29 | #include <linux/of.h> | 29 | #include <linux/of.h> |
30 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
31 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
32 | #include <linux/input/tegra_kbc.h> | ||
32 | #include <mach/clk.h> | 33 | #include <mach/clk.h> |
33 | #include <mach/kbc.h> | ||
34 | 34 | ||
35 | #define KBC_MAX_DEBOUNCE_CNT 0x3ffu | 35 | #define KBC_MAX_DEBOUNCE_CNT 0x3ffu |
36 | 36 | ||