Drivers are allowed to override the default bulk-out buffer size
(endpoint maximum packet size) in order to increase throughput, but it
does not make much sense to allow buffers smaller than the default.

Note that this is already how bulk_in_size is defined.

Signed-off-by: Johan Hovold <jhov...@gmail.com>
---
 drivers/usb/serial/usb-serial.c | 5 ++---
 include/linux/usb/serial.h      | 3 ++-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 7c9dc28640bb..c68fc9fb7598 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -923,9 +923,8 @@ static int usb_serial_probe(struct usb_interface *interface,
                port = serial->port[i];
                if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL))
                        goto probe_error;
-               buffer_size = serial->type->bulk_out_size;
-               if (!buffer_size)
-                       buffer_size = usb_endpoint_maxp(endpoint);
+               buffer_size = max_t(int, serial->type->bulk_out_size,
+                                               usb_endpoint_maxp(endpoint));
                port->bulk_out_size = buffer_size;
                port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
 
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 704a1ab8240c..9bb547c7bce7 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -190,7 +190,8 @@ static inline void usb_set_serial_data(struct usb_serial 
*serial, void *data)
  * @num_ports: the number of different ports this device will have.
  * @bulk_in_size: minimum number of bytes to allocate for bulk-in buffer
  *     (0 = end-point size)
- * @bulk_out_size: bytes to allocate for bulk-out buffer (0 = end-point size)
+ * @bulk_out_size: minimum number of bytes to allocate for bulk-out buffer
+ *     (0 = end-point size)
  * @calc_num_ports: pointer to a function to determine how many ports this
  *     device has dynamically.  It will be called after the probe()
  *     callback is called, but before attach()
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to