[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e1bb879a-55b3-43fc-8d2d-67401c21ef76@bootlin.com>
Date: Tue, 22 Apr 2025 16:36:33 +0200
From: Thomas Richard <thomas.richard@...tlin.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Geert Uytterhoeven <geert+renesas@...der.be>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, thomas.petazzoni@...tlin.com,
DanieleCleri@...on.eu, GaryWang@...on.com.tw
Subject: Re: [PATCH v3 10/10] pinctrl: Add pin controller driver for AAEON UP
boards
>> +static int upboard_gpio_request(struct gpio_chip *gc, unsigned int offset)
>> +{
>> + struct gpiochip_fwd *fwd = container_of(gc, struct gpiochip_fwd, chip);
>> + struct upboard_pinctrl *pctrl = fwd->data;
>
> Yeah, something like
>
> struct upboard_pinctrl *pctrl = gpio_fwd_get_data(fwd);
>
>> + unsigned int pin = pctrl->pctrl_data->pin_header[offset];
>> + struct gpio_desc *desc;
>> + int ret;
>> +
>> + ret = pinctrl_gpio_request(gc, offset);
>> + if (ret)
>> + return ret;
>
>> + /* GPIO desc is already registered */
>> + if (fwd->descs[offset])
>> + return 0;
>
> As mentioned in another reply, why 0 and even though, why can't it be simply
> filtered by EEXIST from the below?
>
> In worst scenario, you can add an API gpio_fwd_is_registered(fwd, offset).
I cannot filter using EEXIST, because I have to get the GPIO desc first.
And using the retcode of gpiod_get_index() I cannot detect that I
already requested the GPIO.
As now gpiochip_fwd is an opaque pointer, I will add the
gpio_fwd_is_registered() helper.
It is due to the fact that the forwarder never releases a GPIO desc. An
other solution could be to add the possibility to remove a GPIO desc.
In upboard_gpio_free() the GPIO desc is free, and we can remove the check.
upboard_gpio_free()
{
gpio_fwd_free_desc(fwd, offset);
pinctrl_gpio_free(gc, offset);
}
Best Regards,
Thomas
Powered by blists - more mailing lists