Commit 57ac7ff8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull backlight updates from Lee Jones:
 "New Functionality:

   - Ensure correct includes are present and remove some that are not
     required

   - Drop redundant of_match_ptr() call to cast pointer to NULL

  Bug Fixes:

   - Revert to old (expected) behaviour of initialising PWM state on
     first brightness change

   - Correctly handle / propagate errors

   - Fix 'sometimes-uninitialised' issues"

* tag 'backlight-next-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  backlight: led_bl: Remove redundant of_match_ptr()
  backlight: lp855x: Drop ret variable in brightness change function
  backlight: gpio_backlight: Drop output GPIO direction check for initial power state
  backlight: lp855x: Catch errors when changing brightness
  backlight: lp855x: Initialize PWM state on first brightness change
  backlight: qcom-wled: Explicitly include correct DT includes
parents 65d6e954 a4464092
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -87,8 +87,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
		/* Not booted with device tree or no phandle link to the node */
		bl->props.power = def_value ? FB_BLANK_UNBLANK
					    : FB_BLANK_POWERDOWN;
	else if (gpiod_get_direction(gbl->gpiod) == 0 &&
		 gpiod_get_value_cansleep(gbl->gpiod) == 0)
	else if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
		bl->props.power = FB_BLANK_POWERDOWN;
	else
		bl->props.power = FB_BLANK_UNBLANK;
+1 −1
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ MODULE_DEVICE_TABLE(of, led_bl_of_match);
static struct platform_driver led_bl_driver = {
	.driver		= {
		.name		= "led-backlight",
		.of_match_table	= of_match_ptr(led_bl_of_match),
		.of_match_table	= led_bl_of_match,
	},
	.probe		= led_bl_probe,
	.remove_new	= led_bl_remove,
+19 −14
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ struct lp855x {
	struct device *dev;
	struct lp855x_platform_data *pdata;
	struct pwm_device *pwm;
	bool needs_pwm_init;
	struct regulator *supply;	/* regulator for VDD input */
	struct regulator *enable;	/* regulator for EN/VDDIO input */
};
@@ -216,16 +217,24 @@ static int lp855x_configure(struct lp855x *lp)
	return ret;
}

static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
static int lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
{
	struct pwm_state state;

	if (lp->needs_pwm_init) {
		pwm_init_state(lp->pwm, &state);
		/* Legacy platform data compatibility */
		if (lp->pdata->period_ns > 0)
			state.period = lp->pdata->period_ns;
		lp->needs_pwm_init = false;
	} else {
		pwm_get_state(lp->pwm, &state);
	}

	state.duty_cycle = div_u64(br * state.period, max_br);
	state.enabled = state.duty_cycle;

	pwm_apply_state(lp->pwm, &state);
	return pwm_apply_state(lp->pwm, &state);
}

static int lp855x_bl_update_status(struct backlight_device *bl)
@@ -237,11 +246,12 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
		brightness = 0;

	if (lp->mode == PWM_BASED)
		lp855x_pwm_ctrl(lp, brightness, bl->props.max_brightness);
		return lp855x_pwm_ctrl(lp, brightness,
				      bl->props.max_brightness);
	else if (lp->mode == REGISTER_BASED)
		lp855x_write_byte(lp, lp->cfg->reg_brightness, (u8)brightness);

	return 0;
		return lp855x_write_byte(lp, lp->cfg->reg_brightness,
					(u8)brightness);
	return -EINVAL;
}

static const struct backlight_ops lp855x_bl_ops = {
@@ -387,7 +397,6 @@ static int lp855x_probe(struct i2c_client *cl)
	const struct i2c_device_id *id = i2c_client_get_device_id(cl);
	const struct acpi_device_id *acpi_id = NULL;
	struct device *dev = &cl->dev;
	struct pwm_state pwmstate;
	struct lp855x *lp;
	int ret;

@@ -470,15 +479,11 @@ static int lp855x_probe(struct i2c_client *cl)
		else
			return dev_err_probe(dev, ret, "getting PWM\n");

		lp->needs_pwm_init = false;
		lp->mode = REGISTER_BASED;
		dev_dbg(dev, "mode: register based\n");
	} else {
		pwm_init_state(lp->pwm, &pwmstate);
		/* Legacy platform data compatibility */
		if (lp->pdata->period_ns > 0)
			pwmstate.period = lp->pdata->period_ns;
		pwm_apply_state(lp->pwm, &pwmstate);

		lp->needs_pwm_init = true;
		lp->mode = PWM_BASED;
		dev_dbg(dev, "mode: PWM based\n");
	}
+1 −1
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@
#include <linux/backlight.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

/* From DT binding */