aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-gpio.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2013-11-22 12:26:01 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2014-01-06 21:54:26 -0500
commit4288d9b8edcec7289e00eecdad44f14c9ea1ba0e (patch)
treea05384e4e756a1c1bd49de99fea6b1d75a883061 /drivers/extcon/extcon-gpio.c
parent319e2e3f63c348a9b66db4667efa73178e18b17d (diff)
extcon: gpio: Request gpio pin before modifying its state
Commit 338de0ca (extcon: gpio: Use gpio driver/chip debounce if supported) introduced a call to gpio_set_debounce() before actually requesting the respective gpio pin from the gpio subsystem. The gpio subsystem expects that a gpio pin was requested before modifying its state. Not doing so results in a warning from gpiolib, and the gpio pin is auto-requested. This in turn causes the subsequent devm_gpio_request_one() to fail. So devm_gpio_request_one() must be called prior to calling gpio_set_debounce(). Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-gpio.c')
-rw-r--r--drivers/extcon/extcon-gpio.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 7e0dff58e494..4736a9c57efa 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -105,6 +105,12 @@ static int gpio_extcon_probe(struct platform_device *pdev)
105 extcon_data->state_off = pdata->state_off; 105 extcon_data->state_off = pdata->state_off;
106 if (pdata->state_on && pdata->state_off) 106 if (pdata->state_on && pdata->state_off)
107 extcon_data->edev.print_state = extcon_gpio_print_state; 107 extcon_data->edev.print_state = extcon_gpio_print_state;
108
109 ret = devm_gpio_request_one(&pdev->dev, extcon_data->gpio, GPIOF_DIR_IN,
110 pdev->name);
111 if (ret < 0)
112 return ret;
113
108 if (pdata->debounce) { 114 if (pdata->debounce) {
109 ret = gpio_set_debounce(extcon_data->gpio, 115 ret = gpio_set_debounce(extcon_data->gpio,
110 pdata->debounce * 1000); 116 pdata->debounce * 1000);
@@ -117,11 +123,6 @@ static int gpio_extcon_probe(struct platform_device *pdev)
117 if (ret < 0) 123 if (ret < 0)
118 return ret; 124 return ret;
119 125
120 ret = devm_gpio_request_one(&pdev->dev, extcon_data->gpio, GPIOF_DIR_IN,
121 pdev->name);
122 if (ret < 0)
123 goto err;
124
125 INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work); 126 INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
126 127
127 extcon_data->irq = gpio_to_irq(extcon_data->gpio); 128 extcon_data->irq = gpio_to_irq(extcon_data->gpio);