[PATCH] pwm: removes period check from pwm_apply_state()

From: Tamseel Shams
Date: Fri Aug 05 2022 - 11:40:24 EST


There may be situation when PWM is exported using sysfs,
but at that point PWM period is not set. At this situation
if we issue a system suspend, it calls pwm_class_suspend
which in turn calls pwm_apply_state, where PWM period value is
checked which returns an invalid argument error casuing Kernel
to panic. So, check for PWM period value is removed so as to
fix the kernel panic observed during suspend.

Signed-off-by: Tamseel Shams <m.shams@xxxxxxxxxxx>
---
drivers/pwm/core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index c7552df32082..69bca7f82398 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -634,8 +634,7 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
*/
might_sleep();

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

chip = pwm->chip;
--
2.17.1