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

leds: leds-ns2: set devm_gpio_request_one() flags param correctly

The devm_gpio_request_one() flags parameter was set to:

GPIOF_DIR_OUT | gpio_get_value(template->cmd)

GPIOF_DIR_OUT and GPIOF_DIR_IN are defined as below:

GPIOF_DIR_OUT (0 << 0)
GPIOF_DIR_IN (1 << 0)

So, when 'gpio_get_value(template->cmd)' is 1, the gpio pin can
be set as input, instead of output.

To prevent this problem, GPIOF_OUT_INIT flags should be used when
using devm_gpio_request_one().

Same goes for 'gpio_get_value(template->slow)' case.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>

authored by

Jingoo Han and committed by
Bryan Wu
9d04cbaa 84f6942c

+4 -2
+4 -2
drivers/leds/leds-ns2.c
··· 193 193 enum ns2_led_modes mode; 194 194 195 195 ret = devm_gpio_request_one(&pdev->dev, template->cmd, 196 - GPIOF_DIR_OUT | gpio_get_value(template->cmd), 196 + gpio_get_value(template->cmd) ? 197 + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, 197 198 template->name); 198 199 if (ret) { 199 200 dev_err(&pdev->dev, "%s: failed to setup command GPIO\n", ··· 203 202 } 204 203 205 204 ret = devm_gpio_request_one(&pdev->dev, template->slow, 206 - GPIOF_DIR_OUT | gpio_get_value(template->slow), 205 + gpio_get_value(template->slow) ? 206 + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, 207 207 template->name); 208 208 if (ret) { 209 209 dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n",