From patchwork Tue Aug 6 08:59:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 264924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2D1DA2C0085 for ; Tue, 6 Aug 2013 18:59:59 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6d7O-00051k-SD; Tue, 06 Aug 2013 08:59:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6d7N-0006sD-2M; Tue, 06 Aug 2013 08:59:49 +0000 Received: from smtp31.i.mail.ru ([94.100.177.91]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6d7B-0006oO-Mr for linux-mtd@lists.infradead.org; Tue, 06 Aug 2013 08:59:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=oimeQ/qllZHwoYg9S5bMO9E0IFyokr2Z523ET4CL5os=; b=OvgFtWSsznVFf6LNuVPoJ0ROqVbGx8Ueb9au/yIW0aze6xjYlVwYMcaCGSlrWGhHCP91Uc+6IL8vh4VNXFqw+24aZwQxeOaoa+3R5/KWQGZlDrjL6zmzJO7YlcArgjjWBAen4CMW1aIR4/sunIa8DCXmeeW8Bh6xdPHuPSgczGI=; Received: from [217.119.30.118] (port=16028 helo=shc.milas.spb.ru) by smtp31.i.mail.ru with esmtpa (envelope-from ) id 1V6d6o-0007S7-OJ; Tue, 06 Aug 2013 12:59:14 +0400 From: Alexander Shiyan To: linux-mtd@lists.infradead.org Subject: [PATCH RESEND] mtd: nand: diskonchip: Request memory region prior ioremap() Date: Tue, 6 Aug 2013 12:59:02 +0400 Message-Id: <1375779544-510-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.1.5 X-Spam: Not detected X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130806_045938_199917_48194846 X-CRM114-Status: GOOD ( 10.23 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.8 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [217.119.30.118 listed in dnsbl.sorbs.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shc_work[at]mail.ru) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Artem Bityutskiy , Brian Norris , David Woodhouse , Alexander Shiyan X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- drivers/mtd/nand/diskonchip.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index eaa3c29..bf5682f 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); } }