pwm: rockchip: Simplify rockchip_pwm_get_state()
The way state->enabled is computed is rather convoluted and hard to read - both branches of the if() actually do the exact same thing. So remove the if(), and further simplify "<boolean condition> ? true : false" to "<boolean condition>". Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
Родитель
ca162ce981
Коммит
cad0f29606
|
@ -83,12 +83,7 @@ static void rockchip_pwm_get_state(struct pwm_chip *chip,
|
||||||
state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, clk_rate);
|
state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, clk_rate);
|
||||||
|
|
||||||
val = readl_relaxed(pc->base + pc->data->regs.ctrl);
|
val = readl_relaxed(pc->base + pc->data->regs.ctrl);
|
||||||
if (pc->data->supports_polarity)
|
state->enabled = (val & enable_conf) == enable_conf;
|
||||||
state->enabled = ((val & enable_conf) != enable_conf) ?
|
|
||||||
false : true;
|
|
||||||
else
|
|
||||||
state->enabled = ((val & enable_conf) == enable_conf) ?
|
|
||||||
true : false;
|
|
||||||
|
|
||||||
if (pc->data->supports_polarity && !(val & PWM_DUTY_POSITIVE))
|
if (pc->data->supports_polarity && !(val & PWM_DUTY_POSITIVE))
|
||||||
state->polarity = PWM_POLARITY_INVERSED;
|
state->polarity = PWM_POLARITY_INVERSED;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче