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: <fiplj5dgokc5syrahjoddwm3lw3vdweg3axi5xcof4qfr6bdo4@yhcnph6lx7zz>
Date: Sun, 6 Apr 2025 22:12:18 +0200
From: Marek BehĂșn <kabel@...nel.org>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Marek BehĂșn <kabel@...nel.org>, 
	Arnd Bergmann <arnd@...db.de>, Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, 
	Al Viro <viro@...iv.linux.org.uk>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] platform: turris: use ffs() instead of __bf_shf()

On Fri, Apr 04, 2025 at 03:55:26PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@...db.de>
> 
> __bf_shf() on a 64-bit variable causes a link failure during
> compile-testing:
> 
> drivers-platform-cznic-turris-omnia-mcu-gpio.c:(.text):undefined-reference-to-__ffsdi2
> 
> Open-code this using ffs()-1, which has the same result but avoids
> the library call.
> 
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  drivers/platform/cznic/turris-omnia-mcu-gpio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/cznic/turris-omnia-mcu-gpio.c b/drivers/platform/cznic/turris-omnia-mcu-gpio.c
> index 932383f7491a..c2df24ea8686 100644
> --- a/drivers/platform/cznic/turris-omnia-mcu-gpio.c
> +++ b/drivers/platform/cznic/turris-omnia-mcu-gpio.c
> @@ -1104,7 +1104,7 @@ int omnia_mcu_request_irq(struct omnia_mcu *mcu, u32 spec,
>  	if (!spec)
>  		return -EINVAL;
>  
> -	irq_idx = omnia_int_to_gpio_idx[__bf_shf(spec)];
> +	irq_idx = omnia_int_to_gpio_idx[ffs(spec) - 1];

Weird that __bf_shf() procudes this error on non-constant input.
But I guess a variant of ffs() makes more sense semantically, since the
spec arugment isn't semantically a bitfield.

Shouldn't we consider using __ffs(), though?

With __ffs() we can drop the "- 1", i.e.:
	irq_idx = omnia_int_to_gpio_idx[__ffs(spec)];

Both __ffs() and ffs() are used within the drivers/ subdir.
Of the 649 usages of ffs(), 482 are ffs(x) - 1, so they could be
converted to __ffs(x).

But I don't particularly care.

Marek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ