Re: [PATCH v2 1/3] device property: Add device_irq_get_byname

From: Andy Shevchenko
Date: Wed Jan 12 2022 - 10:55:43 EST


On Wed, Jan 12, 2022 at 4:14 PM Akhil R <akhilrajeev@xxxxxxxxxx> wrote:

In the subject line: device_irq_get_byname()

> Get interrupt by name from ACPI table as well.

an interrupt
the ACPI

> Add option to use 'interrupt-names' in _DSD which can map to interrupt by

can be mapped
Interrupt() resource

(The last one is very important to point out this is only about
Interrupt() resources for now).

> index. The implementation is similar to 'interrupt-names' in devicetree.

the Device Tree

> Also add a common routine to get irq by name from devicetree and ACPI

IRQ
Device Tree

> table.

...

> /**
> + * fwnode_irq_get_byname - Get IRQ from a fwnode using its name
> + * @fwnode: Pointer to the firmware node
> + * @name: IRQ name in interrupt-names property in fwnode
> + *
> + * Returns Linux IRQ number on success, errno otherwise.

negative errno

> + */
> +int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name)
> +{
> + int index;

> + if (unlikely(!name))

Don't use unlikely() here.

> + return -EINVAL;
> +
> + index = fwnode_property_match_string(fwnode, "interrupt-names", name);
> + if (index < 0)
> + return index;
> +
> + return fwnode_irq_get(fwnode, index);
> +}

--
With Best Regards,
Andy Shevchenko