Skip to contentSkip to conversation

stmmac: use resource_size()

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 7, 2010 – Apr 8, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stmmac: use resource_size()

Resource size should be calculated as end - start + 1 because we start counting at zero. I changed the code to resource_size() to do the calculation.

drivers/net/stmmac/stmmac_main.c +5 -5
index a214a16..4111a85 100644
@@ -1686,7 +1686,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
 	}
 	pr_info("done!\n");
 
-	if (!request_mem_region(res->start, (res->end - res->start),
+	if (!request_mem_region(res->start, resource_size(res),
 				pdev->name)) {
 		pr_err("%s: ERROR: memory allocation failed"
 		       "cannot get the I/O addr 0x%x\n",
@@ -1695,9 +1695,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
 		goto out;
 	}
 
-	addr = ioremap(res->start, (res->end - res->start));
+	addr = ioremap(res->start, resource_size(res));
 	if (!addr) {
-		pr_err("%s: ERROR: memory mapping failed \n", __func__);
+		pr_err("%s: ERROR: memory mapping failed\n", __func__);
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -1775,7 +1775,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
 out:
 	if (ret < 0) {
 		platform_set_drvdata(pdev, NULL);
-		release_mem_region(res->start, (res->end - res->start));
+		release_mem_region(res->start, resource_size(res));
 		if (addr != NULL)
 			iounmap(addr);
 	}
@@ -1813,7 +1813,7 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
 
 	iounmap((void *)ndev->base_addr);
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(res->start, (res->end - res->start));
+	release_mem_region(res->start, resource_size(res));
 
 	free_netdev(ndev);
 
maintainer Applied
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Wed, 7 Apr 2010 12:35:46 +0300

Quoted 5 lines

Resource size should be calculated as end - start + 1 because we start counting at zero. I changed the code to resource_size() to do the calculation.

Applied, thanks Dan.