From: Li Haoran
Date: Mon, 31 Mar 2025 07:55:11 +0000 (+0800)
Subject: scsi: scsi_transport_srp: Replace min/max nesting with clamp()
X-Git-Tag: v6.15-rc3~38^2^2~2
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a63b69f05f999acae91b0b50d7c5fe4fb241dbaf;p=thirdparty%2Fkernel%2Fstable.git
scsi: scsi_transport_srp: Replace min/max nesting with clamp()
This patch replaces min(a, max(b, c)) by clamp(val, lo, hi) in the SRP
transport layer. The clamp() macro explicitly expresses the intent of
constraining a value within bounds, improving code readability.
Signed-off-by: Li Haoran
Signed-off-by: Shao Mingyin
Link: https://lore.kernel.org/r/202503311555115618U8Md16mKpRYOIy2TOmB6@zte.com.cn
Reviewed-by: Bart Van Assche
Signed-off-by: Martin K. Petersen
---
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 64f6b22e8cc0c..aeb58a9e6b7f1 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -388,7 +388,7 @@ static void srp_reconnect_work(struct work_struct *work)
"reconnect attempt %d failed (%d)\n",
++rport->failed_reconnects, res);
delay = rport->reconnect_delay *
- min(100, max(1, rport->failed_reconnects - 10));
+ clamp(rport->failed_reconnects - 10, 1, 100);
if (delay > 0)
queue_delayed_work(system_long_wq,
&rport->reconnect_work, delay * HZ);