lkml.org 
[lkml]   [2022]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4 1/3] device property: Add fwnode_irq_get_byname
On Sat, Jan 22, 2022 at 12:33 PM Akhil R <akhilrajeev@nvidia.com> wrote:
>
> 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>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
> drivers/base/property.c | 29 +++++++++++++++++++++++++++++
> include/linux/property.h | 1 +
> 2 files changed, 30 insertions(+)
>
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index e6497f6..fc59e0f 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -936,6 +936,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
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 7399a0b..95d56a5 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -121,6 +121,7 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
> 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(const struct fwnode_handle *fwnode, const char *name);
>
> void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index);
>
> --
> 2.7.4
>

\
 
 \ /
  Last update: 2022-01-25 18:54    [W:0.210 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site