Re: [PATCH 1/1] pinctrl: stmfx: add irq_request/release_resources callbacks
From: Linus Walleij
Date: Wed Oct 16 2019 - 07:12:44 EST
On Mon, Oct 7, 2019 at 4:53 PM Amelie DELAUNAY <amelie.delaunay@xxxxxx> wrote:
> On 10/5/19 6:49 PM, Linus Walleij wrote:
> > On Fri, Oct 4, 2019 at 2:29 PM Amelie Delaunay <amelie.delaunay@xxxxxx>
> >> + pctl->irq_chip.irq_request_resources = stmfx_gpio_irq_request_resources;
> >> + pctl->irq_chip.irq_release_resources = stmfx_gpio_irq_release_resources;
> >
> > What about just adding
> >
> > pctl->irq_chip.irq_enable and do stmfx_gpio_direction_input()
> > in that callback instead? gpiolib will helpfully wrap it.
>
> Thanks for pointing that out to me.
>
> I can't use .irq_enable because of I2C transfer to set gpio direction
> (scheduling while atomic BUG occurs in this case). Indeed, .irq_enable
> is called under raw_spin_lock_irqsave in __setup_irq() while
> irq_request_resources is called before.
>
> I could apply gpio direction in stmfx_pinctrl_irq_bus_sync_unlock
> depending on pctl->irq_gpi_src[] (checking which one is set, to set
> input direction), but this will be applied each time a consumer requests
> a stmfx gpio irq.
Oh I get it, hm. I thought it would be covered by the sync_unlock()
but I guess not then.
> IMHO, keeping .irq_request/release_resources callbacks and using
> gpiochip_reqres_irq()/gpiochip_relres_irq() seems to be the best compromise.
OK let's go with that for now, please put in some comments as
to why this gets done there so we know when reading the
code.
Yours,
Linus Walleij