Re: [PATCH v2] gpiolib: Show correct direction from the beginning
From: Ricardo Ribalda Delgado
Date: Mon Oct 01 2018 - 09:36:44 EST
Hi Linus
On Mon, Oct 1, 2018 at 1:54 PM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
>
> On Fri, Sep 28, 2018 at 9:30 PM Ricardo Ribalda Delgado
> <ricardo.ribalda@xxxxxxxxx> wrote:
>
> > How do we proceed from here? Can you fix your driver somehow to
> > init the valid mask before enabling the gpio?
>
> Just include a hunk to the qcom driver reordering this call
> at the same time. No need to make it separate patches,
> it need to be tested together anyways.
>
> I guess just switch the order of these two:
>
> ret = gpiochip_add_data(&pctrl->chip, pctrl);
> if (ret) {
> dev_err(pctrl->dev, "Failed register gpiochip\n");
> return ret;
> }
>
> ret = msm_gpio_init_valid_mask(chip, pctrl);
> if (ret) {
> dev_err(pctrl->dev, "Failed to setup irq valid bits\n");
> gpiochip_remove(&pctrl->chip);
> return ret;
> }
>
the problem is that valid_mask is not a long/integer, is a struct that
needs to be malloced, and is malloc at gpiochip_add_data :(
Maybe we need a callback from the driver to init that mask just after
the allocation?
A fast grep shows that the only driver using need_valid_mask (not for
irq) is msm:
ricardo@neopili:~/curro/kernel-upstream$ git grep "need_valid_mask ="
| grep -v irq
drivers/gpio/gpiolib.c: gpiochip->need_valid_mask = true;
drivers/pinctrl/intel/pinctrl-cherryview.c: bool need_valid_mask =
!dmi_check_system(chv_no_valid_mask);
drivers/pinctrl/qcom/pinctrl-msm.c: chip->need_valid_mask =
msm_gpio_needs_valid_mask(pctrl);
so hacking something in the driver might not be a terrible idea.
Also
> > Do we need to make more severe changes on the core?
>
> Don't think so.
>
> Yours,
> Linus Walleij
--
Ricardo Ribalda