Javier Martinez Canillas 2d7c22f67d leds: leds-gpio: set devm_gpio_request_one() flags param correctly
commit a99d76f leds: leds-gpio: use gpio_request_one

changed the leds-gpio driver to use gpio_request_one() instead
of gpio_request() + gpio_direction_output()

Unfortunately, it also made a semantic change that breaks the
leds-gpio driver.

The gpio_request_one() flags parameter was set to:

GPIOF_DIR_OUT | (led_dat->active_low ^ state)

Since GPIOF_DIR_OUT is 0, the final flags value will just be the
XOR'ed value of led_dat->active_low and state.

This value were used to distinguish between HIGH/LOW output initial
level and call gpio_direction_output() accordingly.

With this new semantic gpio_request_one() will take the flags value
of 1 as a configuration of input direction (GPIOF_DIR_IN) and will
call gpio_direction_input() instead of gpio_direction_output().

int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
{
..
	if (flags & GPIOF_DIR_IN)
		err = gpio_direction_input(gpio);
	else
		err = gpio_direction_output(gpio,
				(flags & GPIOF_INIT_HIGH) ? 1 : 0);
..
}

The right semantic is to evaluate led_dat->active_low ^ state and
set the output initial level explicitly.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Reported-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-01-02 17:58:41 -08:00
..
2012-12-15 12:37:18 -08:00
2012-12-19 12:47:41 -08:00
2012-12-19 12:47:41 -08:00
2012-12-12 12:05:15 -08:00
2012-12-07 23:13:36 +01:00
2012-12-17 17:15:13 -08:00
2012-11-21 12:46:40 -08:00
2012-12-20 10:07:25 -08:00
2012-12-11 14:08:47 -08:00
2012-12-18 15:19:06 +10:30
2012-12-20 07:21:54 -08:00
2012-12-12 11:45:16 -08:00
2012-12-17 17:15:14 -08:00
2012-12-11 13:13:55 -08:00
2012-12-19 08:14:08 -08:00
2012-12-19 08:19:07 -08:00
2012-12-11 13:13:55 -08:00
2012-12-12 12:05:15 -08:00
2012-12-16 17:39:14 -08:00
2012-11-16 08:14:18 -08:00
2012-11-16 08:14:18 -08:00