* [patch] cpmac: use resource_size()
@ 2010-06-28 21:19 Dan Carpenter
2010-06-30 20:12 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-06-28 21:19 UTC (permalink / raw)
To: Florian Fainelli
Cc: David S. Miller, Jiri Pirko, Eric Dumazet, netdev,
kernel-janitors
The original code is off by one because we should start counting at
zero. So the size of the resource is end - start + 1. I switched it to
use resource_size() to do the calculation.
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
I don't have a cross compile environment, so I can't even compile test
this. Sorry.
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 23786ee..38de1a4 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -964,7 +964,7 @@ static int cpmac_open(struct net_device *dev)
struct sk_buff *skb;
mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs");
- if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) {
+ if (!request_mem_region(mem->start, resource_size(mem), dev->name)) {
if (netif_msg_drv(priv))
printk(KERN_ERR "%s: failed to request registers\n",
dev->name);
@@ -972,7 +972,7 @@ static int cpmac_open(struct net_device *dev)
goto fail_reserve;
}
- priv->regs = ioremap(mem->start, mem->end - mem->start);
+ priv->regs = ioremap(mem->start, resource_size(mem));
if (!priv->regs) {
if (netif_msg_drv(priv))
printk(KERN_ERR "%s: failed to remap registers\n",
@@ -1049,7 +1049,7 @@ fail_alloc:
iounmap(priv->regs);
fail_remap:
- release_mem_region(mem->start, mem->end - mem->start);
+ release_mem_region(mem->start, resource_size(mem));
fail_reserve:
return res;
@@ -1077,7 +1077,7 @@ static int cpmac_stop(struct net_device *dev)
free_irq(dev->irq, dev);
iounmap(priv->regs);
mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs");
- release_mem_region(mem->start, mem->end - mem->start);
+ release_mem_region(mem->start, resource_size(mem));
priv->rx_head = &priv->desc_ring[CPMAC_QUEUES];
for (i = 0; i < priv->ring_size; i++) {
if (priv->rx_head[i].skb) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] cpmac: use resource_size()
2010-06-28 21:19 [patch] cpmac: use resource_size() Dan Carpenter
@ 2010-06-30 20:12 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-06-30 20:12 UTC (permalink / raw)
To: error27; +Cc: florian, jpirko, eric.dumazet, netdev, kernel-janitors
From: Dan Carpenter <error27@gmail.com>
Date: Mon, 28 Jun 2010 23:19:33 +0200
> The original code is off by one because we should start counting at
> zero. So the size of the resource is end - start + 1. I switched it to
> use resource_size() to do the calculation.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Applied to net-next-2.6, thanks Dan.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-30 20:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-28 21:19 [patch] cpmac: use resource_size() Dan Carpenter
2010-06-30 20:12 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).