From patchwork Wed Mar 22 14:07:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 95761 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp233519obz; Wed, 22 Mar 2017 07:11:17 -0700 (PDT) X-Received: by 10.99.123.75 with SMTP id k11mr32388984pgn.150.1490191877505; Wed, 22 Mar 2017 07:11:17 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id 1si1957514pgr.272.2017.03.22.07.11.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 07:11:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org 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=eACR8uXHIF8Sqo6OpBMK9YjqAfK5NMf59zULKz67Pc0=; b=V6OS+tLVB4gxq43Ke6ANiOp+Ng Jud0ZkzV7qNqBduD9g4GAeGosifNev3P8/Med5I/GMouGwo9n7dTS9DzzO3BM2ud/ujOyLjbsLedv ONhPA1UOYSFX2vZrNgkHjJkmLcZJH10gaYw+pI7CANsAvyKeDMrdTexT8Bb21cPAx6Uyv1i+xOUBy 4XfO84UpR1+73LThunVnlCEec20Y49zb3hVRzLz/EEb2zB9cQ/gqWeG/Wd6H4u/dKpRpCX8OXjho2 emdJGVlIq2vJ8l05RkcyhBLbriPQGJq0huiM2P2kdnyiEJ8Yi+zQOxHuISI0SkBg3ZBC7OWWI/Xwn xsf3RhSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqgyo-0000v4-K7; Wed, 22 Mar 2017 14:11:14 +0000 Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqgxI-000638-Mp for linux-mtd@lists.infradead.org; Wed, 22 Mar 2017 14:09:45 +0000 Received: from pug.jp.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v2ME8LDf010154; Wed, 22 Mar 2017 23:08:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v2ME8LDf010154 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1490191737; bh=G+AgR3Ob/63ow59ue1QR6E0QhLg1wbcp7WadF72jlqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=icfLfMaoQMBBRUVjf7clHP78TdFQDpvqwY1C/PnFft1SSy11vDQr/D2g2r1EmBS2t 9fkxySEIQ3zXAHvMAs5GeJVWKoEasiO3mMk+oE7nQItYevqAfz8+o7aHfMuhbH3zvE 5DMgfgxuhGB9UUq+DlnFvT3zBUvNWcoeQ6p6tx6aodOp5HmdL6Ch4ZAOynJ5BayTRw JM5DNJt5c/0ZyDwYqrBEkYoPMg4TCZKCWdKlVEqvufAN4DWsMBIfuuVIhqtYtaZWga NHcsboMffng3A4HsDEwliXFT73SVqOcIJU4BBpiI+1uLtwhcRFlz9a8mpmH2oJqMpY Ivy+E6hjc2+1w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v2 22/53] mtd: nand: denali: simplify multi device fixup code Date: Wed, 22 Mar 2017 23:07:29 +0900 Message-Id: <1490191680-14481-23-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490191680-14481-1-git-send-email-yamada.masahiro@socionext.com> References: <1490191680-14481-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_070941_208565_D4CA669E X-CRM114-Status: GOOD ( 13.27 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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 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: laurent.monat@idquantique.com, Boris Brezillon , thorsten.christiansson@idquantique.com, Richard Weinberger , Marek Vasut , Masahiro Yamada , Artem Bityutskiy , Cyrille Pitchen , Jason Roberts , linux-kernel@vger.kernel.org, Dinh Nguyen , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Brian Norris , Enrico Jorns , David Woodhouse , Graham Moore MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The available configuration of the IP bus width is x8 or x16, so the possible value for denali->devnum is 1 or 2. If the value is 1, there is nothing to do. Fixup parameters only when denali->devnum is 2. Signed-off-by: Masahiro Yamada --- Changes in v2: - Simplify the code given 1 or 2 is possible for denali->devnum drivers/mtd/nand/denali.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 4e63d57..abf8997 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1458,7 +1458,7 @@ static void denali_drv_init(struct denali_nand_info *denali) denali->irq_status = 0; } -static void denali_multidev_fixup(struct denali_nand_info *denali) +static int denali_multidev_fixup(struct denali_nand_info *denali) { struct nand_chip *chip = &denali->nand; struct mtd_info *mtd = nand_to_mtd(chip); @@ -1472,20 +1472,32 @@ static void denali_multidev_fixup(struct denali_nand_info *denali) */ denali->devnum = ioread32(denali->flash_reg + DEVICES_CONNECTED); - mtd->size <<= denali->devnum - 1; - mtd->erasesize <<= denali->devnum - 1; - mtd->writesize <<= denali->devnum - 1; - mtd->oobsize <<= denali->devnum - 1; - chip->chipsize <<= denali->devnum - 1; - chip->page_shift += denali->devnum - 1; - chip->phys_erase_shift += denali->devnum - 1; - chip->bbt_erase_shift += denali->devnum - 1; - chip->chip_shift += denali->devnum - 1; - chip->pagemask <<= denali->devnum - 1; - chip->ecc.size *= denali->devnum; - chip->ecc.bytes *= denali->devnum; - chip->ecc.strength *= denali->devnum; - denali->bbtskipbytes *= denali->devnum; + if (denali->devnum == 1) + return 0; + + if (denali->devnum != 2) { + dev_err(denali->dev, "unsupported number of devices %d\n", + denali->devnum); + return -EINVAL; + } + + /* 2 chips in parallel */ + mtd->size <<= 1; + mtd->erasesize <<= 1; + mtd->writesize <<= 1; + mtd->oobsize <<= 1; + chip->chipsize <<= 1; + chip->page_shift += 1; + chip->phys_erase_shift += 1; + chip->bbt_erase_shift += 1; + chip->chip_shift += 1; + chip->pagemask <<= 1; + chip->ecc.size <<= 1; + chip->ecc.bytes <<= 1; + chip->ecc.strength <<= 1; + denali->bbtskipbytes <<= 1; + + return 0; } int denali_init(struct denali_nand_info *denali) @@ -1623,7 +1635,9 @@ int denali_init(struct denali_nand_info *denali) chip->ecc.write_oob = denali_write_oob; chip->erase = denali_erase; - denali_multidev_fixup(denali); + ret = denali_multidev_fixup(denali); + if (ret) + goto failed_req_irq; ret = nand_scan_tail(mtd); if (ret)