summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/generic.c18
-rw-r--r--drivers/usb/serial/usb-serial.c27
2 files changed, 24 insertions, 21 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 8c7600472019..2d3599f014e2 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -48,14 +48,28 @@ static int usb_serial_generic_probe(struct usb_serial *serial,
return 0;
}
-struct usb_serial_driver usb_serial_generic_device = {
+static int usb_serial_generic_calc_num_ports(struct usb_serial *serial,
+ struct usb_serial_endpoints *epds)
+{
+ struct device *dev = &serial->interface->dev;
+ int num_ports = epds->num_bulk_out;
+
+ if (num_ports == 0) {
+ dev_err(dev, "Generic device with no bulk out, not allowed.\n");
+ return -ENODEV;
+ }
+
+ return num_ports;
+}
+
+static struct usb_serial_driver usb_serial_generic_device = {
.driver = {
.owner = THIS_MODULE,
.name = "generic",
},
.id_table = generic_device_ids,
- .num_ports = 1,
.probe = usb_serial_generic_probe,
+ .calc_num_ports = usb_serial_generic_calc_num_ports,
.throttle = usb_serial_generic_throttle,
.unthrottle = usb_serial_generic_unthrottle,
.resume = usb_serial_generic_resume,
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index f8ae09e2cff5..101eb105d78e 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -850,28 +850,17 @@ static int usb_serial_probe(struct usb_interface *interface,
retval = -ENODEV;
goto err_free_epds;
}
-#ifdef CONFIG_USB_SERIAL_GENERIC
- if (type == &usb_serial_generic_device) {
- num_ports = epds->num_bulk_out;
- if (num_ports == 0) {
- dev_err(ddev, "Generic device with no bulk out, not allowed.\n");
- retval = -EIO;
+
+ if (type->calc_num_ports) {
+ retval = type->calc_num_ports(serial, epds);
+ if (retval < 0)
goto err_free_epds;
- }
- }
-#endif
- if (!num_ports) {
- /* if this device type has a calc_num_ports function, call it */
- 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;
+ num_ports = retval;
}
+ if (!num_ports)
+ num_ports = type->num_ports;
+
if (num_ports > MAX_NUM_PORTS) {
dev_warn(ddev, "too many ports requested: %d\n", num_ports);
num_ports = MAX_NUM_PORTS;