[EMAIL PROTECTED] wrote: > This formula is better at avoiding integer overflow. > > Signed-off-by: Gerald Van Baren <[EMAIL PROTECTED]> > --- > > This is my latest entry in the baud rate rounding dual. Since it > doesn't multiply the master BRG clock but instead adds the baud rate > scaled by 1/2 the clock multiplier, it should not overflow (for a > master clock right at the edge of overflowing itself, it still will > overflow, but that is pretty unlikely). > > This compiles OK on the mpc7448hpc2. I have only tested it on a > calculator. I have NOT tested it on real hardware.
I have tested it on my board and it works. I also tested it on my board by using the clock value of the mpc7448hpc2 board, and printing the computed value which was correct. > drivers/serial/serial.c | 16 +++++----------- > 1 files changed, 5 insertions(+), 11 deletions(-) > ... > - /* 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 (2/4). > - * Rounding is especially important at high baud rates. > + /* > + * Compute divisor value, rounding it properly. Rounding is > + * especially important at high baud rates. > */ Please keep the comments explaining the base formula: it is not easy to reverse-engineer an optimized formula to figure out what is the base formula. I will resubmit a patch with your fix and my comments. Hugo V. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users