[PATCH v7 4/5] media: venus: venc: Make the range of us_per_frame explicit

From: Ricardo Ribalda
Date: Mon Jun 16 2025 - 11:33:41 EST


Fps bigger than 0.000232829 fps, this fits in a 32 bit us_per_frame.
There is no need to do a 64 bit division here.

Also, the driver only works with whole fps.

Found with cocci:
drivers/media/platform/qcom/venus/venc.c:418:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.

Reviewed-by: Vikash Garodia <quic_vgarodia@xxxxxxxxxxx>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
---
drivers/media/platform/qcom/venus/venc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 4979392aa20b6dc94895c7089878531b92b57754..13395aaf06bbb1f381d809c18be61c5d6da85723 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -412,8 +412,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
do_div(us_per_frame, timeperframe->denominator);

us_per_frame = clamp(us_per_frame, 1, USEC_PER_SEC);
- fps = (u64)USEC_PER_SEC;
- do_div(fps, us_per_frame);
+ fps = USEC_PER_SEC / (u32)us_per_frame;
fps = min(VENUS_MAX_FPS, fps);

inst->fps = fps;

--
2.50.0.rc1.591.g9c95f17f64-goog