From: Jeffrey Hugo Subject: Re: [PATCH v2] gpiolib: Show correct direction from the beginning Date: Mon, 1 Oct 2018 08:27:39 -0600 Message-ID: <79878ad4-1c2a-39fa-5baa-042140a6f1ad@codeaurora.org> 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; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Ricardo Ribalda Delgado , Linus Walleij Cc: Timur Tabi , Stephen Boyd , LKML , linux-gpio List-Id: linux-gpio@vger.kernel.org On 10/1/2018 7:36 AM, Ricardo Ribalda Delgado wrote: > 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. > IMO, hack up the driver and I'll test it. We can figure out what is needed to work, then determine what is the proper solution for that. -- Jeffrey Hugo Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.