Commit 5ce036b9 authored by Mathias Nyman's avatar Mathias Nyman Committed by Greg Kroah-Hartman

xhci: dbc: create and remove dbc structure in dbgtty driver.

Turn the dbgtty closer to a device driver by allocating the dbc
structure in its own xhci_dbc_tty_probe() function, and freeing it
in xhci_dbc_tty_remove()

Remove xhci_do_dbc_exit() as its no longer needed.

allocate and create the dbc strcuture in xhci_dbc_tty_probe()
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20220216095153.1303105-3-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 53467594
...@@ -914,16 +914,6 @@ static void xhci_dbc_handle_events(struct work_struct *work) ...@@ -914,16 +914,6 @@ static void xhci_dbc_handle_events(struct work_struct *work)
mod_delayed_work(system_wq, &dbc->event_work, 1); mod_delayed_work(system_wq, &dbc->event_work, 1);
} }
static void xhci_do_dbc_exit(struct xhci_hcd *xhci)
{
unsigned long flags;
spin_lock_irqsave(&xhci->lock, flags);
kfree(xhci->dbc);
xhci->dbc = NULL;
spin_unlock_irqrestore(&xhci->lock, flags);
}
static ssize_t dbc_show(struct device *dev, static ssize_t dbc_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -984,7 +974,7 @@ static ssize_t dbc_store(struct device *dev, ...@@ -984,7 +974,7 @@ static ssize_t dbc_store(struct device *dev,
static DEVICE_ATTR_RW(dbc); static DEVICE_ATTR_RW(dbc);
struct xhci_dbc * struct xhci_dbc *
xhci_alloc_dbc(struct device *dev, void __iomem *base) xhci_alloc_dbc(struct device *dev, void __iomem *base, const struct dbc_driver *driver)
{ {
struct xhci_dbc *dbc; struct xhci_dbc *dbc;
int ret; int ret;
...@@ -995,6 +985,7 @@ xhci_alloc_dbc(struct device *dev, void __iomem *base) ...@@ -995,6 +985,7 @@ xhci_alloc_dbc(struct device *dev, void __iomem *base)
dbc->regs = base; dbc->regs = base;
dbc->dev = dev; dbc->dev = dev;
dbc->driver = driver;
if (readl(&dbc->regs->control) & DBC_CTRL_DBC_ENABLE) if (readl(&dbc->regs->control) & DBC_CTRL_DBC_ENABLE)
return NULL; return NULL;
...@@ -1045,18 +1036,8 @@ int xhci_dbc_init(struct xhci_hcd *xhci) ...@@ -1045,18 +1036,8 @@ int xhci_dbc_init(struct xhci_hcd *xhci)
if (xhci->dbc) if (xhci->dbc)
return -EBUSY; return -EBUSY;
xhci->dbc = xhci_alloc_dbc(dev, base); ret = xhci_dbc_tty_probe(dev, base + dbc_cap_offs, xhci);
if (!xhci->dbc)
return -ENOMEM;
ret = xhci_dbc_tty_probe(xhci);
if (ret)
goto init_err2;
return 0;
init_err2:
xhci_do_dbc_exit(xhci);
return ret; return ret;
} }
...@@ -1068,7 +1049,6 @@ void xhci_dbc_exit(struct xhci_hcd *xhci) ...@@ -1068,7 +1049,6 @@ void xhci_dbc_exit(struct xhci_hcd *xhci)
return; return;
xhci_dbc_tty_remove(xhci->dbc); xhci_dbc_tty_remove(xhci->dbc);
xhci_dbc_remove(xhci->dbc);
spin_lock_irqsave(&xhci->lock, flags); spin_lock_irqsave(&xhci->lock, flags);
xhci->dbc = NULL; xhci->dbc = NULL;
spin_unlock_irqrestore(&xhci->lock, flags); spin_unlock_irqrestore(&xhci->lock, flags);
......
...@@ -196,8 +196,11 @@ static inline struct dbc_ep *get_out_ep(struct xhci_dbc *dbc) ...@@ -196,8 +196,11 @@ static inline struct dbc_ep *get_out_ep(struct xhci_dbc *dbc)
#ifdef CONFIG_USB_XHCI_DBGCAP #ifdef CONFIG_USB_XHCI_DBGCAP
int xhci_dbc_init(struct xhci_hcd *xhci); int xhci_dbc_init(struct xhci_hcd *xhci);
void xhci_dbc_exit(struct xhci_hcd *xhci); void xhci_dbc_exit(struct xhci_hcd *xhci);
int xhci_dbc_tty_probe(struct xhci_hcd *xhci); int xhci_dbc_tty_probe(struct device *dev, void __iomem *res, struct xhci_hcd *xhci);
void xhci_dbc_tty_remove(struct xhci_dbc *dbc); void xhci_dbc_tty_remove(struct xhci_dbc *dbc);
struct xhci_dbc *xhci_alloc_dbc(struct device *dev, void __iomem *res,
const struct dbc_driver *driver);
void xhci_dbc_remove(struct xhci_dbc *dbc);
struct dbc_request *dbc_alloc_request(struct xhci_dbc *dbc, struct dbc_request *dbc_alloc_request(struct xhci_dbc *dbc,
unsigned int direction, unsigned int direction,
gfp_t flags); gfp_t flags);
......
...@@ -468,9 +468,9 @@ static const struct dbc_driver dbc_driver = { ...@@ -468,9 +468,9 @@ static const struct dbc_driver dbc_driver = {
.disconnect = xhci_dbc_tty_unregister_device, .disconnect = xhci_dbc_tty_unregister_device,
}; };
int xhci_dbc_tty_probe(struct xhci_hcd *xhci) int xhci_dbc_tty_probe(struct device *dev, void __iomem *base, struct xhci_hcd *xhci)
{ {
struct xhci_dbc *dbc = xhci->dbc; struct xhci_dbc *dbc;
struct dbc_port *port; struct dbc_port *port;
int status; int status;
...@@ -485,13 +485,22 @@ int xhci_dbc_tty_probe(struct xhci_hcd *xhci) ...@@ -485,13 +485,22 @@ int xhci_dbc_tty_probe(struct xhci_hcd *xhci)
goto out; goto out;
} }
dbc->driver = &dbc_driver; dbc_tty_driver->driver_state = port;
dbc->priv = port;
dbc = xhci_alloc_dbc(dev, base, &dbc_driver);
if (!dbc) {
status = -ENOMEM;
goto out2;
}
dbc->priv = port;
dbc_tty_driver->driver_state = port; /* get rid of xhci once this is a real driver binding to a device */
xhci->dbc = dbc;
return 0; return 0;
out2:
kfree(port);
out: out:
/* dbc_tty_exit will be called by module_exit() in the future */ /* dbc_tty_exit will be called by module_exit() in the future */
dbc_tty_exit(); dbc_tty_exit();
...@@ -506,8 +515,7 @@ void xhci_dbc_tty_remove(struct xhci_dbc *dbc) ...@@ -506,8 +515,7 @@ void xhci_dbc_tty_remove(struct xhci_dbc *dbc)
{ {
struct dbc_port *port = dbc_to_port(dbc); struct dbc_port *port = dbc_to_port(dbc);
dbc->driver = NULL; xhci_dbc_remove(dbc);
dbc->priv = NULL;
kfree(port); kfree(port);
/* dbc_tty_exit will be called by module_exit() in the future */ /* dbc_tty_exit will be called by module_exit() in the future */
......
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