mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: vimc: sensor: fix pixel_rate type to resolve do_div() warning
@ 2026-07-28  0:15 Faizel K B
  2026-07-28  8:02 ` Ricardo Ribalda
  0 siblings, 1 reply; 2+ messages in thread
From: Faizel K B @ 2026-07-28  0:15 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Kieran Bingham, Mauro Carvalho Chehab, Hans Verkuil,
	Ricardo Ribalda, linux-media, linux-kernel, Faizel K B,
	kernel test robot

vsensor->pixel_rate->val is a plain s32 field. Declaring the local
"pixel_rate" variable as u64 misrepresented its actual range and made
do_div()'s divisor look wider than the 32-bit division it actually
performs, which is exactly what the do_div() coccinelle check warns.
Revert pixel_rate back to its original s32 type to match
vsensor->pixel_rate->val, resolving the warning correctly.

Fixes: ec1e620b2454 ("media: vimc: sensor: Add pixel_rate,vblank and hblank configuration")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202604191731.10nxGZ92-lkp@intel.com/
Link: https://lore.kernel.org/lkml/CANiDSCs9s03DUjKwcPgDtZt2QJ4i0FGwab4zpEP+wCawagSC2Q@mail.gmail.com/
Signed-off-by: Faizel K B <faizel.kb@gmail.com>
---
 drivers/media/test-drivers/vimc/vimc-sensor.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/test-drivers/vimc/vimc-sensor.c b/drivers/media/test-drivers/vimc/vimc-sensor.c
index 83dcc9d61ee0..7cb544fdfddb 100644
--- a/drivers/media/test-drivers/vimc/vimc-sensor.c
+++ b/drivers/media/test-drivers/vimc/vimc-sensor.c
@@ -97,18 +97,14 @@ static void vimc_sensor_update_frame_timing(struct v4l2_subdev *sd,
 {
 	struct vimc_sensor_device *vsensor =
 		container_of(sd, struct vimc_sensor_device, sd);
-	u64 pixel_rate = vsensor->pixel_rate->val;
+	u32 pixel_rate = vsensor->pixel_rate->val;
 	u32 hts = width + vsensor->hblank->val;
 	u32 vts = height + vsensor->vblank->val;
 	u64 total_pixels = (u64)hts * vts;
 	u64 frame_interval_ns;
 
-	/* Sanity check, pixel rate is fixed and fits in 32 bits. */
-	if (WARN_ON(pixel_rate >= 0x100000000))
-		return;
-
 	frame_interval_ns = total_pixels * NSEC_PER_SEC;
-	do_div(frame_interval_ns, (u32)pixel_rate);
+	do_div(frame_interval_ns, pixel_rate);
 	vsensor->hw.fps_jiffies = nsecs_to_jiffies(frame_interval_ns);
 	if (vsensor->hw.fps_jiffies == 0)
 		vsensor->hw.fps_jiffies = 1;

base-commit: a52e6f7923c17a672135b485ffd96fbd72f46267
-- 
2.43.0


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

* Re: [PATCH] media: vimc: sensor: fix pixel_rate type to resolve do_div() warning
  2026-07-28  0:15 [PATCH] media: vimc: sensor: fix pixel_rate type to resolve do_div() warning Faizel K B
@ 2026-07-28  8:02 ` Ricardo Ribalda
  0 siblings, 0 replies; 2+ messages in thread
From: Ricardo Ribalda @ 2026-07-28  8:02 UTC (permalink / raw)
  To: Faizel K B
  Cc: Shuah Khan, Kieran Bingham, Mauro Carvalho Chehab, Hans Verkuil,
	linux-media, linux-kernel, kernel test robot

Thanks

On Tue, 28 Jul 2026 at 02:16, Faizel K B <faizel.kb@gmail.com> wrote:
>
> vsensor->pixel_rate->val is a plain s32 field. Declaring the local
> "pixel_rate" variable as u64 misrepresented its actual range and made
> do_div()'s divisor look wider than the 32-bit division it actually
> performs, which is exactly what the do_div() coccinelle check warns.
> Revert pixel_rate back to its original s32 type to match
> vsensor->pixel_rate->val, resolving the warning correctly.
>
> Fixes: ec1e620b2454 ("media: vimc: sensor: Add pixel_rate,vblank and hblank configuration")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202604191731.10nxGZ92-lkp@intel.com/
> Link: https://lore.kernel.org/lkml/CANiDSCs9s03DUjKwcPgDtZt2QJ4i0FGwab4zpEP+wCawagSC2Q@mail.gmail.com/
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> Signed-off-by: Faizel K B <faizel.kb@gmail.com>
> ---
>  drivers/media/test-drivers/vimc/vimc-sensor.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/test-drivers/vimc/vimc-sensor.c b/drivers/media/test-drivers/vimc/vimc-sensor.c
> index 83dcc9d61ee0..7cb544fdfddb 100644
> --- a/drivers/media/test-drivers/vimc/vimc-sensor.c
> +++ b/drivers/media/test-drivers/vimc/vimc-sensor.c
> @@ -97,18 +97,14 @@ static void vimc_sensor_update_frame_timing(struct v4l2_subdev *sd,
>  {
>         struct vimc_sensor_device *vsensor =
>                 container_of(sd, struct vimc_sensor_device, sd);
> -       u64 pixel_rate = vsensor->pixel_rate->val;
> +       u32 pixel_rate = vsensor->pixel_rate->val;
>         u32 hts = width + vsensor->hblank->val;
>         u32 vts = height + vsensor->vblank->val;
>         u64 total_pixels = (u64)hts * vts;
>         u64 frame_interval_ns;
>
> -       /* Sanity check, pixel rate is fixed and fits in 32 bits. */
> -       if (WARN_ON(pixel_rate >= 0x100000000))
> -               return;
> -
>         frame_interval_ns = total_pixels * NSEC_PER_SEC;
> -       do_div(frame_interval_ns, (u32)pixel_rate);
> +       do_div(frame_interval_ns, pixel_rate);
>         vsensor->hw.fps_jiffies = nsecs_to_jiffies(frame_interval_ns);
>         if (vsensor->hw.fps_jiffies == 0)
>                 vsensor->hw.fps_jiffies = 1;
>
> base-commit: a52e6f7923c17a672135b485ffd96fbd72f46267
> --
> 2.43.0
>


-- 
Ricardo Ribalda

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

end of thread, other threads:[~2026-07-28  8:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-28  0:15 [PATCH] media: vimc: sensor: fix pixel_rate type to resolve do_div() warning Faizel K B
2026-07-28  8:02 ` Ricardo Ribalda

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

all inboxes | Powered by JetHome®