Skip to contentSkip to conversation

media: ov02c10: Use div_u64 to divide a 64-bit number

PATCH In review Sakari Ailus 3 participants 3 messages May 9, 2025

Subsystems (3)
lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

PATCH 1/1 media: ov02c10: Use div_u64 to divide a 64-bit number

The ov02c10 driver divides a 64-bit number but reply relies on division operator to do that. Use div_u64() so this will compile everywhere.

---
 drivers/media/i2c/ov02c10.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/ov02c10.c +2 -2
index 9e3d4a4e12ce..089a4fd9627c 100644
@@ -497,8 +497,8 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
 		ov02c10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
 	/* MIPI lanes are DDR -> use link-freq * 2 */
-	pixel_rate = link_freq_menu_items[ov02c10->link_freq_index] * 2 *
-		     ov02c10->mipi_lanes / OV02C10_RGB_DEPTH;
+	pixel_rate = div_u64(link_freq_menu_items[ov02c10->link_freq_index] *
+			     2 * ov02c10->mipi_lanes, OV02C10_RGB_DEPTH);
 
 	ov02c10->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
 						V4L2_CID_PIXEL_RATE, 0,
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Sakari Ailus

The ov02c10 driver divides a 64-bit number but reply relies on division operator to do that. Use div_u64() so this will compile everywhere.

Quoted 23 lines
---
 drivers/media/i2c/ov02c10.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/ov02c10.c +2 -2
index 9e3d4a4e12ce..089a4fd9627c 100644
@@ -497,8 +497,8 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
 		ov02c10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
 	/* MIPI lanes are DDR -> use link-freq * 2 */
-	pixel_rate = link_freq_menu_items[ov02c10->link_freq_index] * 2 *
-		     ov02c10->mipi_lanes / OV02C10_RGB_DEPTH;
+	pixel_rate = div_u64(link_freq_menu_items[ov02c10->link_freq_index] *
+			     2 * ov02c10->mipi_lanes, OV02C10_RGB_DEPTH);
 
 	ov02c10->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
 						V4L2_CID_PIXEL_RATE, 0,
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#2 lore raw
In reply to Sakari Ailus

Hi,

Quoted 4 lines · Sakari Ailus

The ov02c10 driver divides a 64-bit number but reply relies on division operator to do that. Use div_u64() so this will compile everywhere.

I was just going to start working on fixing this myself, thank you, patch looks good to me:

Regards,

Hans

Quoted 19 lines
---
 drivers/media/i2c/ov02c10.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/ov02c10.c +2 -2
index 9e3d4a4e12ce..089a4fd9627c 100644
@@ -497,8 +497,8 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
 		ov02c10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
 	/* MIPI lanes are DDR -> use link-freq * 2 */
-	pixel_rate = link_freq_menu_items[ov02c10->link_freq_index] * 2 *
-		     ov02c10->mipi_lanes / OV02C10_RGB_DEPTH;
+	pixel_rate = div_u64(link_freq_menu_items[ov02c10->link_freq_index] *
+			     2 * ov02c10->mipi_lanes, OV02C10_RGB_DEPTH);
 
 	ov02c10->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
 						V4L2_CID_PIXEL_RATE, 0,