Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvme: add from0based() helper

The NVMe specifications are big fans of "0's based"/"0-based" fields for
encoding values that must be positive. The encoded value is 1 less than
the value it represents. nvmet already provides a helper to0based() for
encoding 0's based values, so add a corresponding helper to decode these
fields on the host side.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Caleb Sander Mateos and committed by
Keith Busch
b465046c 823340b7

+6
+6
drivers/nvme/host/nvme.h
··· 762 762 return (len >> 2) - 1; 763 763 } 764 764 765 + /* Decode a 2-byte "0's based"/"0-based" field */ 766 + static inline u32 from0based(__le16 value) 767 + { 768 + return (u32)le16_to_cpu(value) + 1; 769 + } 770 + 765 771 static inline bool nvme_is_ana_error(u16 status) 766 772 { 767 773 switch (status & NVME_SCT_SC_MASK) {