• Trent Piepho's avatar
    gianfar: Fix error in mdio reset timeout · baac03d9
    Trent Piepho authored
    The loop with the timeout used "while (...  && timeout--)", which means
    than when the timeout occurs, "timeout" will be -1 after the loop has
    exited.  The code that checks if the looped exited because of a timeout
    used "if (timeout <= 0)".  Seems ok, except timeout is unsigned, and
    (unsigned)-1 isn't less than zero!
    
    Using "--timeout" in the loop fixes this problem, as now "timeout" will be
    0 when the loop times out.
    
    This also fixes a bug in the existing code, where it will erroneously think
    a timeout occurred if the condition the loop was waiting for is satisfied
    on the final iteration before a timeout.
    Signed-off-by: default avatarTrent Piepho <tpiepho@freescale.com>
    Acked-by: default avatarAndy Fleming <afleming@freescale.com>
    Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    baac03d9
gianfar_mii.c 7 KB