[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=Mf7bnAM=-A4jWrqOvS8-ZetTHPfMaEpmQdbKMt6SWKtQQ@mail.gmail.com>
Date: Tue, 16 Sep 2025 05:52:31 -0400
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Michael Walle <mwalle@...nel.org>
Cc: Frank Li <Frank.Li@....com>, Ioana Ciornei <ioana.ciornei@....com>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>, Bartosz Golaszewski <brgl@...ev.pl>,
Shawn Guo <shawnguo@...nel.org>, Lee Jones <lee@...nel.org>, devicetree@...r.kernel.org,
linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 4/9] gpio: regmap: add the .fixed_direction_output
configuration parameter
On Mon, 15 Sep 2025 14:45:58 +0200, Michael Walle <mwalle@...nel.org> said:
> Hi Ioana,
>
> On Mon Sep 15, 2025 at 2:23 PM CEST, Ioana Ciornei wrote:
>> There are GPIO controllers such as the one present in the LX2160ARDB
>> QIXIS FPGA which have fixed-direction input and output GPIO lines mixed
>> together in a single register. This cannot be modeled using the
>> gpio-regmap as-is since there is no way to present the true direction of
>> a GPIO line.
>>
>> In order to make this use case possible, add a new configuration
>> parameter - fixed_direction_output - into the gpio_regmap_config
>> structure. This will enable user drivers to provide a bitmap that
>> represents the fixed direction of the GPIO lines.
>
> I wonder about the ownership of that allocated memory in the config
> structure (and btw, I guess you leak the memory in your driver) and
> if it's not better and more error proof to allocate and copy the
> bitmap in gpio-regmap too (and maybe use devm_bitmap_alloc()) and
> leave it to the caller to handle the passed bitmap. I.e. it could
> also be on the stack.
>
I was under the impression that whatever is in the config structure for GPIO
regmap init function is only required to stay alive until that call returns?
If so, then yes, a deep copy of everything from this structure is required.
> Otherwise, this looks good.
>
[snip]
>>
>> + if (offset >= chip->ngpio)
>> + return -EINVAL;
>
> Not sure this can happen. I tried to look into gpiolib.c but
> couldn't find anything obvious that it can't happen. Maybe Linus or
> Bartosz can comment on that.
>
Indeed, this is handed by GPIO core, please drop it.
[snip]
Bartosz
Powered by blists - more mailing lists