2010-05-11 07:05:41

by Tobias Klauser

[permalink] [raw]
Subject: [PATCH] crypto: mv_cesa - Use resource_size

Use the resource_size function instead of manually calculating the
resource size. This reduces the chance of introducing off-by-one errors.

Signed-off-by: Tobias Klauser <[email protected]>
---
drivers/crypto/mv_cesa.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c
index 18a436c..e095422 100644
--- a/drivers/crypto/mv_cesa.c
+++ b/drivers/crypto/mv_cesa.c
@@ -1023,7 +1023,7 @@ static int mv_probe(struct platform_device *pdev)

spin_lock_init(&cp->lock);
crypto_init_queue(&cp->queue, 50);
- cp->reg = ioremap(res->start, res->end - res->start + 1);
+ cp->reg = ioremap(res->start, resource_size(res));
if (!cp->reg) {
ret = -ENOMEM;
goto err;
@@ -1034,7 +1034,7 @@ static int mv_probe(struct platform_device *pdev)
ret = -ENXIO;
goto err_unmap_reg;
}
- cp->sram_size = res->end - res->start + 1;
+ cp->sram_size = resource_size(res);
cp->max_req_size = cp->sram_size - SRAM_CFG_SPACE;
cp->sram = ioremap(res->start, cp->sram_size);
if (!cp->sram) {
--
1.6.3.3



2010-05-14 04:58:46

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: mv_cesa - Use resource_size

On Tue, May 11, 2010 at 08:57:44AM +0200, Tobias Klauser wrote:
> Use the resource_size function instead of manually calculating the
> resource size. This reduces the chance of introducing off-by-one errors.
>
> Signed-off-by: Tobias Klauser <[email protected]>

Patch applied. Thanks!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt