Skip to contentSkip to conversation

gpio: tz1090: Use resource_size to fix off-by-one resource size calculation

PATCH Superseded Axel Lin 3 participants 4 messages Dec 28, 2014 – Jan 14, 2015 GPIO

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 gpio: tz1090: Use resource_size to fix off-by-one resource size calculation

---
 drivers/gpio/gpio-tz1090.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-tz1090.c +1 -1
index e3024bb..445660a 100644
@@ -573,7 +573,7 @@ static int tz1090_gpio_probe(struct platform_device *pdev)
 
 	/* Ioremap the registers */
 	priv.reg = devm_ioremap(&pdev->dev, res_regs->start,
-				 res_regs->end - res_regs->start);
+				resource_size(res_regs));
 	if (!priv.reg) {
 		dev_err(&pdev->dev, "unable to ioremap registers\n");
 		return -ENOMEM;
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/2 gpio: tz1090-pdc: Use resource_size to fix off-by-one resource size calculation

---
 drivers/gpio/gpio-tz1090-pdc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-tz1090-pdc.c +1 -1
index d753622..ede7e40 100644
@@ -190,7 +190,7 @@ static int tz1090_pdc_gpio_probe(struct platform_device *pdev)
 
 	/* Ioremap the registers */
 	priv->reg = devm_ioremap(&pdev->dev, res_regs->start,
-				 res_regs->end - res_regs->start);
+				 resource_size(res_regs));
 	if (!priv->reg) {
 		dev_err(&pdev->dev, "unable to ioremap registers\n");
 		return -ENOMEM;
Signature · 1 line
1.9.1
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] gpio: tz1090-pdc: Use resource_size to fix off-by-one resource size calculation

Quoted 1 line · Axel Lin

Thanks, both patches

Note that the previous off-by-one behaviour should be harmless since the SoC IO memory region is unmapped on Meta (i.e. the ioremap becomes a no-op as the whole of IO memory is accessible with normal memory accesses regardless of MMU).

Cheers
James

Quoted 18 lines
---
 drivers/gpio/gpio-tz1090-pdc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-tz1090-pdc.c +1 -1
index d753622..ede7e40 100644
@@ -190,7 +190,7 @@ static int tz1090_pdc_gpio_probe(struct platform_device *pdev)
 
 	/* Ioremap the registers */
 	priv->reg = devm_ioremap(&pdev->dev, res_regs->start,
-				 res_regs->end - res_regs->start);
+				 resource_size(res_regs));
 	if (!priv->reg) {
 		dev_err(&pdev->dev, "unable to ioremap registers\n");
 		return -ENOMEM;