staging: tegra-video: replace bit shifts with BIT() macro
Subsystems (4)
PATCH 1/1 staging: tegra-video: replace bit shifts with BIT() macro
Replace manual bit shifts with the BIT() macro to follow kernel coding style and improve readability.
Fixes the following checkpatch warning:
CHECK: Prefer using the BIT macro
--- drivers/staging/media/tegra-video/tegra20.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/tegra-video/tegra20.c +3 -3
@@ -177,15 +177,15 @@ 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) -#define CSI_PP_PAD_SHORT_LINE_PAD1S (1 << 24) +#define CSI_PP_PAD_SHORT_LINE_PAD1S BIT(24)#define CSI_PP_PAD_SHORT_LINE_NOPAD (2 << 24)#define CSI_PP_EMBEDDED_DATA_EMBEDDED BIT(20)#define CSI_PP_OUTPUT_FORMAT_ARBITRARY (0 << 16) -#define CSI_PP_OUTPUT_FORMAT_PIXEL (1 << 16) +#define CSI_PP_OUTPUT_FORMAT_PIXEL BIT(16)#define CSI_PP_OUTPUT_FORMAT_PIXEL_REP (2 << 16)#define CSI_PP_OUTPUT_FORMAT_STORE (3 << 16)#define CSI_PP_VIRTUAL_CHANNEL_ID (n) (((n) - 1) << 14)
Signature · 1 line
2.43.0
Luca Ceresoli
maintainerQuoted 25 lines · On Tue Apr 28, 2026 at 6:33 PM CEST, Mhanna112-code wrote:
Replace manual bit shifts with the
BIT()macro to follow kernel coding style and improve readability.Fixes the following checkpatch warning:
CHECK: Prefer using the BIT macro
Signed-off-by Marc Hanna <[email protected]>--- drivers/staging/media/tegra-video/tegra20.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/staging/media/tegra-video/tegra20.c +1
-1@@ -177,15 +177,15 @@ 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)
drivers/staging/media/tegra-video/tegra20.c enum tegra_vi_out { · line 191
Quoted 10 lines
drivers/staging/media/tegra-video/tegra20.c +2
-2-#define CSI_PP_PAD_SHORT_LINE_PAD1S (1 << 24) +#define CSI_PP_PAD_SHORT_LINE_PAD1S BIT(24)#define CSI_PP_PAD_SHORT_LINE_NOPAD (2 << 24)#define CSI_PP_EMBEDDED_DATA_EMBEDDED BIT(20)#define CSI_PP_OUTPUT_FORMAT_ARBITRARY (0 << 16) -#define CSI_PP_OUTPUT_FORMAT_PIXEL (1 << 16) +#define CSI_PP_OUTPUT_FORMAT_PIXEL BIT(16)#define CSI_PP_OUTPUT_FORMAT_PIXEL_REP (2 << 16)#define CSI_PP_OUTPUT_FORMAT_STORE (3 << 16)#define CSI_PP_VIRTUAL_CHANNEL_ID (n) (((n) - 1) << 14)
I think this change would make code worse, not better. These look like enum-like values for 2-bit register fields, and as such should be described the same way for readability.
If we want to change them they should perhaps use a GENMASK or similar, but it probably makes sense to just leave them as is. They are mostly unused anyway.
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com