mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-11 14:10:34 +00:00
Avoid a divide-by-zero panic when setting the baudrate to 0.
MFC after: 2 weeks
This commit is contained in:
parent
be022505fe
commit
4cac8309a3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=269470
@ -1083,7 +1083,10 @@ umcs7840_calc_baudrate(uint32_t rate, uint16_t *divisor, uint8_t *clk)
|
||||
|
||||
for (i = 0; i < umcs7840_baudrate_divisors_len - 1 &&
|
||||
!(rate > umcs7840_baudrate_divisors[i] && rate <= umcs7840_baudrate_divisors[i + 1]); ++i);
|
||||
*divisor = umcs7840_baudrate_divisors[i + 1] / rate;
|
||||
if (rate == 0)
|
||||
*divisor = 1; /* XXX */
|
||||
else
|
||||
*divisor = umcs7840_baudrate_divisors[i + 1] / rate;
|
||||
/* 0x00 .. 0x70 */
|
||||
*clk = i << MCS7840_DEV_SPx_CLOCK_SHIFT;
|
||||
return (0);
|
||||
|
Loading…
Reference in New Issue
Block a user