diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 5b47210889e038d72f7a172062b3c4ddd2daa07d..9e9227e1762d495b80ef48324ea6ec7c44bf1e27 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -131,9 +131,12 @@ EXPORT_SYMBOL_GPL(platform_get_resource_byname); */ int platform_get_irq_byname(struct platform_device *dev, const char *name) { - struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, - name); + struct resource *r; + + if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) + return of_irq_get_byname(dev->dev.of_node, name); + r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); return r ? r->start : -ENXIO; } EXPORT_SYMBOL_GPL(platform_get_irq_byname); diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 5aeb89411350a4c98a2d769302e16a8d650d075f..3e06a699352d0c83a8c660b35d64c97babcc7469 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -405,6 +405,28 @@ int of_irq_get(struct device_node *dev, int index) return irq_create_of_mapping(&oirq); } +/** + * of_irq_get_byname - Decode a node's IRQ and return it as a Linux irq number + * @dev: pointer to device tree node + * @name: irq name + * + * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain + * is not yet created, or error code in case of any other failure. + */ +int of_irq_get_byname(struct device_node *dev, const char *name) +{ + int index; + + if (unlikely(!name)) + return -EINVAL; + + index = of_property_match_string(dev, "interrupt-names", name); + if (index < 0) + return index; + + return of_irq_get(dev, index); +} + /** * of_irq_count - Count the number of IRQs a node uses * @dev: pointer to device tree node diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index 6404253d810d7482a64fa9e959e99c8bad05c912..bfec136a6d1e60f89f85d93cab465a6a392f7b66 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -45,6 +45,7 @@ extern void of_irq_init(const struct of_device_id *matches); #ifdef CONFIG_OF_IRQ extern int of_irq_count(struct device_node *dev); extern int of_irq_get(struct device_node *dev, int index); +extern int of_irq_get_byname(struct device_node *dev, const char *name); #else static inline int of_irq_count(struct device_node *dev) { @@ -54,6 +55,10 @@ static inline int of_irq_get(struct device_node *dev, int index) { return 0; } +static inline int of_irq_get_byname(struct device_node *dev, const char *name) +{ + return 0; +} #endif #if defined(CONFIG_OF)