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

leds: renesas: set gpio_request_one() flags param correctly

The gpio_request_one() flags parameter was set to:

GPIOF_DIR_OUT | !!brightness

GPIOF_DIR_OUT and GPIOF_DIR_IN are defined as below:
GPIOF_DIR_OUT (0 << 0)
GPIOF_DIR_IN (1 << 0)

So, when '!!brightness' 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 gpio_request_one().

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
901b74a3 9d04cbaa

+2 -1
+2 -1
drivers/leds/leds-renesas-tpu.c
··· 205 205 gpio_free(cfg->pin_gpio_fn); 206 206 207 207 if (new_state == R_TPU_PIN_GPIO) 208 - gpio_request_one(cfg->pin_gpio, GPIOF_DIR_OUT | !!brightness, 208 + gpio_request_one(cfg->pin_gpio, !!brightness ? 209 + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, 209 210 cfg->name); 210 211 211 212 if (new_state == R_TPU_PIN_GPIO_FN)