From: Thorsten Blum Date: Wed, 17 Sep 2025 10:12:31 +0000 (+0200) Subject: usb: hub: Use max() to improve usb_set_lpm_pel() X-Git-Tag: v6.19-rc1~63^2~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87653d54edd69f9f623d0a650323ec1adbbd2952;p=thirdparty%2Flinux.git usb: hub: Use max() to improve usb_set_lpm_pel() Use max() to simplify and improve the readability of usb_set_lpm_pel(). Signed-off-by: Thorsten Blum Link: https://lore.kernel.org/r/20250917101235.58381-2-thorsten.blum@linux.dev Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 256fe8c86828d..c8a543af3ad9b 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -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); } /*