Merge branch 'i2c/for-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
[cascardo/linux.git] / drivers / of / irq.c
index e9eaed1..55317fa 100644 (file)
@@ -18,6 +18,7 @@
  * driver.
  */
 
+#include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/list.h>
 #include <linux/module.h>
@@ -577,3 +578,23 @@ err:
                kfree(desc);
        }
 }
+
+/**
+ * of_msi_configure - Set the msi_domain field of a device
+ * @dev: device structure to associate with an MSI irq domain
+ * @np: device node for that device
+ */
+void of_msi_configure(struct device *dev, struct device_node *np)
+{
+       struct device_node *msi_np;
+       struct irq_domain *d;
+
+       msi_np = of_parse_phandle(np, "msi-parent", 0);
+       if (!msi_np)
+               return;
+
+       d = irq_find_matching_host(msi_np, DOMAIN_BUS_PLATFORM_MSI);
+       if (!d)
+               d = irq_find_host(msi_np);
+       dev_set_msi_domain(dev, d);
+}