aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-11-26 03:59:44 -0500
committerJens Axboe <axboe@fb.com>2015-12-01 12:59:38 -0500
commit01fec28a6f3ba96d4f46a538eae089dd92189fd1 (patch)
tree727c0cf65913b62484ca8fe0502cd173b6d1b953
parentbf7d3ebbd219d8ad948e812d03e1decfd96c97d0 (diff)
nvme: use vendor it from identify
Use the vendor ID from the identify data instead of the PCI device to make the SCSI translation layer independent from the PCI driver. The NVMe spec defines them as having the same value for current PCIe devices. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/nvme/host/scsi.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/nvme/host/scsi.c b/drivers/nvme/host/scsi.c
index b42cf448a55e..0bf90b62ec27 100644
--- a/drivers/nvme/host/scsi.c
+++ b/drivers/nvme/host/scsi.c
@@ -649,6 +649,8 @@ static int nvme_fill_device_id_scsi_string(struct nvme_ns *ns,
649 struct sg_io_hdr *hdr, u8 *inq_response, int alloc_len) 649 struct sg_io_hdr *hdr, u8 *inq_response, int alloc_len)
650{ 650{
651 struct nvme_dev *dev = ns->dev; 651 struct nvme_dev *dev = ns->dev;
652 struct nvme_id_ctrl *id_ctrl;
653 int nvme_sc, res;
652 654
653 if (alloc_len < 72) { 655 if (alloc_len < 72) {
654 return nvme_trans_completion(hdr, 656 return nvme_trans_completion(hdr,
@@ -657,6 +659,11 @@ static int nvme_fill_device_id_scsi_string(struct nvme_ns *ns,
657 SCSI_ASCQ_CAUSE_NOT_REPORTABLE); 659 SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
658 } 660 }
659 661
662 nvme_sc = nvme_identify_ctrl(dev, &id_ctrl);
663 res = nvme_trans_status_code(hdr, nvme_sc);
664 if (res)
665 return res;
666
660 memset(inq_response, 0, alloc_len); 667 memset(inq_response, 0, alloc_len);
661 inq_response[1] = INQ_DEVICE_IDENTIFICATION_PAGE; 668 inq_response[1] = INQ_DEVICE_IDENTIFICATION_PAGE;
662 inq_response[3] = 0x48; /* Page Length */ 669 inq_response[3] = 0x48; /* Page Length */
@@ -667,12 +674,14 @@ static int nvme_fill_device_id_scsi_string(struct nvme_ns *ns,
667 inq_response[6] = 0x00; /* Rsvd */ 674 inq_response[6] = 0x00; /* Rsvd */
668 inq_response[7] = 0x44; /* Designator Length */ 675 inq_response[7] = 0x44; /* Designator Length */
669 676
670 sprintf(&inq_response[8], "%04x", to_pci_dev(dev->dev)->vendor); 677 sprintf(&inq_response[8], "%04x", le16_to_cpu(id_ctrl->vid));
671 memcpy(&inq_response[12], dev->model, sizeof(dev->model)); 678 memcpy(&inq_response[12], dev->model, sizeof(dev->model));
672 sprintf(&inq_response[52], "%04x", cpu_to_be32(ns->ns_id)); 679 sprintf(&inq_response[52], "%04x", cpu_to_be32(ns->ns_id));
673 memcpy(&inq_response[56], dev->serial, sizeof(dev->serial)); 680 memcpy(&inq_response[56], dev->serial, sizeof(dev->serial));
674 681
675 return nvme_trans_copy_to_user(hdr, inq_response, alloc_len); 682 res = nvme_trans_copy_to_user(hdr, inq_response, alloc_len);
683 kfree(id_ctrl);
684 return res;
676} 685}
677 686
678static int nvme_trans_device_id_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, 687static int nvme_trans_device_id_page(struct nvme_ns *ns, struct sg_io_hdr *hdr,