@@ -129,7 +129,7 @@ static void armada_370_xp_free_msi(int hwirq)
mutex_unlock(&msi_used_lock);
}
-static int armada_370_xp_setup_msi_irq(struct pci_dev *pdev,
+static int armada_370_xp_setup_msi_irq(struct device *dev,
struct msi_desc *desc)
{
struct msi_msg msg;
@@ -164,7 +164,7 @@ static void armada_370_xp_teardown_msi_irq(unsigned int irq)
armada_370_xp_free_msi(hwirq);
}
-static int armada_370_xp_check_msi_device(struct pci_dev *dev,
+static int armada_370_xp_check_msi_device(struct device *dev,
int nvec, int type)
{
/* We support MSI, but not MSI-X */
@@ -1192,9 +1192,10 @@ static irqreturn_t tegra_pcie_msi_irq(int irq, void *data)
return processed > 0 ? IRQ_HANDLED : IRQ_NONE;
}
-static int tegra_msi_setup_irq(struct pci_dev *pdev,
+static int tegra_msi_setup_irq(struct device *dev,
struct msi_desc *desc)
{
+ struct pci_dev *pdev = to_pci_dev(dev);
struct msi_chip *chip = pdev->bus->msi;
struct tegra_msi *msi = to_tegra_msi(chip);
struct msi_msg msg;
@@ -342,12 +342,12 @@ static void clear_irq(unsigned int irq)
msi->msi_attrib.multiple = 0;
}
-static int dw_msi_setup_irq(struct pci_dev *pdev,
- struct msi_desc *desc)
+static int dw_msi_setup_irq(struct device *dev, struct msi_desc *desc)
{
int irq, pos, msgvec;
u16 msg_ctr;
struct msi_msg msg;
+ struct pci_dev *pdev = to_pci_dev(dev);
struct pcie_port *pp = sys_to_pcie(pdev->bus->sysdata);
if (!pp) {
@@ -615,9 +615,10 @@ static irqreturn_t rcar_pcie_msi_irq(int irq, void *data)
return IRQ_HANDLED;
}
-static int rcar_msi_setup_irq(struct pci_dev *pdev,
+static int rcar_msi_setup_irq(struct device *dev,
struct msi_desc *desc)
{
+ struct pci_dev *pdev = to_pci_dev(dev);
struct msi_chip *chip = pdev->bus->msi;
struct rcar_msi *msi = to_rcar_msi(chip);
struct rcar_pcie *pcie = container_of(chip, struct rcar_pcie, msi.chip);
@@ -37,7 +37,7 @@ int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
if (!chip || !chip->setup_irq)
return -EINVAL;
- err = chip->setup_irq(dev, desc);
+ err = chip->setup_irq(&dev->dev, desc);
if (err < 0)
return err;
@@ -61,7 +61,7 @@ int __weak arch_msi_check_device(struct pci_dev *dev, int nvec, int type)
if (!chip || !chip->check_device)
return 0;
- return chip->check_device(dev, nvec, type);
+ return chip->check_device(&dev->dev, nvec, type);
}
int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
@@ -72,9 +72,12 @@ struct msi_chip {
struct device_node *of_node;
struct list_head list;
- int (*setup_irq)(struct pci_dev *dev, struct msi_desc *desc);
+ int (*check_device)(struct device *dev, int nvec, int type);
+ int (*setup_irq)(struct device *dev, struct msi_desc *desc);
+ int (*setup_irqs)(struct device *dev, int nvec, int type);
void (*teardown_irq)(unsigned int irq);
- int (*check_device)(struct pci_dev *dev, int nvec, int type);
+ void (*teardown_irqs)(struct device *dev);
+ void (*restore_irqs)(struct device *dev);
};
#endif /* LINUX_MSI_H */
Now there are a lot of __weak arch functions in MSI code. These functions make MSI driver complex, It's time to refactor it. Add .restore_irq(), .setup_irqs(), .teardown_irqs() to make msi_chip common across all platforms. Also replace the argument "struct pci_dev" with "struct device" to support future Non-PCI MSI device. Signed-off-by: Yijing Wang <wangyijing@huawei.com> CC: Thierry Reding <thierry.reding@avionic-design.de> CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- drivers/irqchip/irq-armada-370-xp.c | 4 ++-- drivers/pci/host/pci-tegra.c | 3 ++- drivers/pci/host/pcie-designware.c | 4 ++-- drivers/pci/host/pcie-rcar.c | 3 ++- drivers/pci/msi.c | 4 ++-- include/linux/msi.h | 7 +++++-- 6 files changed, 15 insertions(+), 10 deletions(-)