Skip to content

Commit 8496829

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: whiteheat: fix line-speed endianness
Add missing endianness conversion when setting the line speed so that this driver might work also on big-endian machines. Also use an unsigned format specifier in the corresponding debug message. Signed-off-by: Johan Hovold <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1251dab commit 8496829

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

drivers/usb/serial/whiteheat.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ static void firm_setup_port(struct tty_struct *tty)
636636
struct device *dev = &port->dev;
637637
struct whiteheat_port_settings port_settings;
638638
unsigned int cflag = tty->termios.c_cflag;
639+
speed_t baud;
639640

640641
port_settings.port = port->port_number + 1;
641642

@@ -696,11 +697,13 @@ static void firm_setup_port(struct tty_struct *tty)
696697
dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff);
697698

698699
/* get the baud rate wanted */
699-
port_settings.baud = tty_get_baud_rate(tty);
700-
dev_dbg(dev, "%s - baud rate = %d\n", __func__, port_settings.baud);
700+
baud = tty_get_baud_rate(tty);
701+
port_settings.baud = cpu_to_le32(baud);
702+
dev_dbg(dev, "%s - baud rate = %u\n", __func__, baud);
701703

702704
/* fixme: should set validated settings */
703-
tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud);
705+
tty_encode_baud_rate(tty, baud, baud);
706+
704707
/* handle any settings that aren't specified in the tty structure */
705708
port_settings.lloop = 0;
706709

drivers/usb/serial/whiteheat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct whiteheat_simple {
8787

8888
struct whiteheat_port_settings {
8989
__u8 port; /* port number (1 to N) */
90-
__u32 baud; /* any value 7 - 460800, firmware calculates
90+
__le32 baud; /* any value 7 - 460800, firmware calculates
9191
best fit; arrives little endian */
9292
__u8 bits; /* 5, 6, 7, or 8 */
9393
__u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */

0 commit comments

Comments
 (0)