From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Ribalda Delgado Subject: Re: [PATCH v2] gpiolib: Show correct direction from the beginning Date: Mon, 1 Oct 2018 15:36:22 +0200 Message-ID: References: <20180921103604.13361-1-ricardo.ribalda@gmail.com> <20180921103604.13361-2-ricardo.ribalda@gmail.com> <153803107307.119890.10052910965015646333@swboyd.mtv.corp.google.com> <3e07cab8-0f3e-7474-8f6d-e6bb16e8f998@codeaurora.org> <5aea282d-6fc9-cd70-cec4-10f28aa819b9@codeaurora.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Linus Walleij Cc: Timur Tabi , Jeffrey Hugo , Stephen Boyd , LKML , linux-gpio List-Id: linux-gpio@vger.kernel.org Hi Linus On Mon, Oct 1, 2018 at 1:54 PM Linus Walleij wrote: > > On Fri, Sep 28, 2018 at 9:30 PM Ricardo Ribalda Delgado > 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