netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcin Wojtas <mw@semihalf.com>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-acpi@vger.kernel.org
Cc: graeme.gregory@linaro.org, davem@davemloft.net,
	linux@armlinux.org.uk, rafael.j.wysocki@intel.com,
	andrew@lunn.ch, f.fainelli@gmail.com,
	antoine.tenart@free-electrons.com,
	thomas.petazzoni@free-electrons.com,
	gregory.clement@free-electrons.com, stefanc@marvell.com,
	nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org,
	mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com
Subject: [net-next: PATCH v3 3/7] device property: Introduce fwnode_irq_get()
Date: Wed, 17 Jan 2018 17:55:42 +0100	[thread overview]
Message-ID: <1516208146-4144-4-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com>

Until now there were two very similar functions allowing
to get Linux IRQ number from ACPI handle (acpi_irq_get())
and OF node (of_irq_get()). The first one appeared to be used
only as a subroutine of platform_irq_get(), which (in the generic
code) limited IRQ obtaining from _CRS method only to nodes
associated to kernel's struct platform_device.

This patch introduces new helper routine - fwnode_irq_get(),
which allows to get the IRQ number directly from the fwnode
to be used as common for OF/ACPI worlds.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
 drivers/base/property.c  | 27 ++++++++++++++++++++
 include/linux/property.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 7c4a53d..adb3893 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -16,6 +16,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_graph.h>
+#include <linux/of_irq.h>
 #include <linux/property.h>
 #include <linux/etherdevice.h>
 #include <linux/phy.h>
@@ -1230,6 +1231,32 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen)
 EXPORT_SYMBOL(device_get_mac_address);
 
 /**
+ * fwnode_irq_get - Get IRQ directly from a fwnode
+ * @fwnode:	Pointer to the firmware node
+ * @index:	Zero-based index of the IRQ
+ *
+ * Returns Linux IRQ number on success. Other values are determined
+ * accordingly to acpi_/of_ irq_get() operation.
+ */
+int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index)
+{
+	struct acpi_device *adev = to_acpi_device_node(fwnode);
+	struct device_node *of_node = to_of_node(fwnode);
+	struct resource res;
+	int ret;
+
+	if (IS_ENABLED(CONFIG_OF) && of_node)
+		return of_irq_get(of_node, index);
+
+	ret = acpi_irq_get(acpi_device_handle(adev), index, &res);
+	if (ret)
+		return ret;
+
+	return res.start;
+}
+EXPORT_SYMBOL(fwnode_irq_get);
+
+/**
  * device_graph_get_next_endpoint - Get next endpoint firmware node
  * @fwnode: Pointer to the parent firmware node
  * @prev: Previous endpoint node or %NULL to get the first
diff --git a/include/linux/property.h b/include/linux/property.h
index 9b13332..e05889f 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -103,6 +103,8 @@ struct fwnode_handle *device_get_named_child_node(struct device *dev,
 struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
 void fwnode_handle_put(struct fwnode_handle *fwnode);
 
+int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index);
+
 unsigned int device_get_child_node_count(struct device *dev);
 
 static inline bool device_property_read_bool(struct device *dev,
-- 
2.7.4

  parent reply	other threads:[~2018-01-17 16:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 16:55 [net-next: PATCH v3 0/7] Armada 7k/8k PP2 ACPI support Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 1/7] device property: Introduce fwnode_get_mac_address() Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 2/7] device property: Introduce fwnode_get_phy_mode() Marcin Wojtas
2018-01-17 16:55 ` Marcin Wojtas [this message]
2018-01-17 16:55 ` [net-next: PATCH v3 4/7] device property: Allow iterating over available child fwnodes Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 5/7] net: mvpp2: simplify maintaining enabled ports' list Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 6/7] net: mvpp2: use device_*/fwnode_* APIs instead of of_* Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 7/7] net: mvpp2: enable ACPI support in the driver Marcin Wojtas
2018-01-17 18:11 ` [net-next: PATCH v3 0/7] Armada 7k/8k PP2 ACPI support Andrew Lunn
2018-01-17 19:03   ` Marcin Wojtas
2018-01-17 20:20 ` Andrew Lunn
2018-01-18 15:53 ` graeme.gregory

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=1516208146-4144-4-git-send-email-mw@semihalf.com \
    --to=mw@semihalf.com \
    --cc=andrew@lunn.ch \
    --cc=antoine.tenart@free-electrons.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=graeme.gregory@linaro.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=jaz@semihalf.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=nadavh@marvell.com \
    --cc=neta@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=stefanc@marvell.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=tn@semihalf.com \
    /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).