diff --git a/src/nvme/types.h b/src/nvme/types.h index 3bf223710..a1101c98d 100644 --- a/src/nvme/types.h +++ b/src/nvme/types.h @@ -1870,11 +1870,18 @@ enum nvme_id_nsfeat { * :c:type:`struct nvme_id_ns `.lbaf. */ enum nvme_id_ns_flbas { - NVME_NS_FLBAS_LOWER_MASK = 15 << 0, - NVME_NS_FLBAS_META_EXT = 1 << 4, - NVME_NS_FLBAS_HIGHER_MASK = 3 << 5, + NVME_NS_FLBAS_LOWER_SHIFT = 0, + NVME_NS_FLBAS_META_EXT_SHIFT = 4, + NVME_NS_FLBAS_HIGHER_SHIFT = 5, + NVME_NS_FLBAS_LOWER_MASK = 0xf, + NVME_NS_FLBAS_META_EXT_MASK = 0x1, + NVME_NS_FLBAS_HIGHER_MASK = 0x3, }; +#define NVME_NS_FLBAS_LOWER(flbas) NVME_GET(flbas, NS_FLBAS_LOWER) +#define NVME_NS_FLBAS_META_EX(flbas) NVME_GET(flbas, NS_FLBAS_META_EX) +#define NVME_NS_FLBAS_HIGHER(flbas) NVME_GET(flbas, NS_FLBAS_HIGHER) + /** * enum nvme_nvm_id_ns_elbaf - This field indicates the extended LBA format * @NVME_NVM_ELBAF_STS_MASK: Mask to get the storage tag size used to determine diff --git a/src/nvme/util.h b/src/nvme/util.h index 0c1e646ce..4d0e037c2 100644 --- a/src/nvme/util.h +++ b/src/nvme/util.h @@ -445,8 +445,8 @@ static inline void nvme_feature_decode_namespace_write_protect(__u32 value, static inline void nvme_id_ns_flbas_to_lbaf_inuse(__u8 flbas, __u8 *lbaf_inuse) { - *lbaf_inuse = (((flbas & NVME_NS_FLBAS_HIGHER_MASK) >> 1) | - (flbas & NVME_NS_FLBAS_LOWER_MASK)); + *lbaf_inuse = ((NVME_NS_FLBAS_HIGHER(flbas) >> 1) | + NVME_NS_FLBAS_LOWER(flbas)); } struct nvme_root;