[PATCH v2 1/2] of/irq: Factor out parsing of interrupt-map parent phandle+args from of_irq_parse_raw()

Marc Zyngier maz at kernel.org
Thu May 30 06:46:10 PDT 2024


On Wed, 29 May 2024 20:59:20 +0100,
"Rob Herring (Arm)" <robh at kernel.org> wrote:
> 
> Factor out the parsing of interrupt-map interrupt parent phandle and its
> arg cells to a separate function, of_irq_parse_imap_parent(), so that it
> can be used in other parsing scenarios (e.g. fw_devlink).
> 
> There was a refcount leak on non-matching entries when iterating thru
> "interrupt-map" which is fixed.
> 
> Signed-off-by: Rob Herring (Arm) <robh at kernel.org>
> ---
>  drivers/of/irq.c        | 127 +++++++++++++++++++++++++++++-------------------
>  drivers/of/of_private.h |   3 ++
>  2 files changed, 79 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 174900072c18..a7cdb892991e 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -25,6 +25,8 @@
>  #include <linux/string.h>
>  #include <linux/slab.h>
>  
> +#include "of_private.h"
> +
>  /**
>   * irq_of_parse_and_map - Parse and map an interrupt into linux virq space
>   * @dev: Device node of the device whose interrupt is to be mapped
> @@ -96,6 +98,59 @@ static const char * const of_irq_imap_abusers[] = {
>  	NULL,
>  };
>  
> +const __be32 *of_irq_parse_imap_parent(const __be32 *imap, int len, struct of_phandle_args *out_irq)
> +{
> +	u32 intsize, addrsize;
> +	struct device_node *np;
> +
> +	/* Get the interrupt parent */
> +	if (of_irq_workarounds & OF_IMAP_NO_PHANDLE)
> +		np = of_node_get(of_irq_dflt_pic);
> +	else
> +		np = of_find_node_by_phandle(be32_to_cpup(imap));
> +	imap++;
> +
> +	/* Check if not found */
> +	if (!np) {
> +		pr_debug(" -> imap parent not found !\n");
> +		return NULL;
> +	}
> +
> +	/* Get #interrupt-cells and #address-cells of new
> +		* parent
> +		*/

nit: funky formatting.

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list