The prescaler computation should round at the nearest integer
value, not to the next integer value.
Change-Id: I957e0774421211f3c4ba4b312738b1c67b87c4a2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 051e80812b1b ("drivers/jlink: fix calculate_swo_prescaler formula")
Reviewed-on: http://openocd.zylin.com/5846
Tested-by: jenkins
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
static bool calculate_swo_prescaler(unsigned int traceclkin_freq,
uint32_t trace_freq, uint16_t *prescaler)
{
- unsigned int presc;
- presc = DIV_ROUND_UP(traceclkin_freq, trace_freq);
+ unsigned int presc = (traceclkin_freq + trace_freq / 2) / trace_freq;
if (presc > TPIU_ACPR_MAX_SWOSCALER)
return false;