diff mbox

[4/4,media] lirc_bt829: Enable and disable memory BAR

Message ID 1378082443.25743.63.camel@deadeye.wl.decadent.org.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Hutchings Sept. 2, 2013, 12:40 a.m. UTC
We must not assume that the PCI device is already enabled.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/staging/media/lirc/lirc_bt829.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/staging/media/lirc/lirc_bt829.c b/drivers/staging/media/lirc/lirc_bt829.c
index 76e6cfb..b386628 100644
--- a/drivers/staging/media/lirc/lirc_bt829.c
+++ b/drivers/staging/media/lirc/lirc_bt829.c
@@ -118,11 +118,15 @@  static int atir_pci_probe(struct pci_dev *pdev,
 	dev_info(&pdev->dev, "memory at 0x%08llX\n",
 		 (unsigned long long)pci_addr_phys);
 
+	rc = pci_enable_device_mem(pdev);
+	if (rc)
+		goto err_free;
+
 	atir->pci_addr_lin = ioremap(pci_addr_phys + DATA_PCI_OFF, 0x400);
 	if (atir->pci_addr_lin == 0) {
 		dev_err(&pdev->dev, "pci mem must be mapped\n");
 		rc = -ENODEV;
-		goto err_free;
+		goto err_disable;
 	}
 
 	strcpy(atir->driver.name, "ATIR");
@@ -148,6 +152,8 @@  static int atir_pci_probe(struct pci_dev *pdev,
 
 err_unmap:
 	iounmap(atir->pci_addr_lin);
+err_disable:
+	pci_disable_device(pdev);
 err_free:
 	pci_set_drvdata(pdev, NULL);
 	kfree(atir);
@@ -161,6 +167,7 @@  static void atir_pci_remove(struct pci_dev *pdev)
 
 	lirc_unregister_driver(atir->minor);
 	iounmap(atir->pci_addr_lin);
+	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
 	kfree(atir);
 }