diff options
author | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2013-08-09 16:27:09 -0400 |
---|---|---|
committer | Jason Cooper <jason@lakedaemon.net> | 2013-08-12 11:27:01 -0400 |
commit | 0d5a6db3aa46faafd0212650bfd709d51240d9da (patch) | |
tree | dea9d680f4ae8aea5628ec8d69b72802f0a4bf28 /drivers/of/of_pci.c | |
parent | 0cbdcfcf427b63b9670e56760ef5e67cd7081b35 (diff) |
of: pci: add registry of MSI chips
This commit adds a very basic registry of msi_chip structures, so that
an IRQ controller driver can register an msi_chip, and a PCIe host
controller can find it, based on a 'struct device_node'.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Diffstat (limited to 'drivers/of/of_pci.c')
-rw-r--r-- | drivers/of/of_pci.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 42c687a820ac..e5ca00893c0c 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c | |||
@@ -89,3 +89,48 @@ int of_pci_parse_bus_range(struct device_node *node, struct resource *res) | |||
89 | return 0; | 89 | return 0; |
90 | } | 90 | } |
91 | EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); | 91 | EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); |
92 | |||
93 | #ifdef CONFIG_PCI_MSI | ||
94 | |||
95 | static LIST_HEAD(of_pci_msi_chip_list); | ||
96 | static DEFINE_MUTEX(of_pci_msi_chip_mutex); | ||
97 | |||
98 | int of_pci_msi_chip_add(struct msi_chip *chip) | ||
99 | { | ||
100 | if (!of_property_read_bool(chip->of_node, "msi-controller")) | ||
101 | return -EINVAL; | ||
102 | |||
103 | mutex_lock(&of_pci_msi_chip_mutex); | ||
104 | list_add(&chip->list, &of_pci_msi_chip_list); | ||
105 | mutex_unlock(&of_pci_msi_chip_mutex); | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | EXPORT_SYMBOL_GPL(of_pci_msi_chip_add); | ||
110 | |||
111 | void of_pci_msi_chip_remove(struct msi_chip *chip) | ||
112 | { | ||
113 | mutex_lock(&of_pci_msi_chip_mutex); | ||
114 | list_del(&chip->list); | ||
115 | mutex_unlock(&of_pci_msi_chip_mutex); | ||
116 | } | ||
117 | EXPORT_SYMBOL_GPL(of_pci_msi_chip_remove); | ||
118 | |||
119 | struct msi_chip *of_pci_find_msi_chip_by_node(struct device_node *of_node) | ||
120 | { | ||
121 | struct msi_chip *c; | ||
122 | |||
123 | mutex_lock(&of_pci_msi_chip_mutex); | ||
124 | list_for_each_entry(c, &of_pci_msi_chip_list, list) { | ||
125 | if (c->of_node == of_node) { | ||
126 | mutex_unlock(&of_pci_msi_chip_mutex); | ||
127 | return c; | ||
128 | } | ||
129 | } | ||
130 | mutex_unlock(&of_pci_msi_chip_mutex); | ||
131 | |||
132 | return NULL; | ||
133 | } | ||
134 | EXPORT_SYMBOL_GPL(of_pci_find_msi_chip_by_node); | ||
135 | |||
136 | #endif /* CONFIG_PCI_MSI */ | ||