On Fri, Aug 11, 2017 at 11:47:35PM +0200, Samuel Thibault wrote:
> Okash Khawaja, on ven. 11 ao??t 2017 22:38:14 +0100, wrote:
> > On Thu, Aug 10, 2017 at 10:27:31AM +0200, Samuel Thibault wrote:
> > > Oliver Neukum, on jeu. 10 ao??t 2017 10:03:51 +0200, wrote:
> > > > You cannot make assumptions about driver load. Your driver was loaded.
> > > > End of story. Register it with the proper subsystem.
> > >
> > > The subsystem in question is a line discipline. Registering a line
> > > discipline will not trigger applying it to the serial port, so it's not
> > > enough.
> > >
> > > Samuel
> >
> > Okay, it looks like port_probe callback inside usb_serial_driver does
> > this. It gets passed in usb_serial_port which is enough.
>
> Mmm, but that is called before tty_register_device, is that not a
> problem?
Ah yes. Okay so that won't work.
May be what is needed is something similar to following. It is untested
and intended only to illustrate what is required.
Thanks,
Okash
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -69,6 +69,9 @@ static int usb_serial_device_probe(struc
goto err_port_remove;
}
+ if (driver->tty_registered)
+ driver->tty_registered(port);
+
usb_autopm_put_interface(port->serial->interface);
dev_info(&port->serial->dev->dev,
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -225,6 +225,9 @@ struct usb_serial_endpoints {
* called when the device is unplugged or unbound from the driver.
* @release: pointer to the driver's release function. This will be called
* when the usb_serial data structure is about to be destroyed.
+ * @tty_registered: pointer to the driver's tty_registered callback.
+ * This will be called when the usb serial port has been successfully
+ * registered as a tty device.
* @usb_driver: pointer to the struct usb_driver that controls this
* device. This is necessary to allow dynamic ids to be added to
* the driver from sysfs.
@@ -268,6 +271,7 @@ struct usb_serial_driver {
void (*release)(struct usb_serial *serial);
int (*port_probe)(struct usb_serial_port *port);
+ void (*tty_registered)(struct usb_serial_port *port);
int (*port_remove)(struct usb_serial_port *port);
int (*suspend)(struct usb_serial *serial, pm_message_t message);
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html