* [PATCHv2] NVMe: Use last bytes of f/w rev SCSI Inquiry
@ 2014-04-29 21:52 Keith Busch
2014-05-06 15:29 ` Verma, Vishal L
0 siblings, 1 reply; 2+ messages in thread
From: Keith Busch @ 2014-04-29 21:52 UTC (permalink / raw)
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 <keith.busch at intel.com>
---
v1 -> v2:
The NVMe spec defines this field as an ASCII string, which may be
right-padded with spaces and we don't care to use those in reporting a
product revision.
I have it on good authority that the SNT reference will be updated to
align more like the SAT, which uses the last words of the ATA Identify
firmware revision unless it is padded with spaces in which case it uses
the first. In anticipation of that, here's a patch!
drivers/block/nvme-scsi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index 2c3f5be..00a3f18 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -686,6 +686,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);
@@ -721,7 +722,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);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCHv2] NVMe: Use last bytes of f/w rev SCSI Inquiry
2014-04-29 21:52 [PATCHv2] NVMe: Use last bytes of f/w rev SCSI Inquiry Keith Busch
@ 2014-05-06 15:29 ` Verma, Vishal L
0 siblings, 0 replies; 2+ messages in thread
From: Verma, Vishal L @ 2014-05-06 15:29 UTC (permalink / raw)
On Tue, 2014-04-29@15:52 -0600, Keith Busch wrote:
> 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 <keith.busch at intel.com>
> ---
Looks good!
Acked-by: Vishal Verma <vishal.l.verma at linux.intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-06 15:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-29 21:52 [PATCHv2] NVMe: Use last bytes of f/w rev SCSI Inquiry Keith Busch
2014-05-06 15:29 ` Verma, Vishal L
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox