diff options
author | Daniel Mack <zonque@gmail.com> | 2012-08-01 01:08:48 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-08-22 01:29:51 -0400 |
commit | 429a34d7477bb7071d37dd98b89f000ee6f0193b (patch) | |
tree | 3178b606302ce8781d4309c23782b932cd260893 /drivers/input/misc/rotary_encoder.c | |
parent | a78769b80d73468d53d0ad70c5a9e3fd9ff9dc54 (diff) |
Input: rotary-encoder - use gpio_request_one()
Use gpio_request_one() instead of separate calls to gpio_request() and
gpio_direction_input() to simplify the code.
Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/misc/rotary_encoder.c')
-rw-r--r-- | drivers/input/misc/rotary_encoder.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 00a7bdabb0b3..e261ad4e6c61 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c | |||
@@ -145,6 +145,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) | |||
145 | struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data; | 145 | struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data; |
146 | struct rotary_encoder *encoder; | 146 | struct rotary_encoder *encoder; |
147 | struct input_dev *input; | 147 | struct input_dev *input; |
148 | struct device *dev = &pdev->dev; | ||
148 | irq_handler_t handler; | 149 | irq_handler_t handler; |
149 | int err; | 150 | int err; |
150 | 151 | ||
@@ -180,36 +181,20 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) | |||
180 | 181 | ||
181 | err = input_register_device(input); | 182 | err = input_register_device(input); |
182 | if (err) { | 183 | if (err) { |
183 | dev_err(&pdev->dev, "failed to register input device\n"); | 184 | dev_err(dev, "failed to register input device\n"); |
184 | goto exit_free_mem; | 185 | goto exit_free_mem; |
185 | } | 186 | } |
186 | 187 | ||
187 | /* request the GPIOs */ | 188 | /* request the GPIOs */ |
188 | err = gpio_request(pdata->gpio_a, DRV_NAME); | 189 | err = gpio_request_one(pdata->gpio_a, GPIOF_IN, dev_name(dev)); |
189 | if (err) { | 190 | if (err) { |
190 | dev_err(&pdev->dev, "unable to request GPIO %d\n", | 191 | dev_err(dev, "unable to request GPIO %d\n", pdata->gpio_a); |
191 | pdata->gpio_a); | ||
192 | goto exit_unregister_input; | 192 | goto exit_unregister_input; |
193 | } | 193 | } |
194 | 194 | ||
195 | err = gpio_direction_input(pdata->gpio_a); | 195 | err = gpio_request_one(pdata->gpio_b, GPIOF_IN, dev_name(dev)); |
196 | if (err) { | 196 | if (err) { |
197 | dev_err(&pdev->dev, "unable to set GPIO %d for input\n", | 197 | dev_err(dev, "unable to request GPIO %d\n", pdata->gpio_b); |
198 | pdata->gpio_a); | ||
199 | goto exit_unregister_input; | ||
200 | } | ||
201 | |||
202 | err = gpio_request(pdata->gpio_b, DRV_NAME); | ||
203 | if (err) { | ||
204 | dev_err(&pdev->dev, "unable to request GPIO %d\n", | ||
205 | pdata->gpio_b); | ||
206 | goto exit_free_gpio_a; | ||
207 | } | ||
208 | |||
209 | err = gpio_direction_input(pdata->gpio_b); | ||
210 | if (err) { | ||
211 | dev_err(&pdev->dev, "unable to set GPIO %d for input\n", | ||
212 | pdata->gpio_b); | ||
213 | goto exit_free_gpio_a; | 198 | goto exit_free_gpio_a; |
214 | } | 199 | } |
215 | 200 | ||
@@ -228,8 +213,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) | |||
228 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 213 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
229 | DRV_NAME, encoder); | 214 | DRV_NAME, encoder); |
230 | if (err) { | 215 | if (err) { |
231 | dev_err(&pdev->dev, "unable to request IRQ %d\n", | 216 | dev_err(dev, "unable to request IRQ %d\n", encoder->irq_a); |
232 | encoder->irq_a); | ||
233 | goto exit_free_gpio_b; | 217 | goto exit_free_gpio_b; |
234 | } | 218 | } |
235 | 219 | ||
@@ -237,8 +221,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) | |||
237 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 221 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
238 | DRV_NAME, encoder); | 222 | DRV_NAME, encoder); |
239 | if (err) { | 223 | if (err) { |
240 | dev_err(&pdev->dev, "unable to request IRQ %d\n", | 224 | dev_err(dev, "unable to request IRQ %d\n", encoder->irq_b); |
241 | encoder->irq_b); | ||
242 | goto exit_free_irq_a; | 225 | goto exit_free_irq_a; |
243 | } | 226 | } |
244 | 227 | ||