USB-serial fixes for 6.1-rc8

Here are two fixes for a division-by-zero issue in the Fintek drivers.
 
 All have been in linux-next with no reported issues.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQQHbPq+cpGvN/peuzMLxc3C7H1lCAUCY4o6DgAKCRALxc3C7H1l
 CCyHAP9lHJ4myiSTwFlVMrSHMOGI0xGi59uUfyfx6koQWwJDawEA6C4gMYw770LA
 IGiUEKcXfiDLt21bIQ8Aq9KsHxJ3wAQ=
 =XU8Z
 -----END PGP SIGNATURE-----

Merge tag 'usb-serial-6.1-rc8' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next

Johan writes:

USB-serial fixes for 6.1-rc8

Here are two fixes for a division-by-zero issue in the Fintek drivers.

All have been in linux-next with no reported issues.

* tag 'usb-serial-6.1-rc8' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial:
  USB: serial: f81534: fix division by zero on line-speed change
  USB: serial: f81232: fix division by zero on line-speed change
This commit is contained in:
Greg Kroah-Hartman 2022-12-02 19:30:15 +01:00
commit 1524ceb14d
2 changed files with 14 additions and 10 deletions

View File

@ -130,9 +130,6 @@ static u8 const clock_table[] = { F81232_CLK_1_846_MHZ, F81232_CLK_14_77_MHZ,
static int calc_baud_divisor(speed_t baudrate, speed_t clockrate)
{
if (!baudrate)
return 0;
return DIV_ROUND_CLOSEST(clockrate, baudrate);
}
@ -498,9 +495,14 @@ static void f81232_set_baudrate(struct tty_struct *tty,
speed_t baud_list[] = { baudrate, old_baudrate, F81232_DEF_BAUDRATE };
for (i = 0; i < ARRAY_SIZE(baud_list); ++i) {
idx = f81232_find_clk(baud_list[i]);
baudrate = baud_list[i];
if (baudrate == 0) {
tty_encode_baud_rate(tty, 0, 0);
return;
}
idx = f81232_find_clk(baudrate);
if (idx >= 0) {
baudrate = baud_list[i];
tty_encode_baud_rate(tty, baudrate, baudrate);
break;
}

View File

@ -536,9 +536,6 @@ static int f81534_submit_writer(struct usb_serial_port *port, gfp_t mem_flags)
static u32 f81534_calc_baud_divisor(u32 baudrate, u32 clockrate)
{
if (!baudrate)
return 0;
/* Round to nearest divisor */
return DIV_ROUND_CLOSEST(clockrate, baudrate);
}
@ -568,9 +565,14 @@ static int f81534_set_port_config(struct usb_serial_port *port,
u32 baud_list[] = {baudrate, old_baudrate, F81534_DEFAULT_BAUD_RATE};
for (i = 0; i < ARRAY_SIZE(baud_list); ++i) {
idx = f81534_find_clk(baud_list[i]);
baudrate = baud_list[i];
if (baudrate == 0) {
tty_encode_baud_rate(tty, 0, 0);
return 0;
}
idx = f81534_find_clk(baudrate);
if (idx >= 0) {
baudrate = baud_list[i];
tty_encode_baud_rate(tty, baudrate, baudrate);
break;
}