Skip to content

Commit cdd7928

Browse files
oneukumgregkh
authored andcommitted
ACM gadget: fix endianness in notifications
The gadget code exports the bitfield for serial status changes over the wire in its internal endianness. The fix is to convert to little endian before sending it over the wire. Signed-off-by: Oliver Neukum <[email protected]> Tested-by: 家瑋 <[email protected]> CC: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2e47c53 commit cdd7928

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/usb/gadget/function/f_acm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,15 @@ static int acm_notify_serial_state(struct f_acm *acm)
535535
{
536536
struct usb_composite_dev *cdev = acm->port.func.config->cdev;
537537
int status;
538+
__le16 serial_state;
538539

539540
spin_lock(&acm->lock);
540541
if (acm->notify_req) {
541542
dev_dbg(&cdev->gadget->dev, "acm ttyGS%d serial state %04x\n",
542543
acm->port_num, acm->serial_state);
544+
serial_state = cpu_to_le16(acm->serial_state);
543545
status = acm_cdc_notify(acm, USB_CDC_NOTIFY_SERIAL_STATE,
544-
0, &acm->serial_state, sizeof(acm->serial_state));
546+
0, &serial_state, sizeof(acm->serial_state));
545547
} else {
546548
acm->pending = true;
547549
status = 0;

0 commit comments

Comments
 (0)