@@ -115,8 +115,13 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
115
115
}
116
116
117
117
if (pwm -> chip -> ops -> get_state ) {
118
- err = pwm -> chip -> ops -> get_state (pwm -> chip , pwm , & pwm -> state );
119
- trace_pwm_get (pwm , & pwm -> state , err );
118
+ struct pwm_state state ;
119
+
120
+ err = pwm -> chip -> ops -> get_state (pwm -> chip , pwm , & state );
121
+ trace_pwm_get (pwm , & state , err );
122
+
123
+ if (!err )
124
+ pwm -> state = state ;
120
125
121
126
if (IS_ENABLED (CONFIG_PWM_DEBUG ))
122
127
pwm -> last = pwm -> state ;
@@ -460,6 +465,9 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
460
465
461
466
err = chip -> ops -> get_state (chip , pwm , & s1 );
462
467
trace_pwm_get (pwm , & s1 , err );
468
+ if (err )
469
+ /* If that failed there isn't much to debug */
470
+ return ;
463
471
464
472
/*
465
473
* The lowlevel driver either ignored .polarity (which is a bug) or as
@@ -524,6 +532,8 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
524
532
525
533
err = chip -> ops -> get_state (chip , pwm , last );
526
534
trace_pwm_get (pwm , last , err );
535
+ if (err )
536
+ return ;
527
537
528
538
/* reapplication of the current state should give an exact match */
529
539
if (s1 .enabled != last -> enabled ||
0 commit comments