[PATCH 1/3] usb-serial: device_register before calling attach
Jim Radford <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
Allow usb-serial driver's attach callback to create sysfs attributes, by calling device_register, before calling ->attach(). Signed-Off: Jim Radford <[email protected]> diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -959,6 +959,22 @@ int usb_serial_probe(struct usb_interface *interface, dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined"); } + /* register all of the individual ports with the driver core */ + for (i = 0; i < num_ports; ++i) { + port = serial->port[i]; + port->dev.parent = &interface->dev; + port->dev.driver = NULL; + port->dev.bus = &usb_serial_bus_type; + port->dev.release = &port_release; + + snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); + dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id); + retval = device_register(&port->dev); + if (retval) + dev_err(&port->dev, "Error registering port device, " + "continuing\n"); + } + /* if this device type has an attach function, call it */ if (type->attach) { if (!try_module_get(type->driver.owner)) { @@ -981,22 +997,6 @@ int usb_serial_probe(struct usb_interface *interface, goto probe_error; } - /* register all of the individual ports with the driver core */ - for (i = 0; i < num_ports; ++i) { - port = serial->port[i]; - port->dev.parent = &interface->dev; - port->dev.driver = NULL; - port->dev.bus = &usb_serial_bus_type; - port->dev.release = &port_release; - - snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); - dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id); - retval = device_register(&port->dev); - if (retval) - dev_err(&port->dev, "Error registering port device, " - "continuing\n"); - } - usb_serial_console_init (debug, minor); exit: ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel