Skip to content

Commit

Permalink
NVMe: Use last bytes of f/w rev SCSI Inquiry
Browse files Browse the repository at this point in the history
After skipping right-padded spaces, use the last four bytes of the
firmware revision when reporting the Inquiry Product Revision. These
are generally more indicative to what is running.

Signed-off-by: Keith Busch <[email protected]>
Acked-by: Vishal Verma <[email protected]>
Signed-off-by: Matthew Wilcox <[email protected]>
  • Loading branch information
Keith Busch authored and Matthew Wilcox committed Jun 4, 2014
1 parent b4e75cb commit dedf4b1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/block/nvme-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ static int nvme_trans_standard_inquiry_page(struct nvme_ns *ns,
u8 resp_data_format = 0x02;
u8 protect;
u8 cmdque = 0x01 << 1;
u8 fw_offset = sizeof(dev->firmware_rev);

mem = dma_alloc_coherent(&dev->pci_dev->dev, sizeof(struct nvme_id_ns),
&dma_addr, GFP_KERNEL);
Expand Down Expand Up @@ -716,7 +717,11 @@ static int nvme_trans_standard_inquiry_page(struct nvme_ns *ns,
inq_response[7] = cmdque; /* wbus16=0 | sync=0 | vs=0 */
strncpy(&inq_response[8], "NVMe ", 8);
strncpy(&inq_response[16], dev->model, 16);
strncpy(&inq_response[32], dev->firmware_rev, 4);

while (dev->firmware_rev[fw_offset - 1] == ' ' && fw_offset > 4)
fw_offset--;
fw_offset -= 4;
strncpy(&inq_response[32], dev->firmware_rev + fw_offset, 4);

xfer_len = min(alloc_len, STANDARD_INQUIRY_LENGTH);
res = nvme_trans_copy_to_user(hdr, inq_response, xfer_len);
Expand Down

0 comments on commit dedf4b1

Please sign in to comment.