On Sat, May 31, 2014 at 04:01:37PM +0200, Hans de Goede wrote:
> With level triggered interrupt mask / unmask will get called for each
> interrupt, doing the somewhat expensive mux setting on each unmask thus is
> not a good idea. Instead add a request_resources callback and do it there.
> 
> Signed-off-by: Hans de Goede <[email protected]>
> ---
>  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c 
> b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> index c199337..61d3246 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> @@ -531,6 +531,19 @@ static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip 
> *chip, unsigned offset)
>       return irq_find_mapping(pctl->domain, desc->irqnum);
>  }
>  
> +static int sunxi_pinctrl_irq_request_resources(struct irq_data *d)
> +{
> +     struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
> +     struct sunxi_desc_function *func;
> +
> +     func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
> +                                     pctl->irq_array[d->hwirq], "irq");

I know you're just moving code here, but we should add a check for
func being !NULL here, otherwise, the kernel is going to blow up at
the next line.

And since gpio_to_irq might not be called before the request_irq, you
might be in such a case.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

Attachment: signature.asc
Description: Digital signature

Reply via email to