[Lkw] [PATCH] nvme-cmb: pci part2

Rodrigo Alejandro Melo rodrigomelo9 at gmail.com
Fri Sep 15 14:03:30 EDT 2023


Signed-off-by: Rodrigo Alejandro Melo <rodrigomelo9 at gmail.com>
---
 drivers/block/nvme-cmb.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c
index f8ca8203c..bd1cd81fb 100644
--- a/drivers/block/nvme-cmb.c
+++ b/drivers/block/nvme-cmb.c
@@ -5,13 +5,31 @@
 
 static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
+	int error;
+
 	dev_info(&pdev->dev, "found NVMe device\n");
+
+	pci_set_master(pdev);
+	error = pci_enable_device_mem(pdev);
+	if (error)
+		return error;
+	error = pci_request_mem_regions(pdev, "nvme-cmb");
+	if (error)
+		goto out_disable_device;
+
 	return 0;
+
+out_disable_device:
+	pci_disable_device(pdev);
+	return error;
 }
 
 static void nvme_cmb_remove(struct pci_dev *pdev)
 {
 	dev_info(&pdev->dev, "unbinding NVMe device\n");
+
+	pci_release_mem_regions(pdev);
+	pci_disable_device(pdev);
 }
 
 static const struct pci_device_id nvme_cmb_id_table[] = {
-- 
2.39.2




More information about the LKW mailing list