• Will Deacon's avatar
    openrisc: delay: fix handling of counter overflow · 807607f7
    Will Deacon authored
    If the counter overflows during a __delay operation, we will exit the
    loop prematurely. For example, calling __delay(0x100) with the counter
    at 0xffffff00 gives us a target of 0x0. The unsigned comparison in the
    while loop will likely be false on the first iteration (if the counter
    is now anything other than 0) and we will return early.
    
    This patch fixes the problem by comparing deltas in the loop rather than
    absolute values.
    
    Cc: Jon Masters <jcm@redhat.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    Signed-off-by: default avatarJonas Bonn <jonas@southpole.se>
    807607f7
delay.c 1.37 KB