summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorAkhil R <akhilrajeev@nvidia.com>2022-01-28 17:14:25 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-10-17 15:11:43 +0200
commitc15e2ab4fed9a9dc6c90b20d50352b72fa093345 (patch)
tree333d2f3c40be46960910c83db7d3bb6068070a75 /drivers/base
parentbf36521e559e28928c7f860d8d2db97afb5dbc93 (diff)
device property: Add fwnode_irq_get_byname
[ Upstream commit ca0acb511c21738b32386ce0f85c284b351d919e ] Add fwnode_irq_get_byname() to get an interrupt by name from either ACPI table or Device Tree, whichever is used for enumeration. In the ACPI case, this allow us to use 'interrupt-names' in _DSD which can be mapped to Interrupt() resource by index. The implementation is similar to 'interrupt-names' in the Device Tree. Signed-off-by: Akhil R <akhilrajeev@nvidia.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Wolfram Sang <wsa@kernel.org> Stable-dep-of: 8d3cefaf6592 ("i2c: core: Lock address during client device instantiation") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/property.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 87bb97e12749..ff1be3e311ee 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1067,6 +1067,35 @@ void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index)
EXPORT_SYMBOL(fwnode_iomap);
/**
+ * fwnode_irq_get_byname - Get IRQ from a fwnode using its name
+ * @fwnode: Pointer to the firmware node
+ * @name: IRQ name
+ *
+ * Description:
+ * Find a match to the string @name in the 'interrupt-names' string array
+ * in _DSD for ACPI, or of_node for Device Tree. Then get the Linux IRQ
+ * number of the IRQ resource corresponding to the index of the matched
+ * string.
+ *
+ * Return:
+ * Linux IRQ number on success, or negative errno otherwise.
+ */
+int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name)
+{
+ int index;
+
+ if (!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
* @prev: Previous endpoint node or %NULL to get the first