Commit 5f391979 authored by Johan Hovold's avatar Johan Hovold

USB: serial: aircable: use calc_num_endpoints to verify endpoints

Use the calc_num_ports rather than probe callback to determine which
interface to bind to.

This allows us to remove some duplicate code.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 9d717271
...@@ -29,12 +29,6 @@ ...@@ -29,12 +29,6 @@
* is any other control code, I will simply check for the first * is any other control code, I will simply check for the first
* one. * one.
* *
* The driver registers himself with the USB-serial core and the USB Core. I had
* to implement a probe function against USB-serial, because other way, the
* driver was attaching himself to both interfaces. I have tried with different
* configurations of usb_serial_driver with out exit, only the probe function
* could handle this correctly.
*
* I have taken some info from a Greg Kroah-Hartman article: * I have taken some info from a Greg Kroah-Hartman article:
* http://www.linuxjournal.com/article/6573 * http://www.linuxjournal.com/article/6573
* And from Linux Device Driver Kit CD, which is a great work, the authors taken * And from Linux Device Driver Kit CD, which is a great work, the authors taken
...@@ -93,30 +87,17 @@ static int aircable_prepare_write_buffer(struct usb_serial_port *port, ...@@ -93,30 +87,17 @@ static int aircable_prepare_write_buffer(struct usb_serial_port *port,
return count + HCI_HEADER_LENGTH; return count + HCI_HEADER_LENGTH;
} }
static int aircable_probe(struct usb_serial *serial, static int aircable_calc_num_ports(struct usb_serial *serial,
const struct usb_device_id *id) struct usb_serial_endpoints *epds)
{ {
struct usb_host_interface *iface_desc = serial->interface-> /* Ignore the first interface, which has no bulk endpoints. */
cur_altsetting; if (epds->num_bulk_out == 0) {
struct usb_endpoint_descriptor *endpoint; dev_dbg(&serial->interface->dev,
int num_bulk_out = 0; "ignoring interface with no bulk-out endpoints\n");
int i;
for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
endpoint = &iface_desc->endpoint[i].desc;
if (usb_endpoint_is_bulk_out(endpoint)) {
dev_dbg(&serial->dev->dev,
"found bulk out on endpoint %d\n", i);
++num_bulk_out;
}
}
if (num_bulk_out == 0) {
dev_dbg(&serial->dev->dev, "Invalid interface, discarding\n");
return -ENODEV; return -ENODEV;
} }
return 0; return 1;
} }
static int aircable_process_packet(struct usb_serial_port *port, static int aircable_process_packet(struct usb_serial_port *port,
...@@ -164,9 +145,8 @@ static struct usb_serial_driver aircable_device = { ...@@ -164,9 +145,8 @@ static struct usb_serial_driver aircable_device = {
.name = "aircable", .name = "aircable",
}, },
.id_table = id_table, .id_table = id_table,
.num_ports = 1,
.bulk_out_size = HCI_COMPLETE_FRAME, .bulk_out_size = HCI_COMPLETE_FRAME,
.probe = aircable_probe, .calc_num_ports = aircable_calc_num_ports,
.process_read_urb = aircable_process_read_urb, .process_read_urb = aircable_process_read_urb,
.prepare_write_buffer = aircable_prepare_write_buffer, .prepare_write_buffer = aircable_prepare_write_buffer,
.throttle = usb_serial_generic_throttle, .throttle = usb_serial_generic_throttle,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment