]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print-stdout: Use NVME_BOOT_PARTITION_INFO field definitions
authorTokunori Ikegami <ikegami.t@gmail.com>
Sun, 17 Mar 2024 11:58:01 +0000 (20:58 +0900)
committerDaniel Wagner <wagi@monom.org>
Tue, 19 Mar 2024 10:25:06 +0000 (11:25 +0100)
Change it instead of hardcoded field mask and shift values.

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

index ec775c97f0b7ed3f3209e6567ca0779fb0b0962f..61fe7799c6a77333093aa002726caf4e6b1ce1b0 100644 (file)
@@ -675,13 +675,13 @@ static void stdout_mi_cmd_support_effects_log(struct nvme_mi_cmd_supported_effec
 static void stdout_boot_part_log(void *bp_log, const char *devname,
                                 __u32 size)
 {
-       struct nvme_boot_partition *hdr;
+       struct nvme_boot_partition *hdr = bp_log;
 
-       hdr = bp_log;
        printf("Boot Partition Log for device: %s\n", devname);
        printf("Log ID: %u\n", hdr->lid);
-       printf("Boot Partition Size: %u KiB\n", le32_to_cpu(hdr->bpinfo) & 0x7fff);
-       printf("Active BPID: %u\n", (le32_to_cpu(hdr->bpinfo) >> 31) & 0x1);
+       printf("Boot Partition Size: %u KiB\n",
+              NVME_BOOT_PARTITION_INFO_BPSZ(le32_to_cpu(hdr->bpinfo)));
+       printf("Active BPID: %u\n", NVME_BOOT_PARTITION_INFO_ABPID(le32_to_cpu(hdr->bpinfo)));
 }
 
 static const char *eomip_to_string(__u8 eomip)