diff options
author | Li Haoran <li.haoran7@zte.com.cn> | 2025-03-20 10:53:00 +0300 |
---|---|---|
committer | Keith Busch <kbusch@kernel.org> | 2025-03-21 02:53:56 +0300 |
commit | 64ea88e3afa8c5b6c3f9c477da304b7a56149612 (patch) | |
tree | 56d4491bad015f9a0ee11389921b6285ad323cfe | |
parent | 1be52169c3488ef98582ed553ab35cefa3978817 (diff) | |
download | linux-64ea88e3afa8c5b6c3f9c477da304b7a56149612.tar.xz |
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: Li Haoran <li.haoran7@zte.com.cn>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
-rw-r--r-- | drivers/nvme/target/nvmet.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 9f6110ac7c4a..33fac9151b5b 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -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) |