Skip to content

Commit

Permalink
pwm: Keep PWM state in sync with hardware state
Browse files Browse the repository at this point in the history
Before the introduction of pwm_args, the core was resetting the PWM
period and polarity states to the reference values (those provided
through the DT, a PWM lookup table or hardcoded in the driver).

Now that all PWM users are correctly using pwm_args to configure their
PWM device, we can safely remove the pwm_apply_args() call in pwm_get()
and of_pwm_get().

We can also get rid of the pwm_set_period() call in pwm_apply_args(),
because PWM users are now directly using pargs->period instead of
pwm_get_period(). By doing that we avoid messing with the current PWM
period.

The only remaining bit in pwm_apply_args() is the initial polarity
setting, and it should go away when all PWM users have been patched to
use the atomic API (with this API the polarity will be set along with
other PWM arguments when configuring the PWM).

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Boris Brezillon authored and Thierry Reding committed May 17, 2016
1 parent 102232c commit a8c3862
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
14 changes: 0 additions & 14 deletions drivers/pwm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,6 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)

pwm->label = con_id;

/*
* FIXME: This should be removed once all PWM users properly make use
* of struct pwm_args to initialize the PWM device. As long as this is
* here, the PWM state and hardware state can get out of sync.
*/
pwm_apply_args(pwm);

put:
of_node_put(args.np);

Expand Down Expand Up @@ -750,13 +743,6 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
pwm->args.period = chosen->period;
pwm->args.polarity = chosen->polarity;

/*
* FIXME: This should be removed once all PWM users properly make use
* of struct pwm_args to initialize the PWM device. As long as this is
* here, the PWM state and hardware state can get out of sync.
*/
pwm_apply_args(pwm);

out:
mutex_unlock(&pwm_lookup_lock);
return pwm;
Expand Down
1 change: 0 additions & 1 deletion include/linux/pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ static inline void pwm_get_args(const struct pwm_device *pwm,

static inline void pwm_apply_args(struct pwm_device *pwm)
{
pwm_set_period(pwm, pwm->args.period);
pwm_set_polarity(pwm, pwm->args.polarity);
}

Expand Down

0 comments on commit a8c3862

Please sign in to comment.