mxser: fix timeout calculation for low rates
authorJiri Slaby <jslaby@suse.cz>
Tue, 12 Sep 2017 10:39:54 +0000 (12:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Sep 2017 16:19:20 +0000 (18:19 +0200)
commit104583b504da8a3ad86d033b497cb6e58941a9a1
treebd26ede2093fe93714d6d49aff4e28f3ac0aa591
parent432219fd002ada95d2f45dd3a25c3f7c73f27864
mxser: fix timeout calculation for low rates

Paul reported, that low rates like B300 make the driver to hang in
mxser_wait_until_sent. His debugging tackled the issue down to the
info->timeout computation in mxser_set_baud. Obviously, ints are used
there and they easily overflow with these low rates: B300 makes
info->timeout to be -373.

So switch all these types to unsigned as it ought to be. And use the u64
domain to perform the computation as in the worst case, we need 35 bits
to store the computed value (before division).

And use do_div not to break 32 bit kernels.

[v2] make it actually build

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Paul <Paul@abelian.netcom.co.uk>
Tested-by: <Paul@abelian.netcom.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/mxser.c