Commit 4f0614a0 authored by Alexander Shiyan's avatar Alexander Shiyan Committed by Brian Norris

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

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: default avatarAlexander Shiyan <shc_work@mail.ru>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 3cb2c1ed
...@@ -1440,10 +1440,13 @@ static int __init doc_probe(unsigned long physadr) ...@@ -1440,10 +1440,13 @@ static int __init doc_probe(unsigned long physadr)
int reg, len, numchips; int reg, len, numchips;
int ret = 0; int ret = 0;
if (!request_mem_region(physadr, DOC_IOREMAP_LEN, NULL))
return -EBUSY;
virtadr = ioremap(physadr, DOC_IOREMAP_LEN); virtadr = ioremap(physadr, DOC_IOREMAP_LEN);
if (!virtadr) { if (!virtadr) {
printk(KERN_ERR "Diskonchip ioremap failed: 0x%x bytes at 0x%lx\n", DOC_IOREMAP_LEN, physadr); printk(KERN_ERR "Diskonchip ioremap failed: 0x%x bytes at 0x%lx\n", DOC_IOREMAP_LEN, physadr);
return -EIO; ret = -EIO;
goto error_ioremap;
} }
/* It's not possible to cleanly detect the DiskOnChip - the /* It's not possible to cleanly detect the DiskOnChip - the
...@@ -1629,6 +1632,10 @@ static int __init doc_probe(unsigned long physadr) ...@@ -1629,6 +1632,10 @@ static int __init doc_probe(unsigned long physadr)
WriteDOC(save_control, virtadr, DOCControl); WriteDOC(save_control, virtadr, DOCControl);
fail: fail:
iounmap(virtadr); iounmap(virtadr);
error_ioremap:
release_mem_region(physadr, DOC_IOREMAP_LEN);
return ret; return ret;
} }
...@@ -1645,6 +1652,7 @@ static void release_nanddoc(void) ...@@ -1645,6 +1652,7 @@ static void release_nanddoc(void)
nextmtd = doc->nextdoc; nextmtd = doc->nextdoc;
nand_release(mtd); nand_release(mtd);
iounmap(doc->virtadr); iounmap(doc->virtadr);
release_mem_region(doc->physadr, DOC_IOREMAP_LEN);
kfree(mtd); kfree(mtd);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment