diff options
author | Johan Hovold <johan@kernel.org> | 2017-03-16 17:13:32 +0100 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2017-03-28 10:54:39 +0200 |
commit | a794499b261b8487a984783ccc864975e1bcc7bf (patch) | |
tree | 57dfa404104d6fd86e756c1c10dd5d1ff3e9143b /drivers/usb/serial/generic.c | |
parent | USB: serial: add probe callback to generic driver (diff) | |
download | linux-a794499b261b8487a984783ccc864975e1bcc7bf.tar.xz linux-a794499b261b8487a984783ccc864975e1bcc7bf.zip |
USB: serial: add calc_num_ports callback to generic driver
Add a calc_num_ports callback to the generic driver and verify that the
device has the required endpoints there instead of in core.
Note that the generic driver num_ports field was never used.
Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/generic.c')
-rw-r--r-- | drivers/usb/serial/generic.c | 18 |
1 files changed, 16 insertions, 2 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, |