Skip to contentSkip to conversation

pv-drivers: use PCI interfaces to request IO and MEM resources on platform device

PATCH New Jan Beulich 1 participant 1 message Jan 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pv-drivers: use PCI interfaces to request IO and MEM resources on platform device

This is the correct interface to use and something has broken the use of the previous incorrect interface (which fails because the request conflicts with the resources assigned for the PCI device itself instead of nesting like the PCI interfaces do).

pci_request_region() has been available since at least Linux 2.6.5.

unmodified_drivers/linux-2.6/platform-pci/platform-pci.c +9 -13
@@ -382,18 +382,13 @@ static int __devinit platform_pci_init(s
 		return -ENOENT;
 	}
 
-	if (request_mem_region(mmio_addr, mmio_len, DRV_NAME) == NULL) {
-		printk(KERN_ERR ":MEM I/O resource 0x%lx @ 0x%lx busy\n",
-		       mmio_addr, mmio_len);
-		return -EBUSY;
-	}
+	ret = pci_request_region(pdev, 1, DRV_NAME);
+	if (ret < 0)
+		return ret;
 
-	if (request_region(ioaddr, iolen, DRV_NAME) == NULL) {
-		printk(KERN_ERR DRV_NAME ":I/O resource 0x%lx @ 0x%lx busy\n",
-		       iolen, ioaddr);
-		release_mem_region(mmio_addr, mmio_len);
-		return -EBUSY;
-	}
+	ret = pci_request_region(pdev, 0, DRV_NAME);
+	if (ret < 0)
+		goto mem_out;
 
 	platform_mmio = mmio_addr;
 	platform_mmiolen = mmio_len;
@@ -429,8 +424,9 @@ static int __devinit platform_pci_init(s
 
  out:
 	if (ret) {
-		release_mem_region(mmio_addr, mmio_len);
-		release_region(ioaddr, iolen);
+		pci_release_region(pdev, 0);
+mem_out:
+		pci_release_region(pdev, 1);
 	}
 
 	return ret;

This is the correct interface to use and something has broken the use of the previous incorrect interface (which fails because the request conflicts with the resources assigned for the PCI device itself instead of nesting like the PCI interfaces do).

pci_request_region() has been available since at least Linux 2.6.5.

unmodified_drivers/linux-2.6/platform-pci/platform-pci.c +9 -13
@@ -382,18 +382,13 @@ static int __devinit platform_pci_init(s
 		return -ENOENT;
 	}
 
-	if (request_mem_region(mmio_addr, mmio_len, DRV_NAME) == NULL) {
-		printk(KERN_ERR ":MEM I/O resource 0x%lx @ 0x%lx busy\n",
-		       mmio_addr, mmio_len);
-		return -EBUSY;
-	}
+	ret = pci_request_region(pdev, 1, DRV_NAME);
+	if (ret < 0)
+		return ret;
 
-	if (request_region(ioaddr, iolen, DRV_NAME) == NULL) {
-		printk(KERN_ERR DRV_NAME ":I/O resource 0x%lx @ 0x%lx busy\n",
-		       iolen, ioaddr);
-		release_mem_region(mmio_addr, mmio_len);
-		return -EBUSY;
-	}
+	ret = pci_request_region(pdev, 0, DRV_NAME);
+	if (ret < 0)
+		goto mem_out;
 
 	platform_mmio = mmio_addr;
 	platform_mmiolen = mmio_len;
@@ -429,8 +424,9 @@ static int __devinit platform_pci_init(s
 
  out:
 	if (ret) {
-		release_mem_region(mmio_addr, mmio_len);
-		release_region(ioaddr, iolen);
+		pci_release_region(pdev, 0);
+mem_out:
+		pci_release_region(pdev, 1);
 	}
 
 	return ret;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel