[Lkw] [PATCH] nvme_cmb: update driver
Andres Ferra
andres.ferra at mi.unc.edu.ar
Fri Sep 15 15:02:12 EDT 2023
---
drivers/block/nvme-cmb.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c
index fac1eba6f880..894bb2e2ec5a 100644
--- a/drivers/block/nvme-cmb.c
+++ b/drivers/block/nvme-cmb.c
@@ -1,11 +1,13 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/nvme.h>
#include <linux/pci.h>
MODULE_LICENSE("GPL");
struct nvme_cmb_dev {
+ void __iomem *bar;
};
static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -27,9 +29,25 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
error = pci_request_mem_regions(pdev, "nvme-cmb");
if (error)
goto out_disable_device;
+
+ dev->bar = pci_ioremap_bar(pdev, 0);
+ if (!dev->bar) {
+ error = -ENOMEM;
+ goto out_release_regions;
+ }
+
+ if (readl(dev->bar + NVME_REG_CSTS) == ~0) {
+ error = -EIO;
+ goto out_iounmap;
+ }
+
dev_set_drvdata(&pdev->dev, dev);
return 0;
+out_iounmap:
+ iounmap(dev->bar);
+out_release_regions:
+ pci_release_mem_regions(pdev);
out_disable_device:
pci_disable_device(pdev);
out_free_dev:
@@ -43,6 +61,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev)
dev_info(&pdev->dev, "unbinding NVMe device\n");
+ iounmap(dev->bar);
pci_release_mem_regions(pdev);
pci_disable_device(pdev);
kfree(dev);
--
2.39.2
More information about the LKW
mailing list