Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1606535
| Path | csiph.com!goblin3!goblin.stu.neva.ru!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 22/53] mtd: nand: denali: simplify multi device fixup code |
| Date | Wed, 22 Mar 2017 15:20:01 +0100 |
| Message-ID | <tnPhf-3Fu-13@gated-at.bofh.it> (permalink) |
| References | <tnPhf-3Fu-3@gated-at.bofh.it> |
| X-Original-To | linux-mtd@lists.infradead.org |
| 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] |
| X-Mailer | git-send-email 2.7.4 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 88 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | laurent.monat@idquantique.com, thorsten.christiansson@idquantique.com, Enrico Jorns <ejo@pengutronix.de>, Jason Roberts <jason.e.roberts@intel.com>, Artem Bityutskiy <artem.bityutskiy@linux.intel.com>, Dinh Nguyen <dinguyen@kernel.org>, Boris Brezillon <boris.brezillon@free-electrons.com>, Marek Vasut <marek.vasut@gmail.com>, Brian Norris <computersforpeace@gmail.com>, Graham Moore <grmoore@opensource.altera.com>, David Woodhouse <dwmw2@infradead.org>, Masami Hiramatsu <mhiramat@kernel.org>, Chuanxiao Dong <chuanxiao.dong@intel.com>, Jassi Brar <jaswinder.singh@linaro.org>, Masahiro Yamada <yamada.masahiro@socionext.com>, linux-kernel@vger.kernel.org, Richard Weinberger <richard@nod.at>, Cyrille Pitchen <cyrille.pitchen@atmel.com> |
| X-Original-Date | Wed, 22 Mar 2017 23:07:29 +0900 |
| X-Original-Message-ID | <1490191680-14481-23-git-send-email-yamada.masahiro@socionext.com> |
| X-Original-References | <1490191680-14481-1-git-send-email-yamada.masahiro@socionext.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1606535 |
Show key headers only | View raw
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 <yamada.masahiro@socionext.com>
---
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(-)
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)
--
2.7.4
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH v2 22/53] mtd: nand: denali: simplify multi device fixup code Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-03-22 15:20 +0100
csiph-web