Skip to content

Commit

Permalink
Merge tag 'pwm/for-3.17-rc2' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/thierry.reding/linux-pwm

Pull pwm fix from Thierry Reding:
 "Just one bugfix for the PWM lookup table code that would cause a PWM
  channel to be set to the wrong period and polarity for non-perfect
  matches"

* tag 'pwm/for-3.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm:
  pwm: Fix period and polarity in pwm_get() for non-perfect matches
  • Loading branch information
Linus Torvalds committed Aug 22, 2014
2 parents 47e4df9 + d717ea7 commit 451fd72
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/pwm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
unsigned int best = 0;
struct pwm_lookup *p;
unsigned int match;
unsigned int period;
enum pwm_polarity polarity;

/* look up via DT first */
if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
Expand Down Expand Up @@ -653,6 +655,8 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
if (match > best) {
chip = pwmchip_find_by_name(p->provider);
index = p->index;
period = p->period;
polarity = p->polarity;

if (match != 3)
best = match;
Expand All @@ -668,8 +672,8 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
if (IS_ERR(pwm))
return pwm;

pwm_set_period(pwm, p->period);
pwm_set_polarity(pwm, p->polarity);
pwm_set_period(pwm, period);
pwm_set_polarity(pwm, polarity);


return pwm;
Expand Down

0 comments on commit 451fd72

Please sign in to comment.