public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Thomas Richard <thomas.richard@bootlin.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	thomas.petazzoni@bootlin.com, DanieleCleri@aaeon.eu,
	GaryWang@aaeon.com.tw
Subject: Re: [PATCH v3 04/10] gpio: aggregator: refactor the code to add GPIO desc in the forwarder
Date: Thu, 17 Apr 2025 20:16:49 +0300	[thread overview]
Message-ID: <aAE3gRH08WuuIFai@smile.fi.intel.com> (raw)
In-Reply-To: <20250416-aaeon-up-board-pinctrl-support-v3-4-f40776bd06ee@bootlin.com>

On Wed, Apr 16, 2025 at 04:08:12PM +0200, Thomas Richard wrote:
> Create a dedicated function to add a GPIO desc in the forwarder. Instead of
> passing an array of GPIO desc, now the GPIO desc are passed on by one to
> the forwarder.

...

> +static int gpiochip_fwd_add_gpio_desc(struct gpiochip_fwd *fwd,
> +				      struct gpio_desc *desc,
> +				      unsigned int offset)
> +{
> +	struct gpio_chip *parent = gpiod_to_chip(desc);
> +	struct gpio_chip *chip = &fwd->chip;
> +
> +	if (offset > chip->ngpio)

>= ?

> +		return -EINVAL;

> +	if (fwd->descs[offset])
> +		return -EEXIST;

Not sure we need this. I would rather think that something inside struct
gpiochip_fwd should track this. OTOH, I understand that you want to have
sparse lists perhaps. I;m wondering why GPIO valid mask can't be used for
this purposes?

> +	/*
> +	 * If any of the GPIO lines are sleeping, then the entire forwarder
> +	 * will be sleeping.
> +	 * If any of the chips support .set_config(), then the forwarder will
> +	 * support setting configs.
> +	 */
> +	if (gpiod_cansleep(desc))
> +		chip->can_sleep = true;
> +
> +	if (parent && parent->set_config)
> +		chip->set_config = gpio_fwd_set_config;
> +
> +	fwd->descs[offset] = desc;
> +
> +	dev_dbg(chip->parent, "%u => gpio %d irq %d\n", offset,
> +		desc_to_gpio(desc), gpiod_to_irq(desc));
> +
> +	return 0;
> +}

The bottom line is that I'm fine with this change without additional checks,
add them when function will be used not only in the original loop.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-04-17 17:16 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 14:08 [PATCH v3 00/10] Add pinctrl support for the AAEON UP board FPGA Thomas Richard
2025-04-16 14:08 ` [PATCH v3 01/10] gpiolib: add support to register sparse pin range Thomas Richard
2025-04-17  7:53   ` Linus Walleij
2025-04-17 16:54   ` Andy Shevchenko
2025-04-16 14:08 ` [PATCH v3 02/10] pinctrl: core: add devm_pinctrl_register_mappings() Thomas Richard
2025-04-17  7:54   ` Linus Walleij
2025-04-17 16:07   ` kernel test robot
2025-04-17 16:13   ` Andy Shevchenko
2025-04-17 16:39   ` kernel test robot
2025-04-16 14:08 ` [PATCH v3 03/10] gpio: aggregator: move GPIO forwarder allocation in a dedicated function Thomas Richard
2025-04-17 16:56   ` Andy Shevchenko
2025-04-16 14:08 ` [PATCH v3 04/10] gpio: aggregator: refactor the code to add GPIO desc in the forwarder Thomas Richard
2025-04-17 17:16   ` Andy Shevchenko [this message]
2025-04-18 10:07     ` Thomas Richard
2025-04-16 14:08 ` [PATCH v3 05/10] gpio: aggregator: refactor the forwarder registration part Thomas Richard
2025-04-17 17:18   ` Andy Shevchenko
2025-04-16 14:08 ` [PATCH v3 06/10] gpio: aggregator: update gpiochip_fwd_setup_delay_line() parameters Thomas Richard
2025-04-17 17:23   ` Andy Shevchenko
2025-04-16 14:08 ` [PATCH v3 07/10] gpio: aggregator: export symbols of the GPIO forwarder library Thomas Richard
2025-04-17 17:33   ` Andy Shevchenko
2025-04-16 14:08 ` [PATCH v3 08/10] gpio: aggregator: handle runtime registration of gpio_desc in gpiochip_fwd Thomas Richard
2025-04-17 17:38   ` Andy Shevchenko
2025-04-17 17:40     ` Andy Shevchenko
2025-04-16 14:08 ` [PATCH v3 09/10] gpio: aggregator: add possibility to attach data to the forwarder Thomas Richard
2025-04-17 17:43   ` Andy Shevchenko
2025-04-16 14:08 ` [PATCH v3 10/10] pinctrl: Add pin controller driver for AAEON UP boards Thomas Richard
2025-04-17  7:57   ` Linus Walleij
2025-04-17 18:00   ` Andy Shevchenko
2025-04-22 14:36     ` Thomas Richard
2025-04-22 15:24       ` Andy Shevchenko
2025-04-18 21:45   ` kernel test robot
2025-04-17 18:02 ` [PATCH v3 00/10] Add pinctrl support for the AAEON UP board FPGA Andy Shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2025-04-16 13:59 Thomas Richard
2025-04-16 13:59 ` [PATCH v3 04/10] gpio: aggregator: refactor the code to add GPIO desc in the forwarder Thomas Richard

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=aAE3gRH08WuuIFai@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=DanieleCleri@aaeon.eu \
    --cc=GaryWang@aaeon.com.tw \
    --cc=brgl@bgdev.pl \
    --cc=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=thomas.richard@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