lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aAE8mY2YjWt4PB1o@smile.fi.intel.com>
Date: Thu, 17 Apr 2025 20:38:33 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Thomas Richard <thomas.richard@...tlin.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 08/10] gpio: aggregator: handle runtime registration
 of gpio_desc in gpiochip_fwd

On Wed, Apr 16, 2025 at 04:08:16PM +0200, Thomas Richard wrote:
> Add request() callback to check if the GPIO descriptor was well registered
> in the gpiochip_fwd before to use it. This is done to handle the case
> where GPIO descriptor is added at runtime in the forwarder.
> 
> If at least one GPIO descriptor was not added before the forwarder
> registration, we assume the forwarder can sleep as if a GPIO is added at
> runtime it may sleep.

...

> +int gpio_fwd_request(struct gpio_chip *chip, unsigned int offset)
> +{
> +	struct gpiochip_fwd *fwd = gpiochip_get_data(chip);
> +
> +	return fwd->descs[offset] ? 0 : -ENODEV;

ENODEV? Hmm... Why has that error code been chosen?

> +}

...

>  int gpio_fwd_register(struct gpiochip_fwd *fwd)
>  {
>  	struct gpio_chip *chip = &fwd->chip;
> +	unsigned int ndescs = 0, i;

Slightly better (from maintenance perspective) to decouple assignment as it's
not a standalone function that just counts them. So it means some code may
appear in between and in long-term someone might screw up with the initial
value for that.

>  	int error;

	ndescs = 0;

> +	for (i = 0; i < chip->ngpio; i++)
> +		if (fwd->descs[i])
> +			ndescs++;
> +
> +	/*
> +	 * Some gpio_desc were not registers. They will be registered at runtime

registered

> +	 * but we have to suppose they can sleep.
> +	 */
> +	if (ndescs != chip->ngpio)
> +		chip->can_sleep = true;

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ