Skip to content

Commit ca0acb5

Browse files
akhilr-nvwsakernel
authored andcommitted
device property: Add fwnode_irq_get_byname
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>
1 parent e783362 commit ca0acb5

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

drivers/base/property.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,35 @@ void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index)
935935
}
936936
EXPORT_SYMBOL(fwnode_iomap);
937937

938+
/**
939+
* fwnode_irq_get_byname - Get IRQ from a fwnode using its name
940+
* @fwnode: Pointer to the firmware node
941+
* @name: IRQ name
942+
*
943+
* Description:
944+
* Find a match to the string @name in the 'interrupt-names' string array
945+
* in _DSD for ACPI, or of_node for Device Tree. Then get the Linux IRQ
946+
* number of the IRQ resource corresponding to the index of the matched
947+
* string.
948+
*
949+
* Return:
950+
* Linux IRQ number on success, or negative errno otherwise.
951+
*/
952+
int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name)
953+
{
954+
int index;
955+
956+
if (!name)
957+
return -EINVAL;
958+
959+
index = fwnode_property_match_string(fwnode, "interrupt-names", name);
960+
if (index < 0)
961+
return index;
962+
963+
return fwnode_irq_get(fwnode, index);
964+
}
965+
EXPORT_SYMBOL(fwnode_irq_get_byname);
966+
938967
/**
939968
* fwnode_graph_get_next_endpoint - Get next endpoint firmware node
940969
* @fwnode: Pointer to the parent firmware node

include/linux/property.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
121121
void fwnode_handle_put(struct fwnode_handle *fwnode);
122122

123123
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
124+
int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);
124125

125126
void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index);
126127

0 commit comments

Comments
 (0)