[U-Boot-Users] [PATCH] Round the serial port clock divisor valuereturned by calc_divisor()

Jerry Van Baren
2008-07-11T15:13:21Z

Hugo Villeneuve wrote:
> u-boot-users-bounces at lists.sourceforge.net wrote:
>> This formula is better at avoiding integer overflow.
>
> This patch doesn?t round the value correctly.
>
> Wolfgang, I will resubmit a new patch shortly today to fix the problem.
>
> Hugo V.

Arrgh, you are right. I know you solved it already, but for the record
I oversimplified:
(gd->baudrate / 2)
should have been:
(gd->baudrate * (MODE_X_DIV / 2))

WRONG:
+ return (CFG_NS16550_CLK + (gd->baudrate / 2)) /
+ (MODE_X_DIV * gd->baudrate);

should have been
+ return (CFG_NS16550_CLK + (gd->baudrate * (MODE_X_DIV / 2))) /
+ (MODE_X_DIV * gd->baudrate);

Sorry,
gvb