diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 02:36:30 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 20:56:14 -0400 |
commit | a16ca23935afc0d72215b139720bd07df3162a9f (patch) | |
tree | bcfc8bfcaed96a60728b803632ce973ca6cab0dd | |
parent | 6709c9a5d8c53092cbe89128df4e0a549e93133b (diff) |
Input: gpio_keys - consolidate key destructor code
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 6f067587cdf3..8f44f7b8c944 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -195,7 +195,7 @@ static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata, | |||
195 | * @type: button type (%EV_KEY, %EV_SW) | 195 | * @type: button type (%EV_KEY, %EV_SW) |
196 | * | 196 | * |
197 | * This function parses stringified bitmap from @buf and disables/enables | 197 | * This function parses stringified bitmap from @buf and disables/enables |
198 | * GPIO buttons accordinly. Returns 0 on success and negative error | 198 | * GPIO buttons accordingly. Returns 0 on success and negative error |
199 | * on failure. | 199 | * on failure. |
200 | */ | 200 | */ |
201 | static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, | 201 | static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, |
@@ -551,6 +551,15 @@ static int gpio_keys_get_devtree_pdata(struct device *dev, | |||
551 | 551 | ||
552 | #endif | 552 | #endif |
553 | 553 | ||
554 | static void gpio_remove_key(struct gpio_button_data *bdata) | ||
555 | { | ||
556 | free_irq(gpio_to_irq(bdata->button->gpio), bdata); | ||
557 | if (bdata->timer_debounce) | ||
558 | del_timer_sync(&bdata->timer); | ||
559 | cancel_work_sync(&bdata->work); | ||
560 | gpio_free(bdata->button->gpio); | ||
561 | } | ||
562 | |||
554 | static int __devinit gpio_keys_probe(struct platform_device *pdev) | 563 | static int __devinit gpio_keys_probe(struct platform_device *pdev) |
555 | { | 564 | { |
556 | const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; | 565 | const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; |
@@ -640,13 +649,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
640 | fail3: | 649 | fail3: |
641 | sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); | 650 | sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); |
642 | fail2: | 651 | fail2: |
643 | while (--i >= 0) { | 652 | while (--i >= 0) |
644 | free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); | 653 | gpio_remove_key(&ddata->data[i]); |
645 | if (ddata->data[i].timer_debounce) | ||
646 | del_timer_sync(&ddata->data[i].timer); | ||
647 | cancel_work_sync(&ddata->data[i].work); | ||
648 | gpio_free(pdata->buttons[i].gpio); | ||
649 | } | ||
650 | 654 | ||
651 | platform_set_drvdata(pdev, NULL); | 655 | platform_set_drvdata(pdev, NULL); |
652 | fail1: | 656 | fail1: |
@@ -669,14 +673,8 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) | |||
669 | 673 | ||
670 | device_init_wakeup(&pdev->dev, 0); | 674 | device_init_wakeup(&pdev->dev, 0); |
671 | 675 | ||
672 | for (i = 0; i < ddata->n_buttons; i++) { | 676 | for (i = 0; i < ddata->n_buttons; i++) |
673 | int irq = gpio_to_irq(ddata->data[i].button->gpio); | 677 | gpio_remove_key(&ddata->data[i]); |
674 | free_irq(irq, &ddata->data[i]); | ||
675 | if (ddata->data[i].timer_debounce) | ||
676 | del_timer_sync(&ddata->data[i].timer); | ||
677 | cancel_work_sync(&ddata->data[i].work); | ||
678 | gpio_free(ddata->data[i].button->gpio); | ||
679 | } | ||
680 | 678 | ||
681 | input_unregister_device(input); | 679 | input_unregister_device(input); |
682 | 680 | ||