Skip to contentSkip to conversation

ftmac100: use resource_size()

PATCH Applied Dan Carpenter 3 participants 3 messages Mar 19, 2011

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

PATCH 1/1 ftmac100: use resource_size()

The calculation is off-by-one. It should be "end - start + 1". This patch fixes it to use resource_size() instead. Oddly, the code already uses resource size correctly a couple lines earlier when it calls request_mem_region() for this memory.

drivers/net/ftmac100.c +1 -1
index 1d6f4b8..a316619 100644
@@ -1102,7 +1102,7 @@ static int ftmac100_probe(struct platform_device *pdev)
 		goto err_req_mem;
 	}
 
-	priv->base = ioremap(res->start, res->end - res->start);
+	priv->base = ioremap(res->start, resource_size(res));
 	if (!priv->base) {
 		dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
 		err = -EIO;
maintainer Applied
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Sat, 19 Mar 2011 07:39:15 +0300

Quoted 6 lines

The calculation is off-by-one. It should be "end - start + 1". This patch fixes it to use resource_size() instead. Oddly, the code already uses resource size correctly a couple lines earlier when it calls request_mem_region() for this memory.

Applied, thanks for fixing this Dan.

#2 lore raw
In reply to Dan Carpenter

Hi Dan,

Quoted 12 lines · Dan Carpenter

The calculation is off-by-one.  It should be "end - start + 1".  This patch fixes it to use resource_size() instead.  Oddly, the code already uses resource size correctly a couple lines earlier when it calls request_mem_region() for this memory.

drivers/net/ftmac100.c +0 -0
index 1d6f4b8..a316619 100644

drivers/net/ftmac100.c static int ftmac100_probe(struct platform_device *pdev) · line 1108

Quoted 8 lines
drivers/net/ftmac100.c +1 -1
@@ -1102,7 +1102,7 @@ static int ftmac100_probe(struct platform_device *pdev)
                goto err_req_mem;
        }
 
-       priv->base = ioremap(res->start, res->end - res->start);
+       priv->base = ioremap(res->start, resource_size(res));
        if (!priv->base) {
                dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
                err = -EIO;

Ah, I incautiously missed that line when code review.

Thanks,
Po-Yu Chuang