mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
media: vimc: Ensure that pixel_rate fits in 32 bits
pixel_rate is set to VIMC_PIXEL_RATE_FIXED, which the code expects to fit in 32 bits. Make that constraint into a WARN_ON, so if we ever break that constraint a kernel warning will be triggered. It also fixes the following cocci warning: ./test-drivers/vimc/vimc-sensor.c:107:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
91624e5806
commit
6b8ff73412
|
|
@ -103,8 +103,12 @@ static void vimc_sensor_update_frame_timing(struct v4l2_subdev *sd,
|
|||
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, pixel_rate);
|
||||
do_div(frame_interval_ns, (u32)pixel_rate);
|
||||
vsensor->hw.fps_jiffies = nsecs_to_jiffies(frame_interval_ns);
|
||||
if (vsensor->hw.fps_jiffies == 0)
|
||||
vsensor->hw.fps_jiffies = 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user