Pull pwm fixes from Thierry Reding: "One more fix for some fallout observed after the introduction of the atomic API" * tag 'pwm/for-4.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: pwm: Fix pwm_apply_args()
Unified · Split
| @@ -464,6 +464,8 @@ static inline bool pwm_can_sleep(struct pwm_device *pwm) · 463 unmodified lines | ||
| 464 | 464 | |
| 465 | 465 | static inline void pwm_apply_args(struct pwm_device *pwm) |
| 466 | 466 | { |
| 467 | + struct pwm_state state = { }; | |
| 468 | + | |
| 467 | 469 | /* |
| 468 | 470 | * PWM users calling pwm_apply_args() expect to have a fresh config |
| 469 | 471 | * where the polarity and period are set according to pwm_args info. |
| @@ -476,18 +478,20 @@ static inline void pwm_apply_args(struct pwm_device *pwm) · 6 unmodified lines | ||
| 476 | 478 | * at startup (even if they are actually enabled), thus authorizing |
| 477 | 479 | * polarity setting. |
| 478 | 480 | * |
| 479 | − * Instead of setting ->enabled to false, we call pwm_disable() | |
| 480 | − * before pwm_set_polarity() to ensure that everything is configured | |
| 481 | − * as expected, and the PWM is really disabled when the user request | |
| 482 | − * it. | |
| 481 | + * To fulfill this requirement, we apply a new state which disables | |
| 482 | + * the PWM device and set the reference period and polarity config. | |
| 483 | 483 | * |
| 484 | 484 | * Note that PWM users requiring a smooth handover between the |
| 485 | 485 | * bootloader and the kernel (like critical regulators controlled by |
| 486 | 486 | * PWM devices) will have to switch to the atomic API and avoid calling |
| 487 | 487 | * pwm_apply_args(). |
| 488 | 488 | */ |
| 489 | − pwm_disable(pwm); | |
| 490 | − pwm_set_polarity(pwm, pwm->args.polarity); | |
| 489 | + | |
| 490 | + state.enabled = false; | |
| 491 | + state.polarity = pwm->args.polarity; | |
| 492 | + state.period = pwm->args.period; | |
| 493 | + | |
| 494 | + pwm_apply_state(pwm, &state); | |
| 491 | 495 | } |
| 492 | 496 | |
| 493 | 497 | struct pwm_lookup { |