The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] staging: media: atomisp: Use ARRAY_SIZE macro
@ 2026-08-13  2:03 Rishab Madhugiri
  2026-08-13  7:16 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Rishab Madhugiri @ 2026-08-13  2:03 UTC (permalink / raw)
  To: hansg, mchehab, gregkh
  Cc: andy, sakari.ailus, linux-staging, linux-media, linux-kernel,
	Rishab Madhugiri

Clean up loop bound calculation by replacing sizeof(bds_factors) /
sizeof(struct bayer_ds_factor) with the ARRAY_SIZE() helper macro
to improve readability and maintainability.

Signed-off-by: Rishab Madhugiri <rishab.madhugiri@gmail.com>
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
index 0ee52637e..83519dd8a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
@@ -2160,7 +2160,7 @@ static void __configure_video_pp_input(struct atomisp_sub_device *asd,
 	bayer_ds_out_res->width = effective_res->width;
 	bayer_ds_out_res->height = effective_res->height;
 
-	for (i = 0; i < sizeof(bds_factors) / sizeof(struct bayer_ds_factor);
+	for (i = 0; i < ARRAY_SIZE(bds_factors);
 	     i++) {
 		if (effective_res->width >= out_width *
 		    bds_factors[i].numerator / bds_factors[i].denominator &&
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: media: atomisp: Use ARRAY_SIZE macro
  2026-08-13  2:03 [PATCH] staging: media: atomisp: Use ARRAY_SIZE macro Rishab Madhugiri
@ 2026-08-13  7:16 ` Dan Carpenter
  2026-08-13  7:55   ` [PATCH v2] " Rishab Madhugiri
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2026-08-13  7:16 UTC (permalink / raw)
  To: Rishab Madhugiri
  Cc: hansg, mchehab, gregkh, andy, sakari.ailus, linux-staging,
	linux-media, linux-kernel

On Thu, Aug 13, 2026 at 02:03:54AM +0000, Rishab Madhugiri wrote:
> Clean up loop bound calculation by replacing sizeof(bds_factors) /
> sizeof(struct bayer_ds_factor) with the ARRAY_SIZE() helper macro
> to improve readability and maintainability.
> 
> Signed-off-by: Rishab Madhugiri <rishab.madhugiri@gmail.com>
> ---
>  drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> index 0ee52637e..83519dd8a 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> @@ -2160,7 +2160,7 @@ static void __configure_video_pp_input(struct atomisp_sub_device *asd,
>  	bayer_ds_out_res->width = effective_res->width;
>  	bayer_ds_out_res->height = effective_res->height;
>  
> -	for (i = 0; i < sizeof(bds_factors) / sizeof(struct bayer_ds_factor);
> +	for (i = 0; i < ARRAY_SIZE(bds_factors);
>  	     i++) {

The i++ fits on that line now, so move it up as well.

regards,
dan carpenter

>  		if (effective_res->width >= out_width *
>  		    bds_factors[i].numerator / bds_factors[i].denominator &&
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] staging: media: atomisp: Use ARRAY_SIZE macro
  2026-08-13  7:16 ` Dan Carpenter
@ 2026-08-13  7:55   ` Rishab Madhugiri
  2026-08-13  8:15     ` Dan Carpenter
  2026-08-13  9:44     ` Andy Shevchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Rishab Madhugiri @ 2026-08-13  7:55 UTC (permalink / raw)
  To: hansg, mchehab, gregkh
  Cc: dan.carpenter, andy, sakari.ailus, linux-staging, linux-media,
	linux-kernel, Rishab Madhugiri

Clean up loop bound calculation by replacing sizeof(bds_factors) /
sizeof(struct bayer_ds_factor) with the ARRAY_SIZE() helper macro
to improve readability and maintainability.

v2: Move loop increment to the same line as the for statement as requested.

Signed-off-by: Rishab Madhugiri <rishab.madhugiri@gmail.com>
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
index 0ee52637e..e8734ca1a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
@@ -2160,8 +2160,7 @@ static void __configure_video_pp_input(struct atomisp_sub_device *asd,
 	bayer_ds_out_res->width = effective_res->width;
 	bayer_ds_out_res->height = effective_res->height;
 
-	for (i = 0; i < sizeof(bds_factors) / sizeof(struct bayer_ds_factor);
-	     i++) {
+	for (i = 0; i < ARRAY_SIZE(bds_factors); i++) {
 		if (effective_res->width >= out_width *
 		    bds_factors[i].numerator / bds_factors[i].denominator &&
 		    effective_res->height >= out_height *
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] staging: media: atomisp: Use ARRAY_SIZE macro
  2026-08-13  7:55   ` [PATCH v2] " Rishab Madhugiri
@ 2026-08-13  8:15     ` Dan Carpenter
  2026-08-13  9:44     ` Andy Shevchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2026-08-13  8:15 UTC (permalink / raw)
  To: Rishab Madhugiri
  Cc: hansg, mchehab, gregkh, dan.carpenter, andy, sakari.ailus,
	linux-staging, linux-media, linux-kernel

On Thu, Aug 13, 2026 at 07:55:29AM +0000, Rishab Madhugiri wrote:
> Clean up loop bound calculation by replacing sizeof(bds_factors) /
> sizeof(struct bayer_ds_factor) with the ARRAY_SIZE() helper macro
> to improve readability and maintainability.
> 
> v2: Move loop increment to the same line as the for statement as requested.
> 
> Signed-off-by: Rishab Madhugiri <rishab.madhugiri@gmail.com>
> ---

Thanks, but the v2 has to go below, also best to wait a day between
resends.

https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] staging: media: atomisp: Use ARRAY_SIZE macro
  2026-08-13  7:55   ` [PATCH v2] " Rishab Madhugiri
  2026-08-13  8:15     ` Dan Carpenter
@ 2026-08-13  9:44     ` Andy Shevchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-13  9:44 UTC (permalink / raw)
  To: Rishab Madhugiri
  Cc: hansg, mchehab, gregkh, dan.carpenter, andy, sakari.ailus,
	linux-staging, linux-media, linux-kernel

On Thu, Aug 13, 2026 at 07:55:29AM +0000, Rishab Madhugiri wrote:
> Clean up loop bound calculation by replacing sizeof(bds_factors) /
> sizeof(struct bayer_ds_factor) with the ARRAY_SIZE() helper macro
> to improve readability and maintainability.

> v2: Move loop increment to the same line as the for statement as requested.

This should go...

> Signed-off-by: Rishab Madhugiri <rishab.madhugiri@gmail.com>
> ---

...under here, so it won't be included into Git history.

...

> -	for (i = 0; i < sizeof(bds_factors) / sizeof(struct bayer_ds_factor);
> -	     i++) {
> +	for (i = 0; i < ARRAY_SIZE(bds_factors); i++) {

While at it, also consider

	for (unsigned int i = 0; i < ARRAY_SIZE(bds_factors); i++) {

and dropping the above definition since i is not used outside of the loop.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-13  9:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13  2:03 [PATCH] staging: media: atomisp: Use ARRAY_SIZE macro Rishab Madhugiri
2026-08-13  7:16 ` Dan Carpenter
2026-08-13  7:55   ` [PATCH v2] " Rishab Madhugiri
2026-08-13  8:15     ` Dan Carpenter
2026-08-13  9:44     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox