drivers/serial: Move conditional compilation to Makefile for CONFIG_* macros
[oweals/u-boot.git] / drivers / serial / serial.c
index 182ca2d149ead9aba81003418e0e6c418dec2890..8bbfcf9c0cba8a7115d1c3b5b680791d1e2e36f6 100644 (file)
@@ -147,10 +147,11 @@ static int calc_divisor (NS16550_t port)
 
        /* Compute divisor value. Normally, we should simply return:
         *   CFG_NS16550_CLK) / MODE_X_DIV / gd->baudrate
-        * but we need to round that value by adding 0.5 or 8/16.
+        * but we need to round that value by adding 0.5.
         * Rounding is especially important at high baud rates.
         */
-       return (((16 * CFG_NS16550_CLK) / MODE_X_DIV / gd->baudrate) + 8) / 16;
+       return (CFG_NS16550_CLK + (gd->baudrate * (MODE_X_DIV / 2))) /
+               (MODE_X_DIV * gd->baudrate);
 }
 
 #if !defined(CONFIG_SERIAL_MULTI)