Skip to content

Commit

Permalink
Merge tag 'pwm/for-4.7-rc4' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/thierry.reding/linux-pwm

Pull pwm fixes from Thierry Reding:
 "These changes fix a bit of fallout from the introduction of the atomic
  API"

* tag 'pwm/for-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm:
  pwm: atmel-hlcdc: Fix default PWM polarity
  pwm: sysfs: Get return value from pwm_apply_state()
  pwm: Improve args checking in pwm_apply_state()
  • Loading branch information
torvalds committed Jun 17, 2016
2 parents 2668bc7 + cc51846 commit bb96727
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion drivers/pwm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
{
int err;

if (!pwm)
if (!pwm || !state || !state->period ||
state->duty_cycle > state->period)
return -EINVAL;

if (!memcmp(state, &pwm->state, sizeof(*state)))
Expand Down
2 changes: 1 addition & 1 deletion drivers/pwm/pwm-atmel-hlcdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
chip->chip.of_pwm_n_cells = 3;
chip->chip.can_sleep = 1;

ret = pwmchip_add(&chip->chip);
ret = pwmchip_add_with_polarity(&chip->chip, PWM_POLARITY_INVERSED);
if (ret) {
clk_disable_unprepare(hlcdc->periph_clk);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/pwm/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static ssize_t enable_store(struct device *child,
goto unlock;
}

pwm_apply_state(pwm, &state);
ret = pwm_apply_state(pwm, &state);

unlock:
mutex_unlock(&export->lock);
Expand Down
3 changes: 3 additions & 0 deletions include/linux/pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ static inline int pwm_config(struct pwm_device *pwm, int duty_ns,
if (!pwm)
return -EINVAL;

if (duty_ns < 0 || period_ns < 0)
return -EINVAL;

pwm_get_state(pwm, &state);
if (state.duty_cycle == duty_ns && state.period == period_ns)
return 0;
Expand Down

0 comments on commit bb96727

Please sign in to comment.