diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-14 13:34:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-14 13:34:33 -0500 |
commit | b14bf630be972aceb0c8981f9794e612cbb141f7 (patch) | |
tree | e0c50f281b671e816f609cda533507d228f1acd2 | |
parent | 7fdec82af6a9e190e53d07a1463d2a9ac49a8750 (diff) | |
parent | 60d613d6aef4ae49988eeb3ad38af948c561db1e (diff) |
Merge tag 'backlight-for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones:
Fix-ups:
- Take heed of GPIO default-on requests; gpio_backlight
- Enable DT probing; tps65217_bl
Bug Fixes:
- Free resources in error path; pwm_bl
- Fix uninitialised variable warning; adp8860_bl, adp8870_bl
- Protect unconditional DT look-ups from non-DT platforms; pwm_bl
- Fix backlight flicker; pwm_bl
* tag 'backlight-for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
backlight: pwm_bl: Free PWM requested by legacy API on error path
backlight: adp8860: Fix another uninitialized variable use
backlight: gpio-backlight: Use default-on on GPIO request
backlight: pwm_bl: Fix broken PWM backlight for non-dt platforms
backlight: tps65217_bl: Add MODULE_DEVICE_TABLE
backlight: pwm_bl: Avoid backlight flicker when probed from DT
backlight: adp88x0: Fix uninitialized variable use
-rw-r--r-- | drivers/video/backlight/adp8860_bl.c | 18 | ||||
-rw-r--r-- | drivers/video/backlight/adp8870_bl.c | 10 | ||||
-rw-r--r-- | drivers/video/backlight/gpio_backlight.c | 10 | ||||
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 28 | ||||
-rw-r--r-- | drivers/video/backlight/tps65217_bl.c | 9 |
5 files changed, 58 insertions, 17 deletions
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index 98ffe71e8af2..510e559c060e 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c | |||
@@ -566,11 +566,13 @@ static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev, | |||
566 | 566 | ||
567 | mutex_lock(&data->lock); | 567 | mutex_lock(&data->lock); |
568 | error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val); | 568 | error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val); |
569 | ret_val = reg_val; | 569 | if (!error) { |
570 | error |= adp8860_read(data->client, ADP8860_PH1LEVH, ®_val); | 570 | ret_val = reg_val; |
571 | error = adp8860_read(data->client, ADP8860_PH1LEVH, ®_val); | ||
572 | } | ||
571 | mutex_unlock(&data->lock); | 573 | mutex_unlock(&data->lock); |
572 | 574 | ||
573 | if (error < 0) | 575 | if (error) |
574 | return error; | 576 | return error; |
575 | 577 | ||
576 | /* Return 13-bit conversion value for the first light sensor */ | 578 | /* Return 13-bit conversion value for the first light sensor */ |
@@ -621,10 +623,12 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev, | |||
621 | 623 | ||
622 | /* Set user supplied ambient light zone */ | 624 | /* Set user supplied ambient light zone */ |
623 | mutex_lock(&data->lock); | 625 | mutex_lock(&data->lock); |
624 | adp8860_read(data->client, ADP8860_CFGR, ®_val); | 626 | ret = adp8860_read(data->client, ADP8860_CFGR, ®_val); |
625 | reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); | 627 | if (!ret) { |
626 | reg_val |= (val - 1) << CFGR_BLV_SHIFT; | 628 | reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); |
627 | adp8860_write(data->client, ADP8860_CFGR, reg_val); | 629 | reg_val |= (val - 1) << CFGR_BLV_SHIFT; |
630 | adp8860_write(data->client, ADP8860_CFGR, reg_val); | ||
631 | } | ||
628 | mutex_unlock(&data->lock); | 632 | mutex_unlock(&data->lock); |
629 | } | 633 | } |
630 | 634 | ||
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 9d738352d7d4..21acac90fd77 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c | |||
@@ -807,10 +807,12 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev, | |||
807 | 807 | ||
808 | /* Set user supplied ambient light zone */ | 808 | /* Set user supplied ambient light zone */ |
809 | mutex_lock(&data->lock); | 809 | mutex_lock(&data->lock); |
810 | adp8870_read(data->client, ADP8870_CFGR, ®_val); | 810 | ret = adp8870_read(data->client, ADP8870_CFGR, ®_val); |
811 | reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); | 811 | if (!ret) { |
812 | reg_val |= (val - 1) << CFGR_BLV_SHIFT; | 812 | reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); |
813 | adp8870_write(data->client, ADP8870_CFGR, reg_val); | 813 | reg_val |= (val - 1) << CFGR_BLV_SHIFT; |
814 | adp8870_write(data->client, ADP8870_CFGR, reg_val); | ||
815 | } | ||
814 | mutex_unlock(&data->lock); | 816 | mutex_unlock(&data->lock); |
815 | } | 817 | } |
816 | 818 | ||
diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index 5fbbc2ebdf93..18134416b154 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c | |||
@@ -89,6 +89,7 @@ static int gpio_backlight_probe(struct platform_device *pdev) | |||
89 | struct backlight_device *bl; | 89 | struct backlight_device *bl; |
90 | struct gpio_backlight *gbl; | 90 | struct gpio_backlight *gbl; |
91 | struct device_node *np = pdev->dev.of_node; | 91 | struct device_node *np = pdev->dev.of_node; |
92 | unsigned long flags = GPIOF_DIR_OUT; | ||
92 | int ret; | 93 | int ret; |
93 | 94 | ||
94 | if (!pdata && !np) { | 95 | if (!pdata && !np) { |
@@ -114,9 +115,12 @@ static int gpio_backlight_probe(struct platform_device *pdev) | |||
114 | gbl->def_value = pdata->def_value; | 115 | gbl->def_value = pdata->def_value; |
115 | } | 116 | } |
116 | 117 | ||
117 | ret = devm_gpio_request_one(gbl->dev, gbl->gpio, GPIOF_DIR_OUT | | 118 | if (gbl->active) |
118 | (gbl->active ? GPIOF_INIT_LOW | 119 | flags |= gbl->def_value ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW; |
119 | : GPIOF_INIT_HIGH), | 120 | else |
121 | flags |= gbl->def_value ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH; | ||
122 | |||
123 | ret = devm_gpio_request_one(gbl->dev, gbl->gpio, flags, | ||
120 | pdata ? pdata->name : "backlight"); | 124 | pdata ? pdata->name : "backlight"); |
121 | if (ret < 0) { | 125 | if (ret < 0) { |
122 | dev_err(&pdev->dev, "unable to request GPIO\n"); | 126 | dev_err(&pdev->dev, "unable to request GPIO\n"); |
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index ae3c6b6fd5db..64f9e1b8655f 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
@@ -198,7 +198,9 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
198 | struct platform_pwm_backlight_data defdata; | 198 | struct platform_pwm_backlight_data defdata; |
199 | struct backlight_properties props; | 199 | struct backlight_properties props; |
200 | struct backlight_device *bl; | 200 | struct backlight_device *bl; |
201 | struct device_node *node = pdev->dev.of_node; | ||
201 | struct pwm_bl_data *pb; | 202 | struct pwm_bl_data *pb; |
203 | int initial_blank = FB_BLANK_UNBLANK; | ||
202 | int ret; | 204 | int ret; |
203 | 205 | ||
204 | if (!data) { | 206 | if (!data) { |
@@ -242,7 +244,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
242 | pb->enabled = false; | 244 | pb->enabled = false; |
243 | 245 | ||
244 | pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", | 246 | pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", |
245 | GPIOD_OUT_HIGH); | 247 | GPIOD_ASIS); |
246 | if (IS_ERR(pb->enable_gpio)) { | 248 | if (IS_ERR(pb->enable_gpio)) { |
247 | ret = PTR_ERR(pb->enable_gpio); | 249 | ret = PTR_ERR(pb->enable_gpio); |
248 | goto err_alloc; | 250 | goto err_alloc; |
@@ -264,15 +266,32 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
264 | pb->enable_gpio = gpio_to_desc(data->enable_gpio); | 266 | pb->enable_gpio = gpio_to_desc(data->enable_gpio); |
265 | } | 267 | } |
266 | 268 | ||
269 | if (pb->enable_gpio) { | ||
270 | /* | ||
271 | * If the driver is probed from the device tree and there is a | ||
272 | * phandle link pointing to the backlight node, it is safe to | ||
273 | * assume that another driver will enable the backlight at the | ||
274 | * appropriate time. Therefore, if it is disabled, keep it so. | ||
275 | */ | ||
276 | if (node && node->phandle && | ||
277 | gpiod_get_direction(pb->enable_gpio) == GPIOF_DIR_OUT && | ||
278 | gpiod_get_value(pb->enable_gpio) == 0) | ||
279 | initial_blank = FB_BLANK_POWERDOWN; | ||
280 | else | ||
281 | gpiod_direction_output(pb->enable_gpio, 1); | ||
282 | } | ||
283 | |||
267 | pb->power_supply = devm_regulator_get(&pdev->dev, "power"); | 284 | pb->power_supply = devm_regulator_get(&pdev->dev, "power"); |
268 | if (IS_ERR(pb->power_supply)) { | 285 | if (IS_ERR(pb->power_supply)) { |
269 | ret = PTR_ERR(pb->power_supply); | 286 | ret = PTR_ERR(pb->power_supply); |
270 | goto err_alloc; | 287 | goto err_alloc; |
271 | } | 288 | } |
272 | 289 | ||
290 | if (node && node->phandle && !regulator_is_enabled(pb->power_supply)) | ||
291 | initial_blank = FB_BLANK_POWERDOWN; | ||
292 | |||
273 | pb->pwm = devm_pwm_get(&pdev->dev, NULL); | 293 | pb->pwm = devm_pwm_get(&pdev->dev, NULL); |
274 | if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER | 294 | if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER && !node) { |
275 | && !pdev->dev.of_node) { | ||
276 | dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); | 295 | dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); |
277 | pb->legacy = true; | 296 | pb->legacy = true; |
278 | pb->pwm = pwm_request(data->pwm_id, "pwm-backlight"); | 297 | pb->pwm = pwm_request(data->pwm_id, "pwm-backlight"); |
@@ -309,6 +328,8 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
309 | if (IS_ERR(bl)) { | 328 | if (IS_ERR(bl)) { |
310 | dev_err(&pdev->dev, "failed to register backlight\n"); | 329 | dev_err(&pdev->dev, "failed to register backlight\n"); |
311 | ret = PTR_ERR(bl); | 330 | ret = PTR_ERR(bl); |
331 | if (pb->legacy) | ||
332 | pwm_free(pb->pwm); | ||
312 | goto err_alloc; | 333 | goto err_alloc; |
313 | } | 334 | } |
314 | 335 | ||
@@ -320,6 +341,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
320 | } | 341 | } |
321 | 342 | ||
322 | bl->props.brightness = data->dft_brightness; | 343 | bl->props.brightness = data->dft_brightness; |
344 | bl->props.power = initial_blank; | ||
323 | backlight_update_status(bl); | 345 | backlight_update_status(bl); |
324 | 346 | ||
325 | platform_set_drvdata(pdev, bl); | 347 | platform_set_drvdata(pdev, bl); |
diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c index 61d72bffd402..fd524ad860a5 100644 --- a/drivers/video/backlight/tps65217_bl.c +++ b/drivers/video/backlight/tps65217_bl.c | |||
@@ -320,10 +320,19 @@ static int tps65217_bl_probe(struct platform_device *pdev) | |||
320 | return 0; | 320 | return 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | #ifdef CONFIG_OF | ||
324 | static const struct of_device_id tps65217_bl_of_match[] = { | ||
325 | { .compatible = "ti,tps65217-bl", }, | ||
326 | { /* sentinel */ }, | ||
327 | }; | ||
328 | MODULE_DEVICE_TABLE(of, tps65217_bl_of_match); | ||
329 | #endif | ||
330 | |||
323 | static struct platform_driver tps65217_bl_driver = { | 331 | static struct platform_driver tps65217_bl_driver = { |
324 | .probe = tps65217_bl_probe, | 332 | .probe = tps65217_bl_probe, |
325 | .driver = { | 333 | .driver = { |
326 | .name = "tps65217-bl", | 334 | .name = "tps65217-bl", |
335 | .of_match_table = of_match_ptr(tps65217_bl_of_match), | ||
327 | }, | 336 | }, |
328 | }; | 337 | }; |
329 | 338 | ||