xhci: dbc: Add a operations structure to access driver functions
Don't call dbctty driver functions directly from dbc core code.
Introduce a new dbc_driver structure that contains function pointers
for disconnect and configure operations.
The driver (ttydbc) must provide these opeations when creating a dbc.
Name the structure dbc_driver instead of dbc_ops as we plan to
add more driver configureable values here, such as vid and pid.
Decouples dbc and dbctty.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200723144530.9992-26-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index 9acf1ef..3231cec7 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -455,6 +455,11 @@ void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc)
xhci_dbc_free_requests(&port->write_pool);
}
+static const struct dbc_driver dbc_driver = {
+ .configure = xhci_dbc_tty_register_device,
+ .disconnect = xhci_dbc_tty_unregister_device,
+};
+
int xhci_dbc_tty_probe(struct xhci_hcd *xhci)
{
struct xhci_dbc *dbc = xhci->dbc;
@@ -465,6 +470,8 @@ int xhci_dbc_tty_probe(struct xhci_hcd *xhci)
if (status)
return status;
+ dbc->driver = &dbc_driver;
+
dbc_tty_driver->driver_state = &dbc->port;
return 0;
@@ -481,6 +488,8 @@ int xhci_dbc_tty_probe(struct xhci_hcd *xhci)
*/
void xhci_dbc_tty_remove(struct xhci_dbc *dbc)
{
+ dbc->driver = NULL;
+
/* dbc_tty_exit will be called by module_exit() in the future */
dbc_tty_exit();
}
@@ -523,5 +532,3 @@ static void dbc_tty_exit(void)
dbc_tty_driver = NULL;
}
}
-
-