diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2007-11-21 14:42:33 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2007-11-21 14:42:33 -0500 |
commit | 6a2e391190b17f4fb895bd2d5e8b08c7c8f897a2 (patch) | |
tree | ee5a7af733b8eef5b877614ac02886632208eda1 /drivers/input/keyboard | |
parent | 8bf4215e8a7f7416d7258af211488aabf65863c3 (diff) |
Input: gpio-keys - request and configure GPIOs
Currently, gpio_keys.c assumes the GPIOs to be already properly configured;
this patch changes gpio-keys to perform explicit calls to gpio_request() and
gpio_configure_input().
This matches the behaviour of leds-gpio.
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 3eddf52a0bba..6a9ca4bdcb74 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -75,16 +75,32 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
75 | 75 | ||
76 | for (i = 0; i < pdata->nbuttons; i++) { | 76 | for (i = 0; i < pdata->nbuttons; i++) { |
77 | struct gpio_keys_button *button = &pdata->buttons[i]; | 77 | struct gpio_keys_button *button = &pdata->buttons[i]; |
78 | int irq = gpio_to_irq(button->gpio); | 78 | int irq; |
79 | unsigned int type = button->type ?: EV_KEY; | 79 | unsigned int type = button->type ?: EV_KEY; |
80 | 80 | ||
81 | error = gpio_request(button->gpio, button->desc ?: "gpio_keys"); | ||
82 | if (error < 0) { | ||
83 | pr_err("gpio-keys: failed to request GPIO %d," | ||
84 | " error %d\n", button->gpio, error); | ||
85 | goto fail; | ||
86 | } | ||
87 | |||
88 | error = gpio_direction_input(button->gpio); | ||
89 | if (error < 0) { | ||
90 | pr_err("gpio-keys: failed to configure input" | ||
91 | " direction for GPIO %d, error %d\n", | ||
92 | button->gpio, error); | ||
93 | gpio_free(button->gpio); | ||
94 | goto fail; | ||
95 | } | ||
96 | |||
97 | irq = gpio_to_irq(button->gpio); | ||
81 | if (irq < 0) { | 98 | if (irq < 0) { |
82 | error = irq; | 99 | error = irq; |
83 | printk(KERN_ERR | 100 | pr_err("gpio-keys: Unable to get irq number" |
84 | "gpio-keys: " | 101 | " for GPIO %d, error %d\n", |
85 | "Unable to get irq number for GPIO %d," | ||
86 | "error %d\n", | ||
87 | button->gpio, error); | 102 | button->gpio, error); |
103 | gpio_free(button->gpio); | ||
88 | goto fail; | 104 | goto fail; |
89 | } | 105 | } |
90 | 106 | ||
@@ -94,9 +110,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
94 | button->desc ? button->desc : "gpio_keys", | 110 | button->desc ? button->desc : "gpio_keys", |
95 | pdev); | 111 | pdev); |
96 | if (error) { | 112 | if (error) { |
97 | printk(KERN_ERR | 113 | pr_err("gpio-keys: Unable to claim irq %d; error %d\n", |
98 | "gpio-keys: Unable to claim irq %d; error %d\n", | ||
99 | irq, error); | 114 | irq, error); |
115 | gpio_free(button->gpio); | ||
100 | goto fail; | 116 | goto fail; |
101 | } | 117 | } |
102 | 118 | ||
@@ -108,8 +124,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
108 | 124 | ||
109 | error = input_register_device(input); | 125 | error = input_register_device(input); |
110 | if (error) { | 126 | if (error) { |
111 | printk(KERN_ERR | 127 | pr_err("gpio-keys: Unable to register input device, " |
112 | "gpio-keys: Unable to register input device, " | ||
113 | "error: %d\n", error); | 128 | "error: %d\n", error); |
114 | goto fail; | 129 | goto fail; |
115 | } | 130 | } |
@@ -119,8 +134,10 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
119 | return 0; | 134 | return 0; |
120 | 135 | ||
121 | fail: | 136 | fail: |
122 | while (--i >= 0) | 137 | while (--i >= 0) { |
123 | free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); | 138 | free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); |
139 | gpio_free(pdata->buttons[i].gpio); | ||
140 | } | ||
124 | 141 | ||
125 | platform_set_drvdata(pdev, NULL); | 142 | platform_set_drvdata(pdev, NULL); |
126 | input_free_device(input); | 143 | input_free_device(input); |
@@ -139,6 +156,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) | |||
139 | for (i = 0; i < pdata->nbuttons; i++) { | 156 | for (i = 0; i < pdata->nbuttons; i++) { |
140 | int irq = gpio_to_irq(pdata->buttons[i].gpio); | 157 | int irq = gpio_to_irq(pdata->buttons[i].gpio); |
141 | free_irq(irq, pdev); | 158 | free_irq(irq, pdev); |
159 | gpio_free(pdata->buttons[i].gpio); | ||
142 | } | 160 | } |
143 | 161 | ||
144 | input_unregister_device(input); | 162 | input_unregister_device(input); |