Skip to contentSkip to conversation

usb: typec: tcpm: use max() to get higher value

PATCH In review R Sundar 2 participants 2 messages Sep 25, 2024 – Sep 26, 2024

Subsystems (3)
lore
Share & tools
lore

R Sundar

author
#0 lore raw

PATCH 1/1 usb: typec: tcpm: use max() to get higher value

Use max() for better readability and to fix cocci warnings.

---

Reported in linux repo.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/usb/typec/tcpm/tcpm.c:6356:20-21: WARNING opportunity for max()

vim +6356 drivers/usb/typec/tcpm/tcpm.c

compile-tested only.

 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
index fc619478200f..aac4de1d53a8 100644
@@ -7367,7 +7367,7 @@ static int tcpm_psy_get_input_power_limit(struct tcpm_port *port,
 			src_mv = pdo_fixed_voltage(pdo);
 			src_ma = pdo_max_current(pdo);
 			tmp = src_mv * src_ma;
-			max_src_uw = tmp > max_src_uw ? tmp : max_src_uw;
+			max_src_uw = max(tmp, max_src_uw);
 		}
 	}
 
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · R Sundar

Use max() for better readability and to fix cocci warnings.

Quoted 30 lines

---

Reported in linux repo.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/usb/typec/tcpm/tcpm.c:6356:20-21: WARNING opportunity for max()

vim +6356 drivers/usb/typec/tcpm/tcpm.c

compile-tested only.

 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
index fc619478200f..aac4de1d53a8 100644
@@ -7367,7 +7367,7 @@ static int tcpm_psy_get_input_power_limit(struct tcpm_port *port,
 			src_mv = pdo_fixed_voltage(pdo);
 			src_ma = pdo_max_current(pdo);
 			tmp = src_mv * src_ma;
-			max_src_uw = tmp > max_src_uw ? tmp : max_src_uw;
+			max_src_uw = max(tmp, max_src_uw);
 		}
 	}
 
Signature · 1 line
2.34.1
Signature · 1 line
heikki