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] [day] [month] [year] [list]
Message-ID: <20250725100943.0a974c7c@booty>
Date: Fri, 25 Jul 2025 10:09:43 +0200
From: Luca Ceresoli <luca.ceresoli@...tlin.com>
To: "A.T. Jefferies" <alextjefferies@...il.com>
Cc: thierry.reding@...il.com, jonathanh@...dia.com, skomatineni@...dia.com,
 mchehab@...nel.org, gregkh@...uxfoundation.org,
 linux-media@...r.kernel.org, linux-tegra@...r.kernel.org,
 linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: media: tegra-video: use BIT() macro instead of
 shift

Hello A.T. Jefferies,

On Wed, 23 Jul 2025 23:17:57 +0000
"A.T. Jefferies" <alextjefferies@...il.com> wrote:

> Replace two instances of (1 << X) with BIT(X) in tegra20.c to follow
> kernel coding style guidelines and improve clarity. The BIT() macro
> also ensures proper type handling for larger shifts.
> 
> Signed-off-by: A.T. Jefferies <alextjefferies@...il.com>
> ---
>  drivers/staging/media/tegra-video/tegra20.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c
> index 7b8f8f810b35..1473f1b1f203 100644
> --- a/drivers/staging/media/tegra-video/tegra20.c
> +++ b/drivers/staging/media/tegra-video/tegra20.c
> @@ -42,7 +42,7 @@
>  #define       VI_INPUT_BT656				BIT(25)
>  #define       VI_INPUT_YUV_INPUT_FORMAT_SFT		8  /* bits [9:8] */
>  #define       VI_INPUT_YUV_INPUT_FORMAT_UYVY		(0 << VI_INPUT_YUV_INPUT_FORMAT_SFT)
> -#define       VI_INPUT_YUV_INPUT_FORMAT_VYUY		(1 << VI_INPUT_YUV_INPUT_FORMAT_SFT)
> +#define       VI_INPUT_YUV_INPUT_FORMAT_VYUY		BIT(VI_INPUT_YUV_INPUT_FORMAT_SFT)
>  #define       VI_INPUT_YUV_INPUT_FORMAT_YUYV		(2 << VI_INPUT_YUV_INPUT_FORMAT_SFT)
>  #define       VI_INPUT_YUV_INPUT_FORMAT_YVYU		(3 << VI_INPUT_YUV_INPUT_FORMAT_SFT)

Thanks for your patch. However I'm afraid I don't think this is a good
idea. 1 is just one out of 4 possible values out of 4 possible values
for a multi-bit register field. All the 4 should use the same style.

BIT() is perfect for single-bit register fields. It's not for multi-bit
fields.

Luca

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ