The fwnode framework did not have means to obtain the IRQ number from the name of a node. Add that now, in form of the fwnode_irq_get_byname() function. Signed-off-by: Puranjay Mohan <puranjay12@xxxxxxxxx> --- drivers/base/property.c | 23 +++++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index f1f35b48ab8b..0d685c79b0e8 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -958,6 +958,29 @@ int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) } EXPORT_SYMBOL(fwnode_irq_get); +/** + * fwnode_irq_get_byname - Get IRQ directly from its name. + * @fwnode: Pointer to the firmware node + * @name: IRQ Name + * + * Returns Linux IRQ number on success. Other values are determined + * accordingly to acpi_/of_ irq_get() operation. + */ +int fwnode_irq_get_byname(struct fwnode_handle *fwnode, const char *name) +{ + int index; + + if (unlikely(!name)) + return -EINVAL; + + index = fwnode_property_match_string(fwnode, "interrupt-names", name); + if (index < 0) + return index; + + return fwnode_irq_get(fwnode, index); +} +EXPORT_SYMBOL(fwnode_irq_get_byname); + /** * fwnode_graph_get_next_endpoint - Get next endpoint firmware node * @fwnode: Pointer to the parent firmware node diff --git a/include/linux/property.h b/include/linux/property.h index 88fa726a76df..9c6177597ba8 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -122,6 +122,8 @@ void fwnode_handle_put(struct fwnode_handle *fwnode); int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); +int fwnode_irq_get_byname(struct fwnode_handle *fwnode, const char *name); + unsigned int device_get_child_node_count(struct device *dev); static inline bool device_property_read_bool(struct device *dev, -- 2.30.1