[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6e303964-e34f-4ee7-82c3-5c45e7472e72@nvidia.com>
Date: Tue, 18 Mar 2025 02:57:54 +0000
From: Chaitanya Kulkarni <chaitanyak@...dia.com>
To: "shao.mingyin@....com.cn" <shao.mingyin@....com.cn>
CC: "sagi@...mberg.me" <sagi@...mberg.me>, Chaitanya Kulkarni
<chaitanyak@...dia.com>, "linux-nvme@...ts.infradead.org"
<linux-nvme@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "yang.tao172@....com.cn"
<yang.tao172@....com.cn>, "yang.yang29@....com.cn" <yang.yang29@....com.cn>,
"hch@....de" <hch@....de>, "xu.xin16@....com.cn" <xu.xin16@....com.cn>
Subject: Re: [PATCH] nvme: replace max(a, min(b, c)) by clamp(b, a, c)
On 3/17/25 00:39, shao.mingyin@....com.cn wrote:
> From: LiHaoran <li.haoran7@....com.cn>
>
> This patch replaces max(a, min(b, c)) by clamp(b, a, c) in the nvme
> driver. This improves the readability.
>
> Signed-off-by: LiHaoran <li.haoran7@....com.cn>
> Cc: ShaoMingyin <shao.mingyin@....com.cn>
> ---
> drivers/nvme/target/nvmet.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
> index fcf4f460dc9a..30804b0ca66e 100644
> --- a/drivers/nvme/target/nvmet.h
> +++ b/drivers/nvme/target/nvmet.h
> @@ -819,7 +819,7 @@ static inline u8 nvmet_cc_iocqes(u32 cc)
> /* Convert a 32-bit number to a 16-bit 0's based number */
> static inline __le16 to0based(u32 a)
> {
> - return cpu_to_le16(max(1U, min(1U << 16, a)) - 1);
> + return cpu_to_le16(clamp(1U << 16, 1U, a) - 1);
I've gotten used to the min/max or max/min combination,
but if others prefer something else, sure go for it.
-ck
Powered by blists - more mailing lists