nvme: define identification constant values
Keith Busch
maintainerPATCH 1/1 nvme: define identification constant values
Improve code readability by defining the specification's constants the driver uses to decode identification results.
Signed-off-by Keith Busch <[email protected]>
--- drivers/nvme/host/core.c | 10 +++++----- include/linux/nvme.h | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +5 -5
@@ -1824,7 +1824,7 @@ static void nvme_update_disk_info(struct gendisk *disk,* and whether it should be used instead of AWUPF. If NAWUPF == * 0 then AWUPF must be used instead. */ -if (id->nsfeat & (1 <<1 ) && id->nawupf) +if (id->nsfeat &NVME_NS_FEAT_ATOMICS && id->nawupf) atomic_bs = (1 +le16_to_cpu (id->nawupf)) * bs;else atomic_bs = (1 + ns->ctrl->subsys->awupf) * bs;
@@ -1833,7 +1833,7 @@ static void nvme_update_disk_info(struct gendisk *disk, } phys_bs = bs; io_opt = bs; -if (id->nsfeat & (1 <<4 )) { +if (id->nsfeat &NVME_NS_FEAT_IO_OPT ) {/* NPWG = Namespace Preferred Write Granularity */ phys_bs *=1 +le16_to_cpu (id->npwg);/* NOWS = Namespace Optimal Write Size */
@@ -1862,7 +1862,7 @@ static void nvme_update_disk_info(struct gendisk *disk,nvme_config_discard (disk, ns);nvme_config_write_zeroes (disk, ns); -if (id->nsattr & (1 <<0 )) +if (id->nsattr &NVME_NS_ATTR_RO )set_disk_ro (disk, true);else set_disk_ro (disk, false);
@@ -2655,7 +2655,7 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,return false; } -if ((id->cmic & (1 <<1 )) || +if ((id->cmic &NVME_CTRL_CMIC_MULTI_CTRL ) || (ctrl->opts && ctrl->opts->discovery_nqn))continue ;
@@ -3468,7 +3468,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, struct nvme_id_ns *id) {struct nvme_ctrl *ctrl = ns->ctrl; -bool is_shared = id->nmic & (1 <<0 ); +bool is_shared = id->nmic &NVME_NS_NMIC_SHARED ;struct nvme_ns_head *head =NULL ;struct nvme_ns_ids ids;int ret =0 ;
include/linux/nvme.h +5 -0
@@ -299,6 +299,7 @@ struct nvme_id_ctrl { };enum { +NVME_CTRL_CMIC_MULTI_CTRL =1 <<1 ,NVME_CTRL_ONCS_COMPARE =1 <<0 ,NVME_CTRL_ONCS_WRITE_UNCORRECTABLE =1 <<1 ,NVME_CTRL_ONCS_DSM =1 <<2 ,
@@ -394,8 +395,12 @@ enum {enum {NVME_NS_FEAT_THIN =1 <<0 , +NVME_NS_FEAT_ATOMICS =1 <<1 , +NVME_NS_FEAT_IO_OPT =1 <<4 , +NVME_NS_ATTR_RO =1 <<0 ,NVME_NS_FLBAS_LBA_MASK =0xf ,NVME_NS_FLBAS_META_EXT =0x10 , +NVME_NS_NMIC_SHARED =1 <<0 ,NVME_LBAF_RP_BEST =0 ,NVME_LBAF_RP_BETTER =1 ,NVME_LBAF_RP_GOOD =2 ,
Signature · 7 lines
2.24.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerQuoted 8 lines · Keith Busch
Improve code readability by defining the specification's constants the driver uses to decode identification results.
Signed-off-by Keith Busch <[email protected]>--- drivers/nvme/host/core.c | 10 +++++----- include/linux/nvme.h | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-)
multipath.c also uses these constants. Let me send v2 with that update included.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme