From patchwork Tue Nov 20 10:57:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 1000595 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PEMsIf8P"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="YnJDyy3y"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42zrRs2gFjz9s1c for ; Wed, 21 Nov 2018 03:16:25 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=tp3ctbGaLZVClcclidez0geLv2g6q8w/eQOa7ZK2bSU=; b=PEMsIf8PckGRoKpx2L6AWhUHub yD3V3QovHZ1xMgmDlA1qt0PzGJaFu2HfM0Em7eD+bQVNvX1JOGHaCdoXY9eVMvmtjrLJYPeqnA9lO AVyB38kTJhJiUNp8wpA+htjHtEiFM99x28QgQ1QHWxWWLMCzzqYyPMNH/x6VYw4JN2VMHo+42wGRg 1FjavoAvyEuNZn6RBIeOYrGY5eFp2HQSU4yE+4bpMDabdZvyBWi39kC6Pi9FGnYcplLuC/R/FoQbd AkcoDvyd+7C0PLmAiZ5EV5TVB+dpejLqhSsBhKr3jLwgtcs6vdTa0nBzbgW171sZ4mx9tcmzHEkF0 zRDy7BZg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8gs-0007B2-22; Tue, 20 Nov 2018 16:15:54 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8GL-0003nl-O1 for linux-mtd@bombadil.infradead.org; Tue, 20 Nov 2018 15:48:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=a7QiwxSqtg42PuQ6NAEcAeYLYbtaxX5pZmC59Sn96Fc=; b=YnJDyy3yomWVGx561mZxDLjVK T+2JvZCqvAC8j9Uvn7yDB+zrMqbEIMPyIRFNnARIoL8bTLaSpYCkqpkP5+XvHN1qT05GX+tQZxw8/ tVsP9MCGftvN0+YuPmLDgHBOOo2unM1/+nWcLtZcmHjsucL1qW8iZ/9J0+k5rfL0hrwpteuuutTSr mbJLw36qFDx631LENS5sCXg6/utBZyZi4DzjgrVxU3F4vDaEz8z9c5fMLxNiyXWxlQZgrv/vBG7O0 dEMHkMJEdE+yVjv8Jqxz2Hy3WDoVmOE2w80yWF5n213zcIJrlJteCrd9mV6I+kYN20B2zQ4n6eLxB a8/TN7ZZw==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP3iy-0006o1-03 for linux-mtd@lists.infradead.org; Tue, 20 Nov 2018 10:57:45 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id CDF93206D8; Tue, 20 Nov 2018 11:57:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-13-146.w90-88.abo.wanadoo.fr [90.88.134.146]) by mail.bootlin.com (Postfix) with ESMTPSA id 8326F207B0; Tue, 20 Nov 2018 11:57:23 +0100 (CET) From: Boris Brezillon To: Boris Brezillon , Richard Weinberger , Miquel Raynal , linux-mtd@lists.infradead.org Subject: [RFC PATCH 3/5] mtd: rawnand: omap2: Use nand_controller_init() Date: Tue, 20 Nov 2018 11:57:18 +0100 Message-Id: <20181120105720.23081-4-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181120105720.23081-1-boris.brezillon@bootlin.com> References: <20181120105720.23081-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_055744_565953_A9A4D98B X-CRM114-Status: GOOD ( 13.76 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxim Levitsky , Marek Vasut , Matthias Brugger , Xiaolei Li , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Stop initializing omap_gpmc_controller fields are declaration time and replace that by a call to nand_controller_init(). Since the same object might be shared by several NAND chips and the NAND controller driver expects a ->probe() per-chip, we need to keep track of the omap_gpmc_controller state (whether it's already been initialized or not). Signed-off-by: Boris Brezillon --- drivers/mtd/nand/raw/omap2.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/raw/omap2.c b/drivers/mtd/nand/raw/omap2.c index 886d05c391ef..086561811896 100644 --- a/drivers/mtd/nand/raw/omap2.c +++ b/drivers/mtd/nand/raw/omap2.c @@ -2173,11 +2173,8 @@ static const struct nand_controller_ops omap_nand_controller_ops = { }; /* Shared among all NAND instances to synchronize access to the ECC Engine */ -static struct nand_controller omap_gpmc_controller = { - .lock = __SPIN_LOCK_UNLOCKED(omap_gpmc_controller.lock), - .wq = __WAIT_QUEUE_HEAD_INITIALIZER(omap_gpmc_controller.wq), - .ops = &omap_nand_controller_ops, -}; +static struct nand_controller omap_gpmc_controller; +static bool omap_gpmc_controller_initialized; static int omap_nand_probe(struct platform_device *pdev) { @@ -2227,6 +2224,12 @@ static int omap_nand_probe(struct platform_device *pdev) info->phys_base = res->start; + if (!omap_gpmc_controller_initialized) { + omap_gpmc_controller.ops = &omap_nand_controller_ops; + nand_controller_init(&omap_gpmc_controller); + omap_gpmc_controller_initialized = true; + } + nand_chip->controller = &omap_gpmc_controller; nand_chip->legacy.IO_ADDR_W = nand_chip->legacy.IO_ADDR_R;