stmmac: use resource_size()

Previous thread: x.25 attempts to negotiate invalid throughput by Linux Kernel Mailing List on Tuesday, April 13, 2010 - 12:59 pm. (1 message)

Next thread: net: corrected documentation for hardware time stamping by Linux Kernel Mailing List on Tuesday, April 13, 2010 - 12:59 pm. (1 message)
From: Linux Kernel Mailing List
Date: Tuesday, April 13, 2010 - 12:59 pm

Gitweb:     http://git.kernel.org/linus/b62226826b4ea1926b644b5a337ffa6b637d4870
Commit:     b62226826b4ea1926b644b5a337ffa6b637d4870
Parent:     ddd0451fc8dbf94446c81500ff0dcee06c4057cb
Author:     Dan Carpenter <error27@gmail.com>
AuthorDate: Wed Apr 7 21:50:08 2010 -0700
Committer:  David S. Miller <davem@davemloft.net>
CommitDate: Wed Apr 7 21:50:08 2010 -0700

    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.
    
    Signed-off-by: Dan Carpenter <error27@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/stmmac/stmmac_main.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index a673361..55317ad 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1685,7 +1685,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",
@@ -1694,9 +1694,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;
 	}
@@ -1774,7 +1774,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);
 ...
Previous thread: x.25 attempts to negotiate invalid throughput by Linux Kernel Mailing List on Tuesday, April 13, 2010 - 12:59 pm. (1 message)

Next thread: net: corrected documentation for hardware time stamping by Linux Kernel Mailing List on Tuesday, April 13, 2010 - 12:59 pm. (1 message)