Skip to content

Commit ad69674

Browse files
grygoriySglikely
authored andcommitted
of/irq: do irq resolution in platform_get_irq_byname()
The commit 9ec36ca "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 <[email protected]> Cc: Rob Herring <[email protected]> Cc: Tony Lindgren <[email protected]> Cc: Grant Likely <[email protected]> Cc: Thierry Reding <[email protected]> Signed-off-by: Grygorii Strashko <[email protected]> Signed-off-by: Grant Likely <[email protected]>
1 parent ae91ff7 commit ad69674

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

drivers/base/platform.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ EXPORT_SYMBOL_GPL(platform_get_resource_byname);
131131
*/
132132
int platform_get_irq_byname(struct platform_device *dev, const char *name)
133133
{
134-
struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ,
135-
name);
134+
struct resource *r;
135+
136+
if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node)
137+
return of_irq_get_byname(dev->dev.of_node, name);
136138

139+
r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name);
137140
return r ? r->start : -ENXIO;
138141
}
139142
EXPORT_SYMBOL_GPL(platform_get_irq_byname);

drivers/of/irq.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,28 @@ int of_irq_get(struct device_node *dev, int index)
405405
return irq_create_of_mapping(&oirq);
406406
}
407407

408+
/**
409+
* of_irq_get_byname - Decode a node's IRQ and return it as a Linux irq number
410+
* @dev: pointer to device tree node
411+
* @name: irq name
412+
*
413+
* Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain
414+
* is not yet created, or error code in case of any other failure.
415+
*/
416+
int of_irq_get_byname(struct device_node *dev, const char *name)
417+
{
418+
int index;
419+
420+
if (unlikely(!name))
421+
return -EINVAL;
422+
423+
index = of_property_match_string(dev, "interrupt-names", name);
424+
if (index < 0)
425+
return index;
426+
427+
return of_irq_get(dev, index);
428+
}
429+
408430
/**
409431
* of_irq_count - Count the number of IRQs a node uses
410432
* @dev: pointer to device tree node

include/linux/of_irq.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extern void of_irq_init(const struct of_device_id *matches);
4545
#ifdef CONFIG_OF_IRQ
4646
extern int of_irq_count(struct device_node *dev);
4747
extern int of_irq_get(struct device_node *dev, int index);
48+
extern int of_irq_get_byname(struct device_node *dev, const char *name);
4849
#else
4950
static inline int of_irq_count(struct device_node *dev)
5051
{
@@ -54,6 +55,10 @@ static inline int of_irq_get(struct device_node *dev, int index)
5455
{
5556
return 0;
5657
}
58+
static inline int of_irq_get_byname(struct device_node *dev, const char *name)
59+
{
60+
return 0;
61+
}
5762
#endif
5863

5964
#if defined(CONFIG_OF)

0 commit comments

Comments
 (0)