[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5030b353-85ba-40d7-9b87-619787d99061@bootlin.com>
Date: Mon, 12 May 2025 17:33:53 +0200
From: Thomas Richard <thomas.richard@...tlin.com>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Bartosz Golaszewski <brgl@...ev.pl>, Kees Cook <kees@...nel.org>,
Andy Shevchenko <andy@...nel.org>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, thomas.petazzoni@...tlin.com,
DanieleCleri@...on.eu, GaryWang@...on.com.tw, linux-hardening@...r.kernel.org
Subject: Re: [PATCH v5 08/12] gpio: aggregator: export symbols of the GPIO
forwarder library
On 5/12/25 17:14, Geert Uytterhoeven wrote:
> Hi Thomas,
>
> On Mon, 12 May 2025 at 17:01, Thomas Richard <thomas.richard@...tlin.com> wrote:
>> On 5/12/25 16:39, Geert Uytterhoeven wrote:
>>> On Mon, 12 May 2025 at 16:08, Thomas Richard <thomas.richard@...tlin.com> wrote:
>>>> On 5/9/25 11:07, Geert Uytterhoeven wrote:
>>>>> On Tue, 6 May 2025 at 17:21, Thomas Richard <thomas.richard@...tlin.com> wrote:
>>>>>> Export all symbols and create header file for the GPIO forwarder library.
>>>>>> It will be used in the next changes.
>>>>>>
>>>>>> Signed-off-by: Thomas Richard <thomas.richard@...tlin.com>
>>>>
>>>> ...
>>>>
>>>>>> +
>>>>>> +int gpio_fwd_set_config(struct gpio_chip *chip, unsigned int offset,
>>>>>> + unsigned long config);
>>>>>> +
>>>>>> +int gpio_fwd_to_irq(struct gpio_chip *chip, unsigned int offset);
>>>>>
>>>>> I would expect all of these to take gpiochip_fwd pointers instead of
>>>>> gpio_chip pointers. What prevents you from passing a gpio_chip pointer
>>>>> that does not correspond to a gpiochip_fwd object, causing a crash?
>>>>
>>>> Indeed nothing prevents from passing gpio_chip pointer which does not
>>>> correspond to a gpiochip_fwd object.
>>>> And it is also a bit weird to pass a gpiochip_fwd pointer in some cases
>>>> (for example gpio_fwd_gpio_add()) and a gpio_chip in other cases.
>>>>
>>>> I can keep GPIO operations as is, and create exported wrappers which
>>>> take a gpiochip_fwd pointer as parameter, for example:
>>>>
>>>> int gpiochip_fwd_get_multiple(struct gpiochip_fwd *fwd,
>>>> unsigned long *mask,
>>>> unsigned long *bits)
>>>> {
>>>> struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd);
>>>>
>>>> return gpio_fwd_get_multiple_locked(chip, mask, bits);
>>>> }
>>>> EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_get_multiple, "GPIO_FORWARDER");
>>>>
>>>> So exported functions are gpiochip_fwd_*().
>>>
>>> That sounds fine to me.
>>>
>>> BTW, do you need to use these functions as gpio_chip callbacks?
>>> If that is the case, they do no need to take struct gpio_chip pointers.
>>>
>> I'm not sure to understand the question, or the idea behind the question.
>
> Do users of the forwarder library want to use these functions directly
> as callbacks in their own gpiochip?
> E.g. do they want to use:
>
> chip->get_multiple_rv = gpiochip_fwd_get_multiple;
>
> I hope my question is more clear now.
Oh ok I understand now.
The answer is no (gpiochip_fwd_get_multiple() is already by default the
get_multiple_rv operation of the forwarder).
My use case (patch 12/12) is:
I have a pinctrl driver (for a FPGA) which registers a gpiochip_fwd. The
driver has to drive in tandem its configuration and SoC GPIOs (which are
added in the gpiochip_fwd).
During the probe, the driver will change gpiochip operation to use its
own operation.
gc = gpiochip_fwd_get_gpiochip(fwd)
gc->direction_input = my_direction_input;
This function does some custom things and them call
gpiochip_fwd_gpio_direction_input().
my_direction_input()
{
do_something()
gpiochip_fwd_gpio_direction_input()
}
It allows you to add custom action before/after default operation.
Regards,
Thomas
Powered by blists - more mailing lists