Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Guenter Roeck and committed by
Chanwoo Choi
4288d9b8 319e2e3f

+6 -5
+6 -5
drivers/extcon/extcon-gpio.c
··· 105 105 extcon_data->state_off = pdata->state_off; 106 106 if (pdata->state_on && pdata->state_off) 107 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 114 if (pdata->debounce) { 109 115 ret = gpio_set_debounce(extcon_data->gpio, 110 116 pdata->debounce * 1000); ··· 122 116 ret = extcon_dev_register(&extcon_data->edev); 123 117 if (ret < 0) 124 118 return ret; 125 - 126 - ret = devm_gpio_request_one(&pdev->dev, extcon_data->gpio, GPIOF_DIR_IN, 127 - pdev->name); 128 - if (ret < 0) 129 - goto err; 130 119 131 120 INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work); 132 121