summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorPhilipp Hachtmann <hachti@hachti.de>2015-08-17 17:31:47 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-18 10:06:22 -0700
commit8ae25a355b5969e12f3185e8cb8eb08b871c9084 (patch)
treea49c7e83dad60d779f03a6066ec3a8068bfb2c0d /drivers/usb
parent951d3793bbfc0a441d791d820183aa3085c83ea9 (diff)
downloadop-kernel-dev-8ae25a355b5969e12f3185e8cb8eb08b871c9084.zip
op-kernel-dev-8ae25a355b5969e12f3185e8cb8eb08b871c9084.tar.gz
USB: symbolserial: Correct transferred data size
The scanner (here DS3508) always returns 64 bytes per urb buffer. The first byte indicates the data length used in the current buffer. There even was a comment describing this. But the comment also said that we'll send everything in the buffer to the tty layer. That means sending the actual barcode data and lots of trailing zeroes. This patch lets the driver only send the real data. Signed-off-by: Philipp Hachtmann <hachti@hachti.de> Acked-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/symbolserial.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index 6ed8044..37f3ad1 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -60,17 +60,15 @@ static void symbol_int_callback(struct urb *urb)
usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
+ /*
+ * Data from the device comes with a 1 byte header:
+ *
+ * <size of data> <data>...
+ */
if (urb->actual_length > 1) {
- data_length = urb->actual_length - 1;
-
- /*
- * Data from the device comes with a 1 byte header:
- *
- * <size of data>data...
- * This is real data to be sent to the tty layer
- * we pretty much just ignore the size and send everything
- * else to the tty layer.
- */
+ data_length = data[0];
+ if (data_length > (urb->actual_length - 1))
+ data_length = urb->actual_length - 1;
tty_insert_flip_string(&port->port, &data[1], data_length);
tty_flip_buffer_push(&port->port);
} else {
OpenPOWER on IntegriCloud