]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: use NVME_CTRL_FNA definitions
authorTokunori Ikegami <ikegami.t@gmail.com>
Mon, 16 Sep 2024 06:11:51 +0000 (15:11 +0900)
committerDaniel Wagner <wagi@monom.org>
Mon, 16 Sep 2024 11:19:42 +0000 (13:19 +0200)
Replace the hardcoded values.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
nvme-print-stdout.c
nvme.c

index 27b3beb29f8e9d7b640b095200064bdbdb013837..96aeb75a2fba9a00fe306e673ced1a8d730cb785 100644 (file)
@@ -2217,10 +2217,10 @@ static void stdout_id_ctrl_fuses(__le16 ctrl_fuses)
 static void stdout_id_ctrl_fna(__u8 fna)
 {
        __u8 rsvd = (fna & 0xF0) >> 4;
-       __u8 bcnsid = (fna & 0x8) >> 3;
-       __u8 cese = (fna & 0x4) >> 2;
-       __u8 cens = (fna & 0x2) >> 1;
-       __u8 fmns = fna & 0x1;
+       __u8 bcnsid = (fna & NVME_CTRL_FNA_NSID_FFFFFFFF) >> 3;
+       __u8 cese = (fna & NVME_CTRL_FNA_CRYPTO_ERASE) >> 2;
+       __u8 cens = (fna & NVME_CTRL_FNA_SEC_ALL_NAMESPACES) >> 1;
+       __u8 fmns = fna & NVME_CTRL_FNA_FMT_ALL_NAMESPACES;
 
        if (rsvd)
                printf("  [7:4] : %#x\tReserved\n", rsvd);
diff --git a/nvme.c b/nvme.c
index 40c6c5943bd095493694b6d8aa4e9fe9ec4daaae..c1f177f3518dff0fef571404b7483b4dc1f967da 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -6169,7 +6169,7 @@ static int format_cmd(int argc, char **argv, struct command *cmd, struct plugin
                return -errno;
        }
 
-       if ((ctrl->fna & 1) == 1) {
+       if (ctrl->fna & NVME_CTRL_FNA_FMT_ALL_NAMESPACES) {
                /*
                 * FNA bit 0 set to 1: all namespaces ... shall be configured with the same
                 * attributes and a format (excluding secure erase) of any namespace results in a