[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211109200840.135019-2-puranjay12@gmail.com>
Date: Wed, 10 Nov 2021 01:38:39 +0530
From: Puranjay Mohan <puranjay12@...il.com>
To: gregkh@...uxfoundation.org, rafael@...nel.org,
heikki.krogerus@...ux.intel.com, andriy.shevchenko@...ux.intel.com,
kuba@...nel.org, saravanak@...gle.com,
linux-kernel@...r.kernel.org, lars@...afoo.de,
Michael.Hennerich@...log.com, jic23@...nel.org,
linux-iio@...r.kernel.org
Cc: Puranjay Mohan <puranjay12@...il.com>
Subject: [PATCH v2 1/2] device property: Add fwnode_irq_get_byname()
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@...il.com>
---
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
Powered by blists - more mailing lists