@@ -605,9 +605,18 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
if (state->period != pwm->state.period ||
state->duty_cycle != pwm->state.duty_cycle) {
+ int duty_cycle, period;
+
+ /*
+ * The legacy callbacks use only (signed!) int for
+ * period and duty_cycle compared to u64 in struct
+ * pwm_state. So clamp the values to INT_MAX.
+ */
+ period = min(state->period, (u64)INT_MAX);
+ duty_cycle = min(state->duty_cycle, (u64)INT_MAX);
+
err = chip->ops->config(pwm->chip, pwm,
- state->duty_cycle,
- state->period);
+ duty_cycle, period);
if (err)
return err;