diff options
author | Oliver Neukum <oneukum@suse.com> | 2017-03-14 07:09:56 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-30 03:41:23 -0400 |
commit | ff8d97a822c65e8ae6ceaa67369c0d56f6797c9b (patch) | |
tree | 4e29c2cd1d982a967a8a636699be14d583155de1 | |
parent | 381420a46ae521c34801314985c1ca7ee274b45e (diff) |
ACM gadget: fix endianness in notifications
commit cdd7928df0d2efaa3270d711963773a08a4cc8ab upstream.
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 <oneukum@suse.com>
Tested-by: 家瑋 <momo1208@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/gadget/function/f_acm.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c index a30766ca4226..5e3828d9dac7 100644 --- a/drivers/usb/gadget/function/f_acm.c +++ b/drivers/usb/gadget/function/f_acm.c | |||
@@ -535,13 +535,15 @@ static int acm_notify_serial_state(struct f_acm *acm) | |||
535 | { | 535 | { |
536 | struct usb_composite_dev *cdev = acm->port.func.config->cdev; | 536 | struct usb_composite_dev *cdev = acm->port.func.config->cdev; |
537 | int status; | 537 | int status; |
538 | __le16 serial_state; | ||
538 | 539 | ||
539 | spin_lock(&acm->lock); | 540 | spin_lock(&acm->lock); |
540 | if (acm->notify_req) { | 541 | if (acm->notify_req) { |
541 | dev_dbg(&cdev->gadget->dev, "acm ttyGS%d serial state %04x\n", | 542 | dev_dbg(&cdev->gadget->dev, "acm ttyGS%d serial state %04x\n", |
542 | acm->port_num, acm->serial_state); | 543 | acm->port_num, acm->serial_state); |
544 | serial_state = cpu_to_le16(acm->serial_state); | ||
543 | status = acm_cdc_notify(acm, USB_CDC_NOTIFY_SERIAL_STATE, | 545 | 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)); |
545 | } else { | 547 | } else { |
546 | acm->pending = true; | 548 | acm->pending = true; |
547 | status = 0; | 549 | status = 0; |