Skip to contentSkip to conversation

backlight: pwm_bl: Simplify usage of devm_gpiod_get_optional

PATCH Applied Axel Lin 3 participants 4 messages May 16, 2015 – May 19, 2015

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 backlight: pwm_bl: Simplify usage of devm_gpiod_get_optional

Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions), the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output.
Simplify the usage of devm_gpiod_get_optional accordingly.

---
 drivers/video/backlight/pwm_bl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/video/backlight/pwm_bl.c +2 -4
index 3a145a6..57cb9ec 100644
@@ -241,7 +241,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	pb->dev = &pdev->dev;
 	pb->enabled = false;
 
-	pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable");
+	pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
+						  GPIOD_OUT_HIGH);
 	if (IS_ERR(pb->enable_gpio)) {
 		ret = PTR_ERR(pb->enable_gpio);
 		goto err_alloc;
@@ -263,9 +264,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 		pb->enable_gpio = gpio_to_desc(data->enable_gpio);
 	}
 
-	if (pb->enable_gpio)
-		gpiod_direction_output(pb->enable_gpio, 1);
-
 	pb->power_supply = devm_regulator_get(&pdev->dev, "power");
 	if (IS_ERR(pb->power_supply)) {
 		ret = PTR_ERR(pb->power_supply);
Signature · 1 line
2.1.0
Applied
#1 lore raw
Quoted 9 lines · Axel Lin

Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions), the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output.
Simplify the usage of devm_gpiod_get_optional accordingly.

---
 drivers/video/backlight/pwm_bl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks.

Quoted 24 lines
drivers/video/backlight/pwm_bl.c +2 -4
index 3a145a6..57cb9ec 100644
@@ -241,7 +241,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	pb->dev = &pdev->dev;
 	pb->enabled = false;
 
-	pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable");
+	pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
+						  GPIOD_OUT_HIGH);
 	if (IS_ERR(pb->enable_gpio)) {
 		ret = PTR_ERR(pb->enable_gpio);
 		goto err_alloc;
@@ -263,9 +264,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 		pb->enable_gpio = gpio_to_desc(data->enable_gpio);
 	}
 
-	if (pb->enable_gpio)
-		gpiod_direction_output(pb->enable_gpio, 1);
-
 	pb->power_supply = devm_regulator_get(&pdev->dev, "power");
 	if (IS_ERR(pb->power_supply)) {
 		ret = PTR_ERR(pb->power_supply);
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Acked-by on v1 1/1
#2 lore raw
In reply to Axel Lin

Hello,

Quoted 6 lines · Axel Lin

Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions), the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output.
Simplify the usage of devm_gpiod_get_optional accordingly.

as I just sent the same patch:

@Axel: Do you have some more patches of this type in the queue? I currently have several fixes on top of 4.1-rc4. Some of them are still in a single wip patch, some other are already sent out.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#3 lore raw

2015-05-19 15:59 GMT+08:00 Uwe Kleine-König <[email protected]>:

Quoted 8 lines

Hello,

Quoted 5 lines · Axel Lin

Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions), the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output.
Simplify the usage of devm_gpiod_get_optional accordingly.

Quoted 6 lines
Quoted 1 line

as I just sent the same patch:

@Axel: Do you have some more patches of this type in the queue? I

No, I don't have other patches of this type in the queue.

Regards,
Axel