[PATCH 15/20] usb: xhci: move xhci_reinit() into xhci-pci reset code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



xhci_reinit() is very pci-specific: it reads a value from PCI config
space and executes a PCI command. Looking through the EHCI code, the
->reset() callback is one that requires special treatment on most
platforms.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
 drivers/usb/host/xhci-pci.c |   25 +++++++++++++++++++++----
 drivers/usb/host/xhci.c     |   12 +++---------
 drivers/usb/host/xhci.h     |    3 +--
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index ce9182a..0036f35 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -35,11 +35,10 @@
 
 
 /* called after powerup, by probe or system-pm "wakeup" */
-int xhci_reinit(struct xhci_hcd *xhci, struct device *dev)
+static void xhci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
 {
-	struct pci_dev		*pdev = to_pci_dev(dev->parent);
-
 	pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn);
+	xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn);
 
 	/*
 	 * TODO: Implement finding debug ports later.
@@ -52,9 +51,27 @@ int xhci_reinit(struct xhci_hcd *xhci, struct device *dev)
 		xhci_dbg(xhci, "MWI active\n");
 
 	xhci_dbg(xhci, "Finished xhci_pci_reinit\n");
+}
+
+static int xhci_pci_plat_reset(struct usb_hcd *hcd)
+{
+	struct platform_device  *plat_dev;
+	struct pci_dev          *pci_dev;
+	int ret;
+
+	ret = xhci_setup(hcd);
+	if (ret)
+		return ret;
+
+	if (!usb_hcd_is_primary_hcd(hcd))
+		return 0;
+
+	plat_dev = to_platform_device(hcd->self.controller);
+	pci_dev = to_pci_dev(plat_dev->dev.parent);
+	/* Find any debug ports */
+	xhci_reinit(hcd_to_xhci(hcd), pci_dev);
 	return 0;
 }
-EXPORT_SYMBOL_GPL(xhci_reinit);
 
 /* called during probe() after chip reset completes */
 #define XHCI_PCI_DEVS_POSSIBLE	32
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index c03b738..96f2192 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3117,10 +3117,9 @@ MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_LICENSE("GPL");
 
-static int xhci_setup(struct usb_hcd *hcd)
+int xhci_setup(struct usb_hcd *hcd)
 {
 	struct xhci_hcd		*xhci;
-	struct device		*dev = hcd->self.controller;
 	int			retval;
 	u32			temp;
 	struct platform_device	*plat_dev;
@@ -3207,18 +3206,13 @@ static int xhci_setup(struct usb_hcd *hcd)
 		goto error;
 	xhci_dbg(xhci, "Called HCD init\n");
 
-	/* Find any debug ports */
-	retval = xhci_reinit(xhci, dev);
-
-	xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn);
-
-	if (!retval)
-		return retval;
+	return retval;
 
 error:
 	kfree(xhci);
 	return retval;
 }
+EXPORT_SYMBOL_GPL(xhci_setup);
 
 static const struct hc_driver xhci_hc_driver = {
 	.description		= "xhci-hcd",
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index c8a3f12..eec4178 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1415,8 +1415,6 @@ static inline int xhci_link_trb_quirk(struct xhci_hcd *xhci)
 			(xhci->quirks & XHCI_LINK_TRB_QUIRK));
 }
 
-extern int xhci_reinit(struct xhci_hcd *xhci, struct device *dev);
-
 /* xHCI debugging */
 void xhci_print_ir_set(struct xhci_hcd *xhci, int set_num);
 void xhci_print_registers(struct xhci_hcd *xhci);
@@ -1494,6 +1492,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
 void xhci_quiesce(struct xhci_hcd *xhci);
 int xhci_halt(struct xhci_hcd *xhci);
 int xhci_reset(struct xhci_hcd *xhci);
+int xhci_setup(struct usb_hcd *hcd);
 int xhci_init(struct usb_hcd *hcd);
 int xhci_run(struct usb_hcd *hcd);
 void xhci_stop(struct usb_hcd *hcd);
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux