forked from Minki/linux
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: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20220216095153.1303105-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
534675942e
commit
5ce036b98d
@ -914,16 +914,6 @@ static void xhci_dbc_handle_events(struct work_struct *work)
|
||||
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,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
@ -984,7 +974,7 @@ static ssize_t dbc_store(struct device *dev,
|
||||
static DEVICE_ATTR_RW(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;
|
||||
int ret;
|
||||
@ -995,6 +985,7 @@ xhci_alloc_dbc(struct device *dev, void __iomem *base)
|
||||
|
||||
dbc->regs = base;
|
||||
dbc->dev = dev;
|
||||
dbc->driver = driver;
|
||||
|
||||
if (readl(&dbc->regs->control) & DBC_CTRL_DBC_ENABLE)
|
||||
return NULL;
|
||||
@ -1045,18 +1036,8 @@ int xhci_dbc_init(struct xhci_hcd *xhci)
|
||||
if (xhci->dbc)
|
||||
return -EBUSY;
|
||||
|
||||
xhci->dbc = xhci_alloc_dbc(dev, base);
|
||||
if (!xhci->dbc)
|
||||
return -ENOMEM;
|
||||
ret = xhci_dbc_tty_probe(dev, base + dbc_cap_offs, xhci);
|
||||
|
||||
ret = xhci_dbc_tty_probe(xhci);
|
||||
if (ret)
|
||||
goto init_err2;
|
||||
|
||||
return 0;
|
||||
|
||||
init_err2:
|
||||
xhci_do_dbc_exit(xhci);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1068,7 +1049,6 @@ void xhci_dbc_exit(struct xhci_hcd *xhci)
|
||||
return;
|
||||
|
||||
xhci_dbc_tty_remove(xhci->dbc);
|
||||
xhci_dbc_remove(xhci->dbc);
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
xhci->dbc = NULL;
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
||||
|
@ -196,8 +196,11 @@ static inline struct dbc_ep *get_out_ep(struct xhci_dbc *dbc)
|
||||
#ifdef CONFIG_USB_XHCI_DBGCAP
|
||||
int xhci_dbc_init(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);
|
||||
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,
|
||||
unsigned int direction,
|
||||
gfp_t flags);
|
||||
|
@ -468,9 +468,9 @@ static const struct dbc_driver dbc_driver = {
|
||||
.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;
|
||||
int status;
|
||||
|
||||
@ -485,13 +485,22 @@ int xhci_dbc_tty_probe(struct xhci_hcd *xhci)
|
||||
goto out;
|
||||
}
|
||||
|
||||
dbc->driver = &dbc_driver;
|
||||
dbc->priv = port;
|
||||
|
||||
|
||||
dbc_tty_driver->driver_state = port;
|
||||
|
||||
dbc = xhci_alloc_dbc(dev, base, &dbc_driver);
|
||||
if (!dbc) {
|
||||
status = -ENOMEM;
|
||||
goto out2;
|
||||
}
|
||||
|
||||
dbc->priv = port;
|
||||
|
||||
/* get rid of xhci once this is a real driver binding to a device */
|
||||
xhci->dbc = dbc;
|
||||
|
||||
return 0;
|
||||
out2:
|
||||
kfree(port);
|
||||
out:
|
||||
/* dbc_tty_exit will be called by module_exit() in the future */
|
||||
dbc_tty_exit();
|
||||
@ -506,8 +515,7 @@ void xhci_dbc_tty_remove(struct xhci_dbc *dbc)
|
||||
{
|
||||
struct dbc_port *port = dbc_to_port(dbc);
|
||||
|
||||
dbc->driver = NULL;
|
||||
dbc->priv = NULL;
|
||||
xhci_dbc_remove(dbc);
|
||||
kfree(port);
|
||||
|
||||
/* dbc_tty_exit will be called by module_exit() in the future */
|
||||
|
Loading…
Reference in New Issue
Block a user