* [PATCH] usb: hub: Use max() to improve usb_set_lpm_pel()
@ 2025-09-17 10:12 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2025-09-17 10:12 UTC (permalink / raw)
To: Greg Kroah-Hartman, Mathias Nyman, Alan Stern,
Stefan Eichenberger, Thomas Gleixner, Ingo Molnar,
Heikki Krogerus, Pawel Laszczak, Krzysztof Kozlowski
Cc: Thorsten Blum, Ma Ke, linux-usb, linux-kernel
Use max() to simplify and improve the readability of usb_set_lpm_pel().
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/usb/core/hub.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 256fe8c86828..c8a543af3ad9 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -28,6 +28,7 @@
#include <linux/usb/otg.h>
#include <linux/usb/quirks.h>
#include <linux/workqueue.h>
+#include <linux/minmax.h>
#include <linux/mutex.h>
#include <linux/random.h>
#include <linux/pm_qos.h>
@@ -277,10 +278,7 @@ static void usb_set_lpm_pel(struct usb_device *udev,
* device and the parent hub into U0. The exit latency is the bigger of
* the device exit latency or the hub exit latency.
*/
- if (udev_exit_latency > hub_exit_latency)
- first_link_pel = udev_exit_latency * 1000;
- else
- first_link_pel = hub_exit_latency * 1000;
+ first_link_pel = max(udev_exit_latency, hub_exit_latency) * 1000;
/*
* When the hub starts to receive the LFPS, there is a slight delay for
@@ -294,10 +292,7 @@ static void usb_set_lpm_pel(struct usb_device *udev,
* According to figure C-7 in the USB 3.0 spec, the PEL for this device
* is the greater of the two exit latencies.
*/
- if (first_link_pel > hub_pel)
- udev_lpm_params->pel = first_link_pel;
- else
- udev_lpm_params->pel = hub_pel;
+ udev_lpm_params->pel = max(first_link_pel, hub_pel);
}
/*
--
2.50.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-17 10:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 10:12 [PATCH] usb: hub: Use max() to improve usb_set_lpm_pel() Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox