Skip to content

Commit 8caa81e

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: meson: Explicitly set .polarity in .get_state()
The driver only supports normal polarity. Complete the implementation of .get_state() by setting .polarity accordingly. This fixes a regression that was possible since commit c73a310 ("pwm: Handle .get_state() failures") which stopped to zero-initialize the state passed to the .get_state() callback. This was reported at https://forum.odroid.com/viewtopic.php?f=177&t=46360 . While this was an unintended side effect, the real issue is the driver's callback not setting the polarity. There is a complicating fact, that the .apply() callback fakes support for inversed polarity. This is not (and cannot) be matched by .get_state(). As fixing this isn't easy, only point it out in a comment to prevent authors of other drivers from copying that approach. Fixes: c375bcb ("pwm: meson: Read the full hardware state in meson_pwm_get_state()") Reported-by: Munehisa Kamata <[email protected]> Acked-by: Martin Blumenstingl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 2be4dcf commit 8caa81e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/pwm/pwm-meson.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
162162
duty = state->duty_cycle;
163163
period = state->period;
164164

165+
/*
166+
* Note this is wrong. The result is an output wave that isn't really
167+
* inverted and so is wrongly identified by .get_state as normal.
168+
* Fixing this needs some care however as some machines might rely on
169+
* this.
170+
*/
165171
if (state->polarity == PWM_POLARITY_INVERSED)
166172
duty = period - duty;
167173

@@ -358,6 +364,8 @@ static int meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
358364
state->duty_cycle = 0;
359365
}
360366

367+
state->polarity = PWM_POLARITY_NORMAL;
368+
361369
return 0;
362370
}
363371

0 commit comments

Comments
 (0)