From c5b1ff5857e590f50b4276d4de8e34fbcdc4dfb9 Mon Sep 17 00:00:00 2001
From: Hebbar, Gururaja <gururaja.hebbar@ti.com>
Date: Mon, 24 Oct 2011 15:59:37 +0530
Subject: [PATCH 3/5] arm:omap:mcspi: correct memory range when requesting regions

Current McSPI driver 1st requests memory regions & later adds register
offset. This causes warning when during module removal as below.

root@arago-armv7:~# rmmod -v /lib/modules/3.1.0-rc8/spi-omap2-mcspi.ko
rmmod spi_omap2_mcspi, wait=no
[   42.472810] Trying to free nonexistent resource
<00000000481a0100-00000000481a04ff>
[   42.519178] Trying to free nonexistent resource
<0000000048030100-00000000480304ff>

This patch moves the register offset addition before request_mem_region

Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com>
---
 drivers/spi/spi-omap2-mcspi.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 860651f..f757a8e 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1136,14 +1136,15 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
 		status = -ENODEV;
 		goto err1;
 	}
+
+	r->start += pdata->regs_offset;
+	r->end += pdata->regs_offset;
 	if (!request_mem_region(r->start, resource_size(r),
 				dev_name(&pdev->dev))) {
 		status = -EBUSY;
 		goto err1;
 	}
 
-	r->start += pdata->regs_offset;
-	r->end += pdata->regs_offset;
 	mcspi->phys = r->start;
 	mcspi->base = ioremap(r->start, resource_size(r));
 	if (!mcspi->base) {
-- 
1.7.2.5

