staging: media: tegra-video: prefer using the BIT macro
Subsystems (4)
PATCH 1/1 staging: media: tegra-video: prefer using the BIT macro
Replace open-coded bit shifts (1 << 28) with the standard kernel BIT macro. This improves code uniformity, matches style guidelines, and prevents accidental signed overflow issues.
--- drivers/staging/media/tegra-video/tegra20.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/tegra-video/tegra20.c +1 -1
@@ -177,7 +177,7 @@ enum tegra_vi_out {#define CSI_SKIP_PACKET_THRESHOLD (n) (((n) & 0xff) << 16)#define TEGRA_CSI_PIXEL_STREAM_CONTROL0 (n) (0x0018 + (n) * 0x2c)#define CSI_PP_PAD_FRAME_PAD0S (0 << 28) -#define CSI_PP_PAD_FRAME_PAD1S (1 << 28) +#define CSI_PP_PAD_FRAME_PAD1S BIT(28)#define CSI_PP_PAD_FRAME_NOPAD (2 << 28)#define CSI_PP_HEADER_EC_ENABLE BIT(27)#define CSI_PP_PAD_SHORT_LINE_PAD0S (0 << 24)
Signature · 1 line
2.43.0
Quoted 3 lines · Diego Fernando Mancera Gómez
Replace open-coded bit shifts (1 << 28) with the standard kernel BIT macro. This improves code uniformity, matches style guidelines, and prevents accidental signed overflow issues.
It doesn't prevent any "accidental signed overflow issues".
Quoted 11 lines
Signed-off-by Diego Fernando Mancera Gómez <[email protected]>--- drivers/staging/media/tegra-video/tegra20.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/media/tegra-video/tegra20.c +0
-0
drivers/staging/media/tegra-video/tegra20.c enum tegra_vi_out { · line 181
Quoted 6 lines
drivers/staging/media/tegra-video/tegra20.c +1
-1@@ -177,7 +177,7 @@ enum tegra_vi_out {#define CSI_SKIP_PACKET_THRESHOLD (n) (((n) & 0xff) << 16)#define TEGRA_CSI_PIXEL_STREAM_CONTROL0 (n) (0x0018 + (n) * 0x2c)#define CSI_PP_PAD_FRAME_PAD0S (0 << 28) -#define CSI_PP_PAD_FRAME_PAD1S (1 << 28) +#define CSI_PP_PAD_FRAME_PAD1S BIT(28)#define CSI_PP_PAD_FRAME_NOPAD (2 << 28)
This change makes the code less readable. There are two bits, 28 and 29 and they mean something. 0 meand pad0, 1 means pad1, and 2 means no pad. The patch jumbles the pattern.
regards,
dan carpenter
Hi Dan,
Thank you for the clear explanation. You are absolutely right; I completely missed the sequential pattern of the values being shifted into that register field, and using BIT() there obscures the logic.
I also appreciate the correction on the commit message regarding the signed overflow.
I will drop this patch. Thanks for taking the time to review it.
Best regards,
Diego