Commit b14bf630 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 7fdec82a 60d613d6
......@@ -566,11 +566,13 @@ static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev,
mutex_lock(&data->lock);
error = adp8860_read(data->client, ADP8860_PH1LEVL, &reg_val);
if (!error) {
ret_val = reg_val;
error |= adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
error = adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
}
mutex_unlock(&data->lock);
if (error < 0)
if (error)
return error;
/* 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,
/* Set user supplied ambient light zone */
mutex_lock(&data->lock);
adp8860_read(data->client, ADP8860_CFGR, &reg_val);
ret = adp8860_read(data->client, ADP8860_CFGR, &reg_val);
if (!ret) {
reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
reg_val |= (val - 1) << CFGR_BLV_SHIFT;
adp8860_write(data->client, ADP8860_CFGR, reg_val);
}
mutex_unlock(&data->lock);
}
......
......@@ -807,10 +807,12 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev,
/* Set user supplied ambient light zone */
mutex_lock(&data->lock);
adp8870_read(data->client, ADP8870_CFGR, &reg_val);
ret = adp8870_read(data->client, ADP8870_CFGR, &reg_val);
if (!ret) {
reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
reg_val |= (val - 1) << CFGR_BLV_SHIFT;
adp8870_write(data->client, ADP8870_CFGR, reg_val);
}
mutex_unlock(&data->lock);
}
......
......@@ -89,6 +89,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
struct backlight_device *bl;
struct gpio_backlight *gbl;
struct device_node *np = pdev->dev.of_node;
unsigned long flags = GPIOF_DIR_OUT;
int ret;
if (!pdata && !np) {
......@@ -114,9 +115,12 @@ static int gpio_backlight_probe(struct platform_device *pdev)
gbl->def_value = pdata->def_value;
}
ret = devm_gpio_request_one(gbl->dev, gbl->gpio, GPIOF_DIR_OUT |
(gbl->active ? GPIOF_INIT_LOW
: GPIOF_INIT_HIGH),
if (gbl->active)
flags |= gbl->def_value ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW;
else
flags |= gbl->def_value ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH;
ret = devm_gpio_request_one(gbl->dev, gbl->gpio, flags,
pdata ? pdata->name : "backlight");
if (ret < 0) {
dev_err(&pdev->dev, "unable to request GPIO\n");
......
......@@ -198,7 +198,9 @@ static int pwm_backlight_probe(struct platform_device *pdev)
struct platform_pwm_backlight_data defdata;
struct backlight_properties props;
struct backlight_device *bl;
struct device_node *node = pdev->dev.of_node;
struct pwm_bl_data *pb;
int initial_blank = FB_BLANK_UNBLANK;
int ret;
if (!data) {
......@@ -242,7 +244,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->enabled = false;
pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
GPIOD_OUT_HIGH);
GPIOD_ASIS);
if (IS_ERR(pb->enable_gpio)) {
ret = PTR_ERR(pb->enable_gpio);
goto err_alloc;
......@@ -264,15 +266,32 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->enable_gpio = gpio_to_desc(data->enable_gpio);
}
if (pb->enable_gpio) {
/*
* If the driver is probed from the device tree and there is a
* phandle link pointing to the backlight node, it is safe to
* assume that another driver will enable the backlight at the
* appropriate time. Therefore, if it is disabled, keep it so.
*/
if (node && node->phandle &&
gpiod_get_direction(pb->enable_gpio) == GPIOF_DIR_OUT &&
gpiod_get_value(pb->enable_gpio) == 0)
initial_blank = FB_BLANK_POWERDOWN;
else
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);
goto err_alloc;
}
if (node && node->phandle && !regulator_is_enabled(pb->power_supply))
initial_blank = FB_BLANK_POWERDOWN;
pb->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER
&& !pdev->dev.of_node) {
if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER && !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");
......@@ -309,6 +328,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
if (IS_ERR(bl)) {
dev_err(&pdev->dev, "failed to register backlight\n");
ret = PTR_ERR(bl);
if (pb->legacy)
pwm_free(pb->pwm);
goto err_alloc;
}
......@@ -320,6 +341,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
}
bl->props.brightness = data->dft_brightness;
bl->props.power = initial_blank;
backlight_update_status(bl);
platform_set_drvdata(pdev, bl);
......
......@@ -320,10 +320,19 @@ static int tps65217_bl_probe(struct platform_device *pdev)
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id tps65217_bl_of_match[] = {
{ .compatible = "ti,tps65217-bl", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, tps65217_bl_of_match);
#endif
static struct platform_driver tps65217_bl_driver = {
.probe = tps65217_bl_probe,
.driver = {
.name = "tps65217-bl",
.of_match_table = of_match_ptr(tps65217_bl_of_match),
},
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment