On 8/29/25 7:42 PM, Marcelo Schmitt wrote: > From: Axel Haslam <ahaslam@xxxxxxxxxxxx> > > Pass the duty offset to the waveform pwm. > > Signed-off-by: Axel Haslam <ahaslam@xxxxxxxxxxxx> > Signed-off-by: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx> > --- > drivers/spi/spi-offload-trigger-pwm.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/spi/spi-offload-trigger-pwm.c b/drivers/spi/spi-offload-trigger-pwm.c > index 805ed41560df..8413aeb3689d 100644 > --- a/drivers/spi/spi-offload-trigger-pwm.c > +++ b/drivers/spi/spi-offload-trigger-pwm.c > @@ -51,13 +51,13 @@ static int spi_offload_trigger_pwm_validate(struct spi_offload_trigger *trigger, > wf.period_length_ns = DIV_ROUND_UP_ULL(NSEC_PER_SEC, periodic->frequency_hz); > /* REVISIT: 50% duty-cycle for now - may add config parameter later */ > wf.duty_length_ns = wf.period_length_ns / 2; > - > + wf.duty_offset_ns = periodic->offset_ns; I would be tempted to put the loop check here: offload_offset_ns = periodic->offset_ns; do { wf.offset_ns = offload_offset_ns; ret = pwm_round_waveform_might_sleep(st->pwm, &wf); if (ret) return ret; offload_offset_ns += 10; } while (wf.offset_ns < periodic->offset_ns); wf.duty_offset_ns = periodic->offset_ns; instead of in the ADC driver so that all future callers don't have to repeat this. Also cc: Uwe in case he has any better suggestions on how to avoid repeating such verbose validations by all uses of the PWM waveform APIs. > ret = pwm_round_waveform_might_sleep(st->pwm, &wf); > if (ret < 0) > return ret; > > periodic->frequency_hz = DIV_ROUND_UP_ULL(NSEC_PER_SEC, wf.period_length_ns); > - > + periodic->offset_ns = wf.duty_offset_ns; > return 0; > } > > @@ -77,6 +77,7 @@ static int spi_offload_trigger_pwm_enable(struct spi_offload_trigger *trigger, > wf.period_length_ns = DIV_ROUND_UP_ULL(NSEC_PER_SEC, periodic->frequency_hz); > /* REVISIT: 50% duty-cycle for now - may add config parameter later */ > wf.duty_length_ns = wf.period_length_ns / 2; > + wf.duty_offset_ns = periodic->offset_ns; > > return pwm_set_waveform_might_sleep(st->pwm, &wf, false); > }