Commit ad69674e authored by Grygorii Strashko's avatar Grygorii Strashko Committed by Grant Likely

of/irq: do irq resolution in platform_get_irq_byname()

The commit 9ec36caf
"of/irq: do irq resolution in platform_get_irq" from Rob Herring -
moves resolving of the interrupt resources in platform_get_irq().
But this solution isn't complete because platform_get_irq_byname()
need to be modified the same way.

Hence, fix it by adding interrupt resolution code at the
platform_get_irq_byname() function too.

Cc: Russell King <linux@arm.linux.org.uk>
Cc: Rob Herring <robh@kernel.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarGrant Likely <grant.likely@linaro.org>
parent ae91ff72
...@@ -131,9 +131,12 @@ EXPORT_SYMBOL_GPL(platform_get_resource_byname); ...@@ -131,9 +131,12 @@ EXPORT_SYMBOL_GPL(platform_get_resource_byname);
*/ */
int platform_get_irq_byname(struct platform_device *dev, const char *name) int platform_get_irq_byname(struct platform_device *dev, const char *name)
{ {
struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, struct resource *r;
name);
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; return r ? r->start : -ENXIO;
} }
EXPORT_SYMBOL_GPL(platform_get_irq_byname); EXPORT_SYMBOL_GPL(platform_get_irq_byname);
......
...@@ -405,6 +405,28 @@ int of_irq_get(struct device_node *dev, int index) ...@@ -405,6 +405,28 @@ int of_irq_get(struct device_node *dev, int index)
return irq_create_of_mapping(&oirq); 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 * of_irq_count - Count the number of IRQs a node uses
* @dev: pointer to device tree node * @dev: pointer to device tree node
......
...@@ -45,6 +45,7 @@ extern void of_irq_init(const struct of_device_id *matches); ...@@ -45,6 +45,7 @@ extern void of_irq_init(const struct of_device_id *matches);
#ifdef CONFIG_OF_IRQ #ifdef CONFIG_OF_IRQ
extern int of_irq_count(struct device_node *dev); 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(struct device_node *dev, int index);
extern int of_irq_get_byname(struct device_node *dev, const char *name);
#else #else
static inline int of_irq_count(struct device_node *dev) 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) ...@@ -54,6 +55,10 @@ static inline int of_irq_get(struct device_node *dev, int index)
{ {
return 0; return 0;
} }
static inline int of_irq_get_byname(struct device_node *dev, const char *name)
{
return 0;
}
#endif #endif
#if defined(CONFIG_OF) #if defined(CONFIG_OF)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment