Patchwork mtd: nand: diskonchip: Request memory region prior ioremap()

login
register
mail settings
Submitter Alexander Shiyan
Date July 23, 2013, 9:46 a.m.
Message ID <1374572774-9989-1-git-send-email-shc_work@mail.ru>
Download mbox | patch
Permalink /patch/261013/
State New
Headers show

Comments

Alexander Shiyan - July 23, 2013, 9:46 a.m.
This patch adds request_mem_region() prior ioremap() for diskonchip
driver. This will allow to check if memory region is occupied by any
other device, for example in case if we have memory region for several
optional devices and only one device can be used at once.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/mtd/nand/diskonchip.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch

diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 81fa578..b16f1dd 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -1440,8 +1440,11 @@  static int __init doc_probe(unsigned long physadr)
 	int reg, len, numchips;
 	int ret = 0;
 
+	if (!request_mem_region(physadr, DOC_IOREMAP_LEN, NULL))
+		return -EBUSY;
 	virtadr = ioremap(physadr, DOC_IOREMAP_LEN);
 	if (!virtadr) {
+		release_mem_region(physadr, DOC_IOREMAP_LEN);
 		printk(KERN_ERR "Diskonchip ioremap failed: 0x%x bytes at 0x%lx\n", DOC_IOREMAP_LEN, physadr);
 		return -EIO;
 	}
@@ -1629,6 +1632,7 @@  static int __init doc_probe(unsigned long physadr)
 	WriteDOC(save_control, virtadr, DOCControl);
  fail:
 	iounmap(virtadr);
+	release_mem_region(physadr, DOC_IOREMAP_LEN);
 	return ret;
 }
 
@@ -1645,6 +1649,7 @@  static void release_nanddoc(void)
 		nextmtd = doc->nextdoc;
 		nand_release(mtd);
 		iounmap(doc->virtadr);
+		release_mem_region(doc->physadr, DOC_IOREMAP_LEN);
 		kfree(mtd);
 	}
 }