On Thu, 2021-11-04 at 09:59 +0100, Sander Vanheule wrote: > + do { > + if (prescale > OTTO_WDT_PRESCALE_MAX) > + return -EINVAL; > + > + tick_ms = otto_wdt_tick_ms(ctrl, prescale); > + total_ticks = div_round_ticks(timeout_ms, tick_ms, 2); > + phase1_ticks = div_round_ticks(timeout_ms - pretimeout_ms, tick_ms, > 1); > + phase2_ticks = total_ticks - phase1_ticks; > + > + prescale++; > + } while (phase1_ticks > OTTO_WDT_PHASE_TICKS_MAX > + || phase2_ticks > OTTO_WDT_PHASE_TICKS_MAX); > + > + v = ioread32(ctrl->base + OTTO_WDT_REG_CTRL); > + > + v &= ~(OTTO_WDT_CTRL_PRESCALE | OTTO_WDT_CTRL_PHASE1 | > OTTO_WDT_CTRL_PHASE2); > + v |= FIELD_PREP(OTTO_WDT_CTRL_PHASE1, phase1_ticks - 1); > + v |= FIELD_PREP(OTTO_WDT_CTRL_PHASE2, phase2_ticks - 1); > + v |= FIELD_PREP(OTTO_WDT_CTRL_PRESCALE, prescale); I dropped the prescale_next variable here, but now the wrong prescale value is used after the loop. I'll send out a v3 shortly. Best, Sander