summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb-serial.c
diff options
context:
space:
mode:
authorJohan Hovold2017-03-16 17:13:30 +0100
committerJohan Hovold2017-03-28 10:54:39 +0200
commit07814246dd5530860ef758fd9b2b5f2e26472aa2 (patch)
treee27c9ae087d22c49b063e365df2c7f2ba479c253 /drivers/usb/serial/usb-serial.c
parentUSB: serial: whiteheat: simplify endpoint check (diff)
downloadkernel-qcow2-linux-07814246dd5530860ef758fd9b2b5f2e26472aa2.tar.gz
kernel-qcow2-linux-07814246dd5530860ef758fd9b2b5f2e26472aa2.tar.xz
kernel-qcow2-linux-07814246dd5530860ef758fd9b2b5f2e26472aa2.zip
USB: serial: allow subdrivers to modify port-endpoint mapping
Allow subdrivers to modify the port-endpoint mapping by passing the endpoint descriptors to calc_num_ports. The callback can now also be used to verify that the required endpoints exists and abort probing otherwise. This will allow us to get rid of a few hacks in subdrivers that are already modifying the port-endpoint mapping (or aborting probe due to missing endpoints), but only after the port structures have been setup. Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r--drivers/usb/serial/usb-serial.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 747dd414bef9..f0761f491c5f 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -710,17 +710,6 @@ static const struct tty_port_operations serial_port_ops = {
.shutdown = serial_port_shutdown,
};
-struct usb_serial_endpoints {
- unsigned char num_bulk_in;
- unsigned char num_bulk_out;
- unsigned char num_interrupt_in;
- unsigned char num_interrupt_out;
- struct usb_endpoint_descriptor *bulk_in[MAX_NUM_PORTS];
- struct usb_endpoint_descriptor *bulk_out[MAX_NUM_PORTS];
- struct usb_endpoint_descriptor *interrupt_in[MAX_NUM_PORTS];
- struct usb_endpoint_descriptor *interrupt_out[MAX_NUM_PORTS];
-};
-
static void find_endpoints(struct usb_serial *serial,
struct usb_serial_endpoints *epds)
{
@@ -875,8 +864,12 @@ static int usb_serial_probe(struct usb_interface *interface,
#endif
if (!num_ports) {
/* if this device type has a calc_num_ports function, call it */
- if (type->calc_num_ports)
- num_ports = type->calc_num_ports(serial);
+ if (type->calc_num_ports) {
+ retval = type->calc_num_ports(serial, epds);
+ if (retval < 0)
+ goto err_free_epds;
+ num_ports = retval;
+ }
if (!num_ports)
num_ports = type->num_ports;
}