Skip to contentSkip to conversation

media: i2c: Replace nested min() with single min3()

PATCH In review Qasim Ijaz 3 participants 3 messages Feb 25, 2025 – Feb 26, 2025

Subsystems (3)
lore
Share & tools
lore

Qasim Ijaz

author
#0 lore raw

PATCH 1/1 media: i2c: Replace nested min() with single min3()

Use min3() macro instead of nesting min() to simplify the return statement.

---
 drivers/media/i2c/vgxy61.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/vgxy61.c +2 -2
index d77468c8587b..5b0479f3a3c0 100644
@@ -892,8 +892,8 @@ static u32 vgxy61_get_expo_long_max(struct vgxy61_dev *sensor,
 	third_rot_max_expo = (sensor->frame_length / 71) * short_expo_ratio;
 
 	/* Take the minimum from all rules */
-	return min(min(first_rot_max_expo, second_rot_max_expo),
-		   third_rot_max_expo);
+	return min3(first_rot_max_expo, second_rot_max_expo,
+		    third_rot_max_expo);
 }
 
 static int vgxy61_update_exposure(struct vgxy61_dev *sensor, u16 new_expo_long,
Signature · 1 line
2.39.5
#1 lore raw

…

drivers/media/i2c/vgxy61.c static u32 vgxy61_get_expo_long_max(struct vgxy61_dev *sensor, · line 896

Quoted 9 lines

+++ b/drivers/media/i2c/vgxy61.c

drivers/media/i2c/vgxy61.c +2 -2
@@ -892,8 +892,8 @@ static u32 vgxy61_get_expo_long_max(struct vgxy61_dev *sensor,
 	third_rot_max_expo = (sensor->frame_length / 71) * short_expo_ratio;
 
 	/* Take the minimum from all rules */
-	return min(min(first_rot_max_expo, second_rot_max_expo),
-		   third_rot_max_expo);
+	return min3(first_rot_max_expo, second_rot_max_expo,
+		    third_rot_max_expo);

…

Can the following source code variant be applied?

+ return min3(first_rot_max_expo, second_rot_max_expo, third_rot_max_expo);

Regards,
Markus

maintainer
#2 lore raw
In reply to Qasim Ijaz

Hi Qasim,

Quoted 2 lines · Qasim Ijaz

Use min3() macro instead of nesting min() to simplify the return statement.

Going forward, for this driver on subject:

s/i2c/vgxy61/

as this is a driver for vgxy61. I've done that this time.

Signature · 3 lines
Regards,

Sakari Ailus