linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Puranjay Mohan <puranjay12@gmail.com>
To: gregkh@linuxfoundation.org, rafael@kernel.org,
	linux-kernel@vger.kernel.org, jic23@kernel.org,
	linux-iio@vger.kernel.org
Cc: Puranjay Mohan <puranjay12@gmail.com>
Subject: [PATCH 1/1] device property: Add fwnode_irq_get_by_name
Date: Sat,  6 Nov 2021 23:09:09 +0530	[thread overview]
Message-ID: <20211106173909.34255-2-puranjay12@gmail.com> (raw)
In-Reply-To: <20211106173909.34255-1-puranjay12@gmail.com>

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_by_name() function.

Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
---
 drivers/base/property.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index f1f35b48ab8b..627e4e6d3ebd 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -958,6 +958,30 @@ int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
 }
 EXPORT_SYMBOL(fwnode_irq_get);
 
+/**
+ * fwnode_irq_get_by_name - 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_by_name(const struct fwnode_handle *fwnode, const char *name)
+{
+	int index;
+
+	if (unlikely(!name))
+		return -EINVAL;
+
+	index = of_property_match_string(to_of_node(fwnode), "interrupt-names",
+					 name);
+	if (index < 0)
+		return index;
+
+	return fwnode_irq_get(fwnode, index);
+}
+EXPORT_SYMBOL(fwnode_irq_get_by_name);
+
 /**
  * fwnode_graph_get_next_endpoint - Get next endpoint firmware node
  * @fwnode: Pointer to the parent firmware node
-- 
2.30.1


  reply	other threads:[~2021-11-06 17:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-06 17:39 [PATCH 0/1] device property: Adding fwnode_irq_get_by_name() Puranjay Mohan
2021-11-06 17:39 ` Puranjay Mohan [this message]
2021-11-07  1:33   ` [PATCH 1/1] device property: Add fwnode_irq_get_by_name kernel test robot
2021-11-07 12:37   ` kernel test robot
2021-11-07  8:29 ` [PATCH 0/1] device property: Adding fwnode_irq_get_by_name() Greg KH
2021-11-09 19:30   ` Puranjay Mohan
2021-11-09 19:45     ` Greg KH
2021-11-09 20:13       ` Puranjay Mohan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211106173909.34255-2-puranjay12@gmail.com \
    --to=puranjay12@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).