From: Thomas Richard <thomas.richard@bootlin.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Bartosz Golaszewski <brgl@bgdev.pl>, Kees Cook <kees@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
thomas.petazzoni@bootlin.com, DanieleCleri@aaeon.eu,
GaryWang@aaeon.com.tw, linux-hardening@vger.kernel.org
Subject: Re: [PATCH v5 08/12] gpio: aggregator: export symbols of the GPIO forwarder library
Date: Mon, 12 May 2025 17:33:53 +0200 [thread overview]
Message-ID: <5030b353-85ba-40d7-9b87-619787d99061@bootlin.com> (raw)
In-Reply-To: <CAMuHMdUMVFk+-3akj6nj+XCya9zj_FqkbnpOT1Wc4wSsgttiww@mail.gmail.com>
On 5/12/25 17:14, Geert Uytterhoeven wrote:
> Hi Thomas,
>
> On Mon, 12 May 2025 at 17:01, Thomas Richard <thomas.richard@bootlin.com> wrote:
>> On 5/12/25 16:39, Geert Uytterhoeven wrote:
>>> On Mon, 12 May 2025 at 16:08, Thomas Richard <thomas.richard@bootlin.com> wrote:
>>>> On 5/9/25 11:07, Geert Uytterhoeven wrote:
>>>>> On Tue, 6 May 2025 at 17:21, Thomas Richard <thomas.richard@bootlin.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@bootlin.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
next prev parent reply other threads:[~2025-05-12 15:33 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 15:21 [PATCH v5 00/12] Add pinctrl support for the AAEON UP board FPGA Thomas Richard
2025-05-06 15:21 ` [PATCH v5 01/12] gpiolib: add support to register sparse pin range Thomas Richard
2025-05-07 17:49 ` kernel test robot
2025-05-06 15:21 ` [PATCH v5 02/12] pinctrl: remove extern specifier for functions in machine.h Thomas Richard
2025-05-13 12:59 ` Linus Walleij
2025-05-06 15:21 ` [PATCH v5 03/12] pinctrl: core: add devm_pinctrl_register_mappings() Thomas Richard
2025-05-06 15:21 ` [PATCH v5 04/12] gpio: aggregator: move GPIO forwarder allocation in a dedicated function Thomas Richard
2025-05-09 8:05 ` Geert Uytterhoeven
2025-05-06 15:21 ` [PATCH v5 05/12] gpio: aggregator: refactor the code to add GPIO desc in the forwarder Thomas Richard
2025-05-07 6:22 ` Andy Shevchenko
2025-05-09 8:38 ` Geert Uytterhoeven
2025-05-09 8:43 ` Geert Uytterhoeven
2025-05-06 15:21 ` [PATCH v5 06/12] gpio: aggregator: refactor the forwarder registration part Thomas Richard
2025-05-09 8:50 ` Geert Uytterhoeven
2025-05-06 15:21 ` [PATCH v5 07/12] gpio: aggregator: update gpiochip_fwd_setup_delay_line() parameters Thomas Richard
2025-05-09 8:53 ` Geert Uytterhoeven
2025-05-06 15:21 ` [PATCH v5 08/12] gpio: aggregator: export symbols of the GPIO forwarder library Thomas Richard
2025-05-07 6:29 ` Andy Shevchenko
2025-05-07 14:53 ` Thomas Richard
2025-05-07 15:21 ` Andy Shevchenko
2025-05-07 15:23 ` Andy Shevchenko
2025-05-07 15:29 ` Thomas Richard
2025-05-08 7:23 ` Geert Uytterhoeven
2025-05-09 9:07 ` Geert Uytterhoeven
2025-05-12 14:08 ` Thomas Richard
2025-05-12 14:11 ` Andy Shevchenko
2025-05-12 14:30 ` Thomas Richard
2025-05-12 14:42 ` Geert Uytterhoeven
2025-05-12 14:39 ` Geert Uytterhoeven
2025-05-12 15:00 ` Thomas Richard
2025-05-12 15:14 ` Geert Uytterhoeven
2025-05-12 15:33 ` Thomas Richard [this message]
2025-05-06 15:21 ` [PATCH v5 09/12] gpio: aggregator: handle runtime registration of gpio_desc in gpiochip_fwd Thomas Richard
2025-05-07 6:34 ` Andy Shevchenko
2025-05-07 10:10 ` Thomas Richard
2025-05-07 13:24 ` Andy Shevchenko
2025-05-07 13:54 ` Thomas Richard
2025-05-07 15:24 ` Andy Shevchenko
2025-05-09 13:33 ` Bartosz Golaszewski
2025-05-09 9:29 ` Geert Uytterhoeven
2025-05-06 15:21 ` [PATCH v5 10/12] gpio: aggregator: add possibility to attach data to the forwarder Thomas Richard
2025-05-09 9:32 ` Geert Uytterhoeven
2025-05-06 15:21 ` [PATCH v5 11/12] lib/string_choices: Add str_input_output() helper Thomas Richard
2025-05-06 15:21 ` [PATCH v5 12/12] pinctrl: Add pin controller driver for AAEON UP boards Thomas Richard
2025-05-07 6:57 ` Andy Shevchenko
2025-05-07 13:34 ` Thomas Richard
2025-05-07 6:59 ` [PATCH v5 00/12] Add pinctrl support for the AAEON UP board FPGA Andy Shevchenko
2025-05-13 13:02 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5030b353-85ba-40d7-9b87-619787d99061@bootlin.com \
--to=thomas.richard@bootlin.com \
--cc=DanieleCleri@aaeon.eu \
--cc=GaryWang@aaeon.com.tw \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=brgl@bgdev.pl \
--cc=geert@linux-m68k.org \
--cc=kees@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox