From 9f7898f3ca71744ef834048dc78ad4a21db4ac64 Mon Sep 17 00:00:00 2001 From: Werner Johansson Date: Thu, 27 Aug 2015 10:41:15 -0700 Subject: backlight: lp855x: Make sure props struct is zeroed The driver occasionally got stuck in suspend mode or other strange states as those parts of the props struct were never initialized. Signed-off-by: Werner Johansson Signed-off-by: Bjorn Andersson Acked-by: Milo Kim Signed-off-by: Lee Jones --- drivers/video/backlight/lp855x_bl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/video/backlight') diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index f88df9ec08d0..daca9e6a2bb3 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -283,6 +283,7 @@ static int lp855x_backlight_register(struct lp855x *lp) struct lp855x_platform_data *pdata = lp->pdata; const char *name = pdata->name ? : DEFAULT_BL_NAME; + memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_PLATFORM; props.max_brightness = MAX_BRIGHTNESS; -- cgit v1.2.3 From da601ebc70f3b2d3a5c9b6f9f41e519abe76f47e Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sun, 30 Aug 2015 23:34:24 +0200 Subject: backlight: adp8860: Remove unnecessary MODULE_ALIAS() The driver has a I2C device id table that is used to create the modaliases and also "adp8860-backlight" is not a supported I2C id, so it's never used. Signed-off-by: Javier Martinez Canillas Signed-off-by: Lee Jones --- drivers/video/backlight/adp8860_bl.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/video/backlight') diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index 71147f4461b8..98ffe71e8af2 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c @@ -819,4 +819,3 @@ module_i2c_driver(adp8860_driver); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("ADP8860 Backlight driver"); -MODULE_ALIAS("i2c:adp8860-backlight"); -- cgit v1.2.3 From 7111c6c672fc8714c5092952a24df6694d46d71f Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sun, 30 Aug 2015 23:34:25 +0200 Subject: backlight: adp8870: Remove unnecessary MODULE_ALIAS() The driver has a I2C device id table that is used to create the modaliases and also "adp8870-backlight" is not a supported I2C id, so it's never used. Signed-off-by: Javier Martinez Canillas Signed-off-by: Lee Jones --- drivers/video/backlight/adp8870_bl.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/video/backlight') diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 037e43083343..9d738352d7d4 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -992,4 +992,3 @@ module_i2c_driver(adp8870_driver); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("ADP8870 Backlight driver"); -MODULE_ALIAS("i2c:adp8870-backlight"); -- cgit v1.2.3 From f85de2d9e24ee0b286ae54434f405d4a22f565f0 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 10 Oct 2015 14:30:50 +0200 Subject: backlight: 88pm860x_bl: Add missing of_node_put for_each_child_of_node performs an of_node_get on each iteration, so a break out of the loop requires an of_node_put. The semantic patch that fixes this problem is as follows (http://coccinelle.lip6.fr): // @@ expression root,e; local idexpression child; iterator name for_each_child_of_node; @@ for_each_child_of_node(root, child) { ... when != of_node_put(child) when != e = child + of_node_put(child); ? break; ... } ... when != child // Signed-off-by: Julia Lawall Signed-off-by: Lee Jones --- drivers/video/backlight/88pm860x_bl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/video/backlight') diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c index 2da5862876d1..6d8dc2c77520 100644 --- a/drivers/video/backlight/88pm860x_bl.c +++ b/drivers/video/backlight/88pm860x_bl.c @@ -180,6 +180,7 @@ static int pm860x_backlight_dt_init(struct platform_device *pdev, data->iset = PM8606_WLED_CURRENT(iset); of_property_read_u32(np, "marvell,88pm860x-pwm", &data->pwm); + of_node_put(np); break; } } -- cgit v1.2.3 From dc881123aa1aeff02ce2dc94c2b810d37173aa90 Mon Sep 17 00:00:00 2001 From: Vladimir Zapolskiy Date: Mon, 12 Oct 2015 15:29:03 +0300 Subject: backlight: pwm: Reject legacy PWM request for device defined in DT Platform PWM backlight data provided by board's device tree should be complete enough to successfully request a pwm device using pwm_get() API. This change fixes a bug, when an arbitrary (first found) PWM is connected to a "pwm-backlight" compatible device, when explicit PWM device reference is not given. Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt already describes "pwms" as a required property, instead of blind selection of a potentially wrong PWM reject legacy PWM device registration request, leave legacy API only for non-dt cases. Based on initial implementation done by Dmitry Eremin-Solenikov. Reported-by: Dmitry Eremin-Solenikov Signed-off-by: Vladimir Zapolskiy Acked-by: Thierry Reding Acked-by: Nicolas Ferre Tested-by: Robert Jarzmik Signed-off-by: Lee Jones --- drivers/video/backlight/pwm_bl.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers/video/backlight') diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index eff379b234cc..ae3c6b6fd5db 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -271,19 +271,18 @@ static int pwm_backlight_probe(struct platform_device *pdev) } pb->pwm = devm_pwm_get(&pdev->dev, NULL); - if (IS_ERR(pb->pwm)) { - ret = PTR_ERR(pb->pwm); - if (ret == -EPROBE_DEFER) - goto err_alloc; - + if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER + && !pdev->dev.of_node) { dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); pb->legacy = true; pb->pwm = pwm_request(data->pwm_id, "pwm-backlight"); - if (IS_ERR(pb->pwm)) { - dev_err(&pdev->dev, "unable to request legacy PWM\n"); - ret = PTR_ERR(pb->pwm); - goto err_alloc; - } + } + + if (IS_ERR(pb->pwm)) { + ret = PTR_ERR(pb->pwm); + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "unable to request PWM\n"); + goto err_alloc; } dev_dbg(&pdev->dev, "got pwm for backlight\n"); -- cgit v1.2.3 From fc18111b8973e2c7cc0c2ba6183795e5266ddff7 Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Tue, 27 Oct 2015 02:26:11 +0800 Subject: backlight: pm8941-wled: Fix ptr_ret.cocci warnings drivers/video/backlight/pm8941-wled.c:404:1-3: WARNING: PTR_ERR_OR_ZERO can be used Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Generated by: scripts/coccinelle/api/ptr_ret.cocci Acked-by: Bjorn Andersson Signed-off-by: Fengguang Wu Signed-off-by: Lee Jones --- drivers/video/backlight/pm8941-wled.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/video/backlight') diff --git a/drivers/video/backlight/pm8941-wled.c b/drivers/video/backlight/pm8941-wled.c index c704c3236034..78bba87551b2 100644 --- a/drivers/video/backlight/pm8941-wled.c +++ b/drivers/video/backlight/pm8941-wled.c @@ -401,10 +401,7 @@ static int pm8941_wled_probe(struct platform_device *pdev) bl = devm_backlight_device_register(&pdev->dev, wled->name, &pdev->dev, wled, &pm8941_wled_ops, &props); - if (IS_ERR(bl)) - return PTR_ERR(bl); - - return 0; + return PTR_ERR_OR_ZERO(bl); }; static const struct of_device_id pm8941_wled_match_table[] = { -- cgit v1.2.3 From 9d6c243502b7f0a9696bc6fe5b473e40d8478d28 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Mon, 26 Oct 2015 10:45:08 -0700 Subject: backlight: pm8941-wled: Add default-brightness property Default the brightness to 2048 and add possibility to override this in device tree. Suggested-by: Rob Clark Signed-off-by: Bjorn Andersson Acked-by: Rob Herring Signed-off-by: Lee Jones --- Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt | 2 ++ drivers/video/backlight/pm8941-wled.c | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'drivers/video/backlight') diff --git a/Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt b/Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt index 424f8444a6cd..e5b294dafc58 100644 --- a/Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt +++ b/Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt @@ -5,6 +5,8 @@ Required properties: - reg: slave address Optional properties: +- default-brightness: brightness value on boot, value from: 0-4095 + default: 2048 - label: The name of the backlight device - qcom,cs-out: bool; enable current sink output - qcom,cabc: bool; enable content adaptive backlight control diff --git a/drivers/video/backlight/pm8941-wled.c b/drivers/video/backlight/pm8941-wled.c index 78bba87551b2..0b6d21955d91 100644 --- a/drivers/video/backlight/pm8941-wled.c +++ b/drivers/video/backlight/pm8941-wled.c @@ -17,6 +17,9 @@ #include #include +/* From DT binding */ +#define PM8941_WLED_DEFAULT_BRIGHTNESS 2048 + #define PM8941_WLED_REG_VAL_BASE 0x40 #define PM8941_WLED_REG_VAL_MAX 0xFFF @@ -373,6 +376,7 @@ static int pm8941_wled_probe(struct platform_device *pdev) struct backlight_device *bl; struct pm8941_wled *wled; struct regmap *regmap; + u32 val; int rc; regmap = dev_get_regmap(pdev->dev.parent, NULL); @@ -395,8 +399,12 @@ static int pm8941_wled_probe(struct platform_device *pdev) if (rc) return rc; + val = PM8941_WLED_DEFAULT_BRIGHTNESS; + of_property_read_u32(pdev->dev.of_node, "default-brightness", &val); + memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; + props.brightness = val; props.max_brightness = PM8941_WLED_REG_VAL_MAX; bl = devm_backlight_device_register(&pdev->dev, wled->name, &pdev->dev, wled, -- cgit v1.2.3