From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Walleij Subject: Re: [PATCH v2] gpiolib: Show correct direction from the beginning Date: Tue, 2 Oct 2018 09:38:05 +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: Ricardo Ribalda Delgado Cc: timur@kernel.org, jhugo@codeaurora.org, Stephen Boyd , "linux-kernel@vger.kernel.org" , "open list:GPIO SUBSYSTEM" List-Id: linux-gpio@vger.kernel.org On Tue, Oct 2, 2018 at 9:15 AM Ricardo Ribalda Delgado wrote: > On Mon, Oct 1, 2018 at 11:20 PM Linus Walleij wrote: > > gpiochip_add_data() doesn't allocate anything, it > > just adds a already allocated (or static!) gpio_chip > > to the gpiolib subsystem. > > Take a look to gpiochip_add_data_with_key() > ->gpiochip_init_valid_mask() > -> gpiochip->valid_mask = gpiochip_allocate_mask(gpiochip); Aha I see... > > In fact I think it is wrong to set up the mask after > > calling gpiolob_add_data(), because of exactly the > > type of problem you're seeing. > > I agree, and I believe that the cleaner way would be to add a function > pointer that replaces: > > gpiochip_allocate_mask() > bitmap_fill(p, chip->ngpio); > > with a proper initalization from the driver OK > But as today the only driver that seems to be using valid_mask is msm, > so perhaps a hack is something better and then when we have a second > driver that requires it we figure out the real requirements. But it is > definately your decision ;) I would just add some exported function to gpiolib to do what you need so you can set up the valid_mask before calling gpiochip_add*. Yours, Linus Walleij