Skip to contentSkip to conversation

staging: media: atomisp: Use GENMASK instead of manual masking

PATCH In review Moses Christopher Bollavarapu 2 participants 2 messages Feb 6, 2022 – Feb 7, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: media: atomisp: Use GENMASK instead of manual masking

There is a GENMASK macro available in linux/bits.h, for masking.

Example: GENMASK(3, 0) = 0b00001111 (same as (1 << 4) - 1)

---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +4 -3
index 1173be0e72b0..a345fa1d7de9 100644
@@ -40,6 +40,7 @@
 
 #include <linux/io.h>
 #include <linux/pm_runtime.h>
+#include <linux/bits.h>
 
 /* Assume max number of ACC stages */
 #define MAX_ACC_STAGES	20
@@ -1913,11 +1914,11 @@ void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
 			    &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_config;
 		s_config->mode = IA_CSS_INPUT_MODE_TPG;
 		s_config->source.tpg.mode = IA_CSS_TPG_MODE_CHECKERBOARD;
-		s_config->source.tpg.x_mask = (1 << 4) - 1;
+		s_config->source.tpg.x_mask = GENMASK(3, 0);
 		s_config->source.tpg.x_delta = -2;
-		s_config->source.tpg.y_mask = (1 << 4) - 1;
+		s_config->source.tpg.y_mask = GENMASK(3, 0);
 		s_config->source.tpg.y_delta = 3;
-		s_config->source.tpg.xy_mask = (1 << 8) - 1;
+		s_config->source.tpg.xy_mask = GENMASK(7, 0);
 		return;
 	}
 
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Moses Christopher Bollavarapu

There is a GENMASK macro available in linux/bits.h, for masking.

Example: GENMASK(3, 0) = 0b00001111 (same as (1 << 4) - 1)

Quoted 10 lines
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -0
index 1173be0e72b0..a345fa1d7de9 100644

drivers/staging/media/atomisp/pci/atomisp_compat_css20.c line 44

Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +1 -0
@@ -40,6 +40,7 @@
 
 #include <linux/io.h>
 #include <linux/pm_runtime.h>
 
+#include <linux/bits.h>

Probably this can be still ordered.

Quoted 20 lines
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +3 -3
 /* Assume max number of ACC stages */
 #define MAX_ACC_STAGES	20
@@ -1913,11 +1914,11 @@ void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
 			    &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_config;
 		s_config->mode = IA_CSS_INPUT_MODE_TPG;
 		s_config->source.tpg.mode = IA_CSS_TPG_MODE_CHECKERBOARD;
-		s_config->source.tpg.x_mask = (1 << 4) - 1;
+		s_config->source.tpg.x_mask = GENMASK(3, 0);
 		s_config->source.tpg.x_delta = -2;
-		s_config->source.tpg.y_mask = (1 << 4) - 1;
+		s_config->source.tpg.y_mask = GENMASK(3, 0);
 		s_config->source.tpg.y_delta = 3;
-		s_config->source.tpg.xy_mask = (1 << 8) - 1;
+		s_config->source.tpg.xy_mask = GENMASK(7, 0);
 		return;
 	}
 
Signature · 1 line
2.30.2
Signature · 2 lines
With Best Regards,
Andy Shevchenko