NVMe: Simplify Firmware Activate code slightly
authorMatthew Wilcox <matthew.r.wilcox@intel.com>
Mon, 6 May 2013 12:22:18 +0000 (08:22 -0400)
committerMatthew Wilcox <matthew.r.wilcox@intel.com>
Wed, 8 May 2013 13:55:05 +0000 (09:55 -0400)
Add definitions for the three Firmware Activate actions, and change the
SCSI translation code to construct the command into a temporary variable
instead of translating the endianness back-and-forth.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@linux.intel.com>
drivers/block/nvme-scsi.c
include/linux/nvme.h

index 1c0710ca55d672af4d011e1d806fca13cd324339..fed54b039893474bfa39cbda0004f46ab6c78a18 100644 (file)
@@ -1577,10 +1577,8 @@ static int nvme_trans_send_fw_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr,
                c.dlfw.numd = cpu_to_le32((tot_len/BYTES_TO_DWORDS) - 1);
                c.dlfw.offset = cpu_to_le32(offset/BYTES_TO_DWORDS);
        } else if (opcode == nvme_admin_activate_fw) {
-               c.common.cdw10[0] = cpu_to_le32(buffer_id);
-               /* AA=01b Replace & activate at reset */
-               c.common.cdw10[0] = cpu_to_le32(le32_to_cpu(
-                                               c.common.cdw10[0]) | 0x00000008);
+               u32 cdw10 = buffer_id | NVME_FWACT_REPL_ACTV;
+               c.common.cdw10[0] = cpu_to_le32(cdw10);
        }
 
        nvme_sc = nvme_submit_admin_cmd(dev, &c, NULL);
index 971ef086ed63606dd7639278d3366e6df61b2d6b..f451c8d6e231005b5a1ef702a89a2a4b8968ffc4 100644 (file)
@@ -316,6 +316,9 @@ enum {
        NVME_FEAT_WRITE_ATOMIC  = 0x0a,
        NVME_FEAT_ASYNC_EVENT   = 0x0b,
        NVME_FEAT_SW_PROGRESS   = 0x0c,
+       NVME_FWACT_REPL         = (0 << 3),
+       NVME_FWACT_REPL_ACTV    = (1 << 3),
+       NVME_FWACT_ACTV         = (2 << 3),
 };
 
 struct nvme_identify {