Skip to content

Commit f2ac0a8

Browse files
mairacanallag-linaro
authored andcommitted
backlight: lp855x: Switch to atomic PWM API
Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and replace it for the atomic PWM API. Signed-off-by: Maíra Canal <[email protected]> Reviewed-by: Uwe Kleine-König <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Signed-off-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2654f59 commit f2ac0a8

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

drivers/video/backlight/lp855x_bl.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,8 @@ static int lp855x_configure(struct lp855x *lp)
218218

219219
static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
220220
{
221-
unsigned int period = lp->pdata->period_ns;
222-
unsigned int duty = br * period / max_br;
223221
struct pwm_device *pwm;
222+
struct pwm_state state;
224223

225224
/* request pwm device with the consumer name */
226225
if (!lp->pwm) {
@@ -230,18 +229,16 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
230229

231230
lp->pwm = pwm;
232231

233-
/*
234-
* FIXME: pwm_apply_args() should be removed when switching to
235-
* the atomic PWM API.
236-
*/
237-
pwm_apply_args(pwm);
232+
pwm_init_state(lp->pwm, &state);
233+
} else {
234+
pwm_get_state(lp->pwm, &state);
238235
}
239236

240-
pwm_config(lp->pwm, duty, period);
241-
if (duty)
242-
pwm_enable(lp->pwm);
243-
else
244-
pwm_disable(lp->pwm);
237+
state.period = lp->pdata->period_ns;
238+
state.duty_cycle = div_u64(br * state.period, max_br);
239+
state.enabled = state.duty_cycle;
240+
241+
pwm_apply_state(lp->pwm, &state);
245242
}
246243

247244
static int lp855x_bl_update_status(struct backlight_device *bl)

0 commit comments

Comments
 (0)