* [PATCH] scsi: scsi_transport_srp: replace min/max nesting with clamp()
@ 2025-03-31 7:55 shao.mingyin
2025-04-01 15:59 ` Bart Van Assche
2025-04-03 14:55 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: shao.mingyin @ 2025-03-31 7:55 UTC (permalink / raw)
To: james.bottomley
Cc: martin.petersen, linux-scsi, linux-kernel, yang.yang29, xu.xin16,
ye.xingchen, li.haoran7
From: Li Haoran <li.haoran7@zte.com.cn>
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 <li.haoran7@zte.com.cn>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
drivers/scsi/scsi_transport_srp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 64f6b22e8cc0..aeb58a9e6b7f 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);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: scsi_transport_srp: replace min/max nesting with clamp()
2025-03-31 7:55 [PATCH] scsi: scsi_transport_srp: replace min/max nesting with clamp() shao.mingyin
@ 2025-04-01 15:59 ` Bart Van Assche
2025-04-03 14:55 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2025-04-01 15:59 UTC (permalink / raw)
To: shao.mingyin, james.bottomley
Cc: martin.petersen, linux-scsi, linux-kernel, yang.yang29, xu.xin16,
ye.xingchen, li.haoran7
On 3/31/25 12:55 AM, shao.mingyin@zte.com.cn wrote:
> From: Li Haoran <li.haoran7@zte.com.cn>
>
> 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 <li.haoran7@zte.com.cn>
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> ---
> drivers/scsi/scsi_transport_srp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
> index 64f6b22e8cc0..aeb58a9e6b7f 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);
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: scsi_transport_srp: replace min/max nesting with clamp()
2025-03-31 7:55 [PATCH] scsi: scsi_transport_srp: replace min/max nesting with clamp() shao.mingyin
2025-04-01 15:59 ` Bart Van Assche
@ 2025-04-03 14:55 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2025-04-03 14:55 UTC (permalink / raw)
To: shao.mingyin
Cc: james.bottomley, martin.petersen, linux-scsi, linux-kernel,
yang.yang29, xu.xin16, ye.xingchen, li.haoran7
> 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.
Applied to 6.15/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-03 14:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31 7:55 [PATCH] scsi: scsi_transport_srp: replace min/max nesting with clamp() shao.mingyin
2025-04-01 15:59 ` Bart Van Assche
2025-04-03 14:55 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox