“39876e7dd385e0f0a438ee0ab13cf75a4f5e0e3b”上不存在“git@gitcode.net:openharmony/kernel_linux.git”
提交 ec98a497 编写于 作者: G Geert Uytterhoeven 提交者: Rafael J. Wysocki

leds: leds-gpio: Fix legacy GPIO number case

In the legacy case, led_dat->gpiod is initialized correctly, but
overwritten later by template->gpiod, which is NULL, causing leds-gpio
to fail with:

    gpiod_direction_output: invalid GPIO
    leds-gpio: probe of leds-gpio failed with error -22

Move the initialization of led_dat->gpiod from template->gpiod up, and
always use led_dat->gpiod later, to fix this.

Fixes: 5c51277a (leds: leds-gpio: Add support for GPIO descriptors)
Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 60ba032e
...@@ -92,7 +92,8 @@ static int create_gpio_led(const struct gpio_led *template, ...@@ -92,7 +92,8 @@ static int create_gpio_led(const struct gpio_led *template,
{ {
int ret, state; int ret, state;
if (!template->gpiod) { led_dat->gpiod = template->gpiod;
if (!led_dat->gpiod) {
/* /*
* This is the legacy code path for platform code that * This is the legacy code path for platform code that
* still uses GPIO numbers. Ultimately we would like to get * still uses GPIO numbers. Ultimately we would like to get
...@@ -122,8 +123,7 @@ static int create_gpio_led(const struct gpio_led *template, ...@@ -122,8 +123,7 @@ static int create_gpio_led(const struct gpio_led *template,
led_dat->cdev.name = template->name; led_dat->cdev.name = template->name;
led_dat->cdev.default_trigger = template->default_trigger; led_dat->cdev.default_trigger = template->default_trigger;
led_dat->gpiod = template->gpiod; led_dat->can_sleep = gpiod_cansleep(led_dat->gpiod);
led_dat->can_sleep = gpiod_cansleep(template->gpiod);
led_dat->blinking = 0; led_dat->blinking = 0;
if (blink_set) { if (blink_set) {
led_dat->platform_gpio_blink_set = blink_set; led_dat->platform_gpio_blink_set = blink_set;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册