From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Tudor Ambarus <Tudor.Ambarus@microchip.com>,
<linux-mtd@lists.infradead.org>
Cc: Boris Brezillon <boris.brezillon@collabora.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Miquel Raynal <miquel.raynal@bootlin.com>
Subject: [PATCH v2 5/9] mtd: rawnand: onfi: Define the number of parameter pages
Date: Fri, 24 Apr 2020 18:40:38 +0200 [thread overview]
Message-ID: <20200424164042.26572-6-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20200424164042.26572-1-miquel.raynal@bootlin.com>
Use a macro to define the number of parameter page instead of
hardcoding it everywhere.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/nand/raw/nand_onfi.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/raw/nand_onfi.c b/drivers/mtd/nand/raw/nand_onfi.c
index 7d9a3130443a..9fe39adbde4c 100644
--- a/drivers/mtd/nand/raw/nand_onfi.c
+++ b/drivers/mtd/nand/raw/nand_onfi.c
@@ -16,6 +16,8 @@
#include "internals.h"
+#define ONFI_PARAM_PAGES 3
+
u16 onfi_crc16(u16 crc, u8 const *p, size_t len)
{
int i;
@@ -156,7 +158,7 @@ int nand_onfi_detect(struct nand_chip *chip)
return 0;
/* ONFI chip: allocate a buffer to hold its parameter page */
- p = kzalloc((sizeof(*p) * 3), GFP_KERNEL);
+ p = kzalloc((sizeof(*p) * ONFI_PARAM_PAGES), GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -166,7 +168,7 @@ int nand_onfi_detect(struct nand_chip *chip)
goto free_onfi_param_page;
}
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < ONFI_PARAM_PAGES; i++) {
ret = nand_read_data_op(chip, &p[i], sizeof(*p), true);
if (ret) {
ret = 0;
@@ -181,8 +183,8 @@ int nand_onfi_detect(struct nand_chip *chip)
}
}
- if (i == 3) {
- const void *srcbufs[3] = {p, p + 1, p + 2};
+ if (i == ONFI_PARAM_PAGES) {
+ const void *srcbufs[ONFI_PARAM_PAGES] = {p, p + 1, p + 2};
pr_warn("Could not find a valid ONFI parameter page, trying bit-wise majority to recover it\n");
nand_bit_wise_majority(srcbufs, ARRAY_SIZE(srcbufs), p,
--
2.20.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-04-24 16:43 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 16:40 [PATCH v2 0/9] Misc timing changes Miquel Raynal
2020-04-24 16:40 ` [PATCH v2 1/9] mtd: rawnand: timings: Add mode information to the timings structure Miquel Raynal
2020-04-24 16:40 ` [PATCH v2 2/9] mtd: rawnand: timings: Fix default tR_max and tCCS_min timings Miquel Raynal
2020-04-25 9:40 ` Sergei Shtylyov
2020-04-28 9:10 ` Miquel Raynal
2020-04-24 16:40 ` [PATCH v2 3/9] mtd: rawnand: onfi: Fix redundancy detection check Miquel Raynal
2020-04-25 8:22 ` Boris Brezillon
2020-04-28 8:54 ` Miquel Raynal
2020-04-28 9:10 ` Boris Brezillon
2020-04-24 16:40 ` [PATCH v2 4/9] mtd: rawnand: onfi: Use intermediate variables to improve readability Miquel Raynal
2020-04-24 16:40 ` Miquel Raynal [this message]
2020-04-25 8:25 ` [PATCH v2 5/9] mtd: rawnand: onfi: Define the number of parameter pages Boris Brezillon
2020-04-25 8:28 ` Boris Brezillon
2020-04-28 9:36 ` Miquel Raynal
2020-04-28 9:38 ` Boris Brezillon
2020-04-28 9:39 ` Miquel Raynal
2020-04-24 16:40 ` [PATCH v2 6/9] mtd: rawnand: onfi: Avoid doing a copy of the parameter page Miquel Raynal
2020-04-24 16:40 ` [PATCH v2 7/9] mtd: rawnand: onfi: Drop a useless parameter page read Miquel Raynal
2020-04-25 8:26 ` Boris Brezillon
2020-04-24 16:40 ` [PATCH v2 8/9] mtd: rawnand: jedec: Define the number of parameter pages Miquel Raynal
2020-04-25 8:26 ` Boris Brezillon
2020-04-24 16:40 ` [PATCH v2 9/9] mtd: rawnand: jedec: Use intermediate variables to improve readability Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200424164042.26572-6-miquel.raynal@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=Tudor.Ambarus@microchip.com \
--cc=boris.brezillon@collabora.com \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=thomas.petazzoni@bootlin.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.