Re: [PATCH] gpio: Remove dynamic allocation from populate_parent_alloc_arg()

From: Daniel Palmer
Date: Fri May 13 2022 - 07:15:06 EST


Hi March,

On Fri, 13 May 2022 at 01:23, Marc Zyngier <maz@xxxxxxxxxx> wrote:
> diff --git a/drivers/gpio/gpio-msc313.c b/drivers/gpio/gpio-msc313.c
> index b2c90bdd39d0..52d7b8d99170 100644
> --- a/drivers/gpio/gpio-msc313.c
> +++ b/drivers/gpio/gpio-msc313.c
> @@ -550,15 +550,12 @@ static struct irq_chip msc313_gpio_irqchip = {
> * so we need to provide the fwspec. Essentially gpiochip_populate_parent_fwspec_twocell
> * that puts GIC_SPI into the first cell.
> */
> -static void *msc313_gpio_populate_parent_fwspec(struct gpio_chip *gc,
> - unsigned int parent_hwirq,
> - unsigned int parent_type)
> +static int msc313_gpio_populate_parent_fwspec(struct gpio_chip *gc,
> + union gpio_irq_fwspec *gfwspec,
> + unsigned int parent_hwirq,
> + unsigned int parent_type)
> {
> - struct irq_fwspec *fwspec;
> -
> - fwspec = kmalloc(sizeof(*fwspec), GFP_KERNEL);
> - if (!fwspec)
> - return NULL;
> + struct irq_fwspec *fwspec = &gfwspec->fwspec;
>
> fwspec->fwnode = gc->irq.parent_domain->fwnode;
> fwspec->param_count = 3;
> @@ -566,7 +563,7 @@ static void *msc313_gpio_populate_parent_fwspec(struct gpio_chip *gc,
> fwspec->param[1] = parent_hwirq;
> fwspec->param[2] = parent_type;
>
> - return fwspec;
> + return 0;
> }
>
> static int msc313e_gpio_child_to_parent_hwirq(struct gpio_chip *chip,

This bit looks fine to me. I will test it over the weekend.

Cheers,

Daniel