Skip to contentSkip to conversation

pwm-backlight: fix bogus request for GPIO#0 when instantiated from DT

PATCH Applied Lothar Waßmann 3 participants 3 messages Aug 20, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm-backlight: fix bogus request for GPIO#0 when instantiated from DT

commit 257462dbf3ed ("pwm-backlight: switch to gpiod interface") introduced a regression leading to acquiring a bogus GPIO-0 when configured from DT without an 'enable-gpios' property.
The driver will happily accept the 0 initialized 'enable_gpio' member of the struct platform_pwm_backlight_data as valid gpio number, and request this GPIO as enable pin. In case of multiple driver instances, the second will fail to register with the error message:
pwm-backlight backlight1.23: failed to request GPIO#0: -16

Fix this by setting enable_gpio in the pdata struct to -EINVAL.

---
 drivers/video/backlight/pwm_bl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/pwm_bl.c +1 -1
index d7a3d13..e6ef6b4 100644
@@ -172,7 +172,7 @@ static int pwm_backlight_parse_dt(struct device *dev,
 		data->dft_brightness = value;
 		data->max_brightness--;
 	}
-
+	data->enable_gpio = -EINVAL;
 	return 0;
 }
 
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · Lothar Waßmann

commit 257462dbf3ed ("pwm-backlight: switch to gpiod interface") introduced a regression leading to acquiring a bogus GPIO-0 when configured from DT without an 'enable-gpios' property.
The driver will happily accept the 0 initialized 'enable_gpio' member of the struct platform_pwm_backlight_data as valid gpio number, and request this GPIO as enable pin. In case of multiple driver instances, the second will fail to register with the error message:
pwm-backlight backlight1.23: failed to request GPIO#0: -16

Fix this by setting enable_gpio in the pdata struct to -EINVAL.

---
 drivers/video/backlight/pwm_bl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/backlight/pwm_bl.c +0 -0
index d7a3d13..e6ef6b4 100644

drivers/video/backlight/pwm_bl.c static int pwm_backlight_parse_dt(struct device *dev, · line 175

Quoted 5 lines
drivers/video/backlight/pwm_bl.c +1 -1
@@ -172,7 +172,7 @@ static int pwm_backlight_parse_dt(struct device *dev,
 		data->dft_brightness = value;
 		data->max_brightness--;
 	}
-
+	data->enable_gpio = -EINVAL;

I'd prefer to keep the blank line for readability. Other than that:

Applied
#2 lore raw
In reply to Lothar Waßmann
Quoted 9 lines · Lothar Waßmann

commit 257462dbf3ed ("pwm-backlight: switch to gpiod interface") introduced a regression leading to acquiring a bogus GPIO-0 when configured from DT without an 'enable-gpios' property.
The driver will happily accept the 0 initialized 'enable_gpio' member of the struct platform_pwm_backlight_data as valid gpio number, and request this GPIO as enable pin. In case of multiple driver instances, the second will fail to register with the error message:
pwm-backlight backlight1.23: failed to request GPIO#0: -16

Quoted 6 lines

Fix this by setting enable_gpio in the pdata struct to -EINVAL.

---
 drivers/video/backlight/pwm_bl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to -fixes with Thierry's Ack and the blank line left.

Quoted 13 lines
drivers/video/backlight/pwm_bl.c +1 -1
index d7a3d13..e6ef6b4 100644
@@ -172,7 +172,7 @@ static int pwm_backlight_parse_dt(struct device *dev,
 		data->dft_brightness = value;
 		data->max_brightness--;
 	}
-
+	data->enable_gpio = -EINVAL;
 	return 0;
 }
 
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog