[PATCH 1/5] USB: hcd-pci: add callbacks for enabling MSI

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

 



Add callbacks to the hc_driver structure to allow drivers that use
hcd-pci to manage enabling of MSI interrupts.

Signed-off-by: Clemens Ladisch <clemens@xxxxxxxxxx>
---
 drivers/usb/core/hcd-pci.c |   19 +++++++++++++++++--
 include/linux/usb/hcd.h    |    4 ++++
 2 files changed, 21 insertions(+), 2 deletions(-)

--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -176,6 +176,7 @@ int usb_hcd_pci_probe(struct pci_dev *de
 {
 	struct hc_driver	*driver;
 	struct usb_hcd		*hcd;
+	unsigned long		irqflags;
 	int			retval;
 
 	if (usb_disabled())
@@ -246,12 +247,24 @@ int usb_hcd_pci_probe(struct pci_dev *de
 
 	pci_set_master(dev);
 
-	retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED);
+	if (driver->pci_prepare_irq) {
+		retval = driver->pci_prepare_irq(hcd);
+		if (retval < 0)
+			goto err4;
+	}
+
+	irqflags = IRQF_DISABLED;
+	if (!pci_dev_msi_enabled(dev))
+		irqflags |= IRQF_SHARED;
+	retval = usb_add_hcd(hcd, dev->irq, irqflags);
 	if (retval != 0)
-		goto err4;
+		goto err5;
 	set_hs_companion(dev, hcd);
 	return retval;
 
+ err5:
+	if (driver->pci_cleanup_irq)
+		driver->pci_cleanup_irq(hcd);
  err4:
 	if (driver->flags & HCD_MEMORY) {
 		iounmap(hcd->regs);
@@ -293,6 +306,8 @@ void usb_hcd_pci_remove(struct pci_dev *
 		return;
 
 	usb_remove_hcd(hcd);
+	if (hcd->driver->pci_cleanup_irq)
+		hcd->driver->pci_cleanup_irq(hcd);
 	if (hcd->driver->flags & HCD_MEMORY) {
 		iounmap(hcd->regs);
 		release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -190,6 +190,10 @@ struct hc_driver {
 #define	HCD_USB3	0x0040		/* USB 3.0 */
 #define	HCD_MASK	0x0070
 
+	/* used to enable MSI, if desired */
+	int	(*pci_prepare_irq)(struct usb_hcd *hcd);
+	void	(*pci_cleanup_irq)(struct usb_hcd *hcd);
+
 	/* called to init HCD and root hub */
 	int	(*reset) (struct usb_hcd *hcd);
 	int	(*start) (struct usb_hcd *hcd);
--
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