[PATCH] usb: xhci: only set D3hot for pci device
From: Henry Lin
Date: Tue Nov 12 2019 - 02:18:37 EST
xhci driver cannot call pci_set_power_state() on non-pci xhci host
controllers.
Signed-off-by: Henry Lin <henryl@xxxxxxxxxx>
---
drivers/usb/host/xhci.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6c17e3fe181a..1fc16763dcda 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -761,6 +761,8 @@ static void xhci_stop(struct usb_hcd *hcd)
mutex_unlock(&xhci->mutex);
}
+extern struct device_type pci_dev_type;
+
/*
* Shutdown HC (not bus-specific)
*
@@ -791,8 +793,12 @@ static void xhci_shutdown(struct usb_hcd *hcd)
readl(&xhci->op_regs->status));
/* Yet another workaround for spurious wakeups at shutdown with HSW */
- if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
- pci_set_power_state(to_pci_dev(hcd->self.sysdev), PCI_D3hot);
+ if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) {
+ struct device *dev = hcd->self.sysdev;
+
+ if (dev->type == &pci_dev_type)
+ pci_set_power_state(to_pci_dev(dev), PCI_D3hot);
+ }
}
#ifdef CONFIG_PM
--
2.17.1