[PATCH v1] mtd: rawnand: meson: handle OOB buffer according OOB layout
Viacheslav Bocharov
adeep at lexina.in
Thu Nov 9 00:06:58 PST 2023
Hi!
On Thu, 2023-11-09 at 08:39 +0300, Arseniy Krasnov wrote:
> In case of MTD_OPS_AUTO_OOB mode, MTD/NAND layer fills/reads OOB buffer
> according current OOB layout so we need to follow it in the driver.
>
> Signed-off-by: Arseniy Krasnov <avkrasnov at salutedevices.com>
> ---
> drivers/mtd/nand/raw/meson_nand.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
> index 561d46d860b7..0d4d358152d7 100644
> --- a/drivers/mtd/nand/raw/meson_nand.c
> +++ b/drivers/mtd/nand/raw/meson_nand.c
> @@ -510,7 +510,7 @@ static void meson_nfc_set_user_byte(struct nand_chip *nand, u8 *oob_buf)
> __le64 *info;
> int i, count;
>
> - for (i = 0, count = 0; i < nand->ecc.steps; i++, count += 2) {
> + for (i = 0, count = 0; i < nand->ecc.steps; i++, count += (2 + nand->ecc.bytes)) {
> info = &meson_chip->info_buf[i];
> *info |= oob_buf[count];
> *info |= oob_buf[count + 1] << 8;
Seems something wrong with your logic here.
I think this code should most likely look like this:
for (i = 0, count = 0; i < nand->ecc.steps; i++, count += nand->ecc.bytes) {
info = &meson_chip->info_buf[i];
*info |= oob_buf[count];
if (nand->ecc.bytes > 1)
*info |= oob_buf[count + 1] << 8;
}
> @@ -523,7 +523,7 @@ static void meson_nfc_get_user_byte(struct nand_chip *nand, u8 *oob_buf)
> __le64 *info;
> int i, count;
>
> - for (i = 0, count = 0; i < nand->ecc.steps; i++, count += 2) {
> + for (i = 0, count = 0; i < nand->ecc.steps; i++, count += (2 + nand->ecc.bytes)) {
> info = &meson_chip->info_buf[i];
> oob_buf[count] = *info;
> oob_buf[count + 1] = *info >> 8;
And there:
for (i = 0, count = 0; i < nand->ecc.steps; i++, count += nand->ecc.bytes) {
info = &meson_chip->info_buf[i];
oob_buf[count] = *info;
if (nand->ecc.bytes > 1)
oob_buf[count + 1] = *info >> 8;
}
This is more similar to the behavior of similar functions in the proprietary U-Boot.
--
Viacheslav Bocharov
More information about the linux-amlogic
mailing list