Commit 64ea88e3 authored by Li Haoran's avatar Li Haoran Committed by Keith Busch
Browse files

nvmet: replace max(a, min(b, c)) by clamp(val, lo, hi)



This patch replaces max(a, min(b, c)) by clamp(val, lo, hi) in the nvme
driver. The clamp() macro explicitly expresses the intent of constraining
a value within bounds, improving code readability.

Signed-off-by: default avatarLi Haoran <li.haoran7@zte.com.cn>
Signed-off-by: default avatarShao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 1be52169
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -828,7 +828,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(a, 1U, 1U << 16) - 1);
}

static inline bool nvmet_ns_has_pi(struct nvmet_ns *ns)