linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Shivamurthy Shastri (sshivamurthy)" <sshivamurthy@micron.com>
To: 'Miquel Raynal' <miquel.raynal@bootlin.com>
Cc: Chuanhong Guo <gch981213@gmail.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Boris Brezillon <bbrezillon@kernel.org>,
	Marcel Ziswiler <marcel.ziswiler@toradex.com>,
	Richard Weinberger <richard@nod.at>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	liaoweixiong <liaoweixiong@allwinnertech.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	Jeff Kletsky <git-commits@allycomm.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: RE: [EXT] Re: [PATCH 2/8] mtd: nand: move support functions for ONFI to nand/onfi.c
Date: Mon, 19 Aug 2019 08:36:11 +0000	[thread overview]
Message-ID: <MN2PR08MB5951FC43B93D6B1868D5AD6EB8A80@MN2PR08MB5951.namprd08.prod.outlook.com> (raw)
In-Reply-To: <20190807110332.748d2c14@xps13>

Hi Miquel,

> 
> Hi shiva.linuxworks@gmail.com,
> 
> shiva.linuxworks@gmail.com wrote on Mon, 22 Jul 2019 07:56:15 +0200:
> 
> > From: Shivamurthy Shastri <sshivamurthy@micron.com>
> 
> "mtd: nand: move ONFI specific helpers to nand/onfi.c"?

I will use this.

> 
> >
> > These functions are support functions for enabling ONFI standard and
> > common between raw NAND and SPI NAND.
> 
> "
> These are ONFI specific helpers that might be shared between raw and
> SPI NAND logics, move them to a generic place.
> 
> While at it, add kernel doc on the function parameters.
> "
> 

I will use this.

> >
> > Signed-off-by: Shivamurthy Shastri <sshivamurthy@micron.com>
> > ---
> >  drivers/mtd/nand/Makefile        |  2 +-
> >  drivers/mtd/nand/onfi.c          | 89
> ++++++++++++++++++++++++++++++++
> >  drivers/mtd/nand/raw/nand_base.c | 18 -------
> >  drivers/mtd/nand/raw/nand_onfi.c | 43 ---------------
> >  4 files changed, 90 insertions(+), 62 deletions(-)
> >  create mode 100644 drivers/mtd/nand/onfi.c
> >
> > diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
> > index 7ecd80c0a66e..221945c223c3 100644
> > --- a/drivers/mtd/nand/Makefile
> > +++ b/drivers/mtd/nand/Makefile
> > @@ -1,6 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >
> > -nandcore-objs := core.o bbt.o
> > +nandcore-objs := core.o bbt.o onfi.o
> >  obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
> >
> >  obj-y	+= onenand/
> > diff --git a/drivers/mtd/nand/onfi.c b/drivers/mtd/nand/onfi.c
> > new file mode 100644
> > index 000000000000..7aaf36dfc5e0
> > --- /dev/null
> > +++ b/drivers/mtd/nand/onfi.c
> > @@ -0,0 +1,89 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +#define pr_fmt(fmt)     "nand-onfi: " fmt
> > +
> > +#include <linux/mtd/onfi.h>
> > +#include <linux/mtd/nand.h>
> > +
> > +/**
> > + * onfi_crc16() - Check CRC of ONFI table
> 
> There is no check in this function.
> 
>                      Derive the CRC of an ONFI table

okay.

> 
> > + * @crc: base CRC
> > + * @p: buffer pointing to ONFI table
>                             ^ the
> > + * @len: length of ONFI table
>                      ^the
> > + *
> > + * Return: CRC of the ONFI table
>       @return: the CRC of the given ONFI table
> 
> > + */
> > +u16 onfi_crc16(u16 crc, u8 const *p, size_t len)
> > +{
> > +	int i;
> > +
> > +	while (len--) {
> > +		crc ^= *p++ << 8;
> > +		for (i = 0; i < 8; i++)
> > +			crc = (crc << 1) ^ ((crc & 0x8000) ? 0x8005 : 0);
> > +	}
> > +
> > +	return crc;
> > +}
> > +EXPORT_SYMBOL_GPL(onfi_crc16);
> > +
> > +/**
> > + * nand_bit_wise_majority() - Recover data with bit-wise majority
> > + * @srcbufs: buffer pointing to ONFI table
> > + * @nsrcbufs: length of ONFI table
>                          ^the
> > + * @dstbuf: valid ONFI table to be returned
> > + * @bufsize: length og valid ONFI table
>                        of the valid...
> > + *
> 
> Extra line
> 
> > + */
> > +void nand_bit_wise_majority(const void **srcbufs,
> > +			    unsigned int nsrcbufs,
> > +			    void *dstbuf,
> > +			    unsigned int bufsize)
> > +{
> > +	int i, j, k;
> > +
> > +	for (i = 0; i < bufsize; i++) {
> > +		u8 val = 0;
> > +
> > +		for (j = 0; j < 8; j++) {
> > +			unsigned int cnt = 0;
> > +
> > +			for (k = 0; k < nsrcbufs; k++) {
> > +				const u8 *srcbuf = srcbufs[k];
> > +
> > +				if (srcbuf[i] & BIT(j))
> > +					cnt++;
> > +			}
> > +
> > +			if (cnt > nsrcbufs / 2)
> > +				val |= BIT(j);
> > +		}
> > +
> > +		((u8 *)dstbuf)[i] = val;
> > +	}
> > +}
> > +EXPORT_SYMBOL_GPL(nand_bit_wise_majority);
> > +
> > +/**
> > + * sanitize_string() - Sanitize ONFI strings so we can safely print them
> 
> It is used by JEDEC logic so this should be moved elsewhere and not
> refer to any ONFI naming.

okay, I will move this.

> 
> > + * @s: string to be sanitized
> > + * @len: length of the string
> > + *
> > + */
> > +void sanitize_string(u8 *s, size_t len)
> > +{
> > +	ssize_t i;
> > +
> > +	/* Null terminate */
> > +	s[len - 1] = 0;
> > +
> > +	/* Remove non printable chars */
> > +	for (i = 0; i < len - 1; i++) {
> > +		if (s[i] < ' ' || s[i] > 127)
> > +			s[i] = '?';
> > +	}
> > +
> > +	/* Remove trailing spaces */
> > +	strim(s);
> > +}
> > +EXPORT_SYMBOL_GPL(sanitize_string);
> > diff --git a/drivers/mtd/nand/raw/nand_base.c
> b/drivers/mtd/nand/raw/nand_base.c
> > index 6ecd1c496ce3..c198829bcd79 100644
> > --- a/drivers/mtd/nand/raw/nand_base.c
> > +++ b/drivers/mtd/nand/raw/nand_base.c
> > @@ -4375,24 +4375,6 @@ static void nand_set_defaults(struct nand_chip
> *chip)
> >  		chip->buf_align = 1;
> >  }
> >
> > -/* Sanitize ONFI strings so we can safely print them */
> > -void sanitize_string(uint8_t *s, size_t len)
> > -{
> > -	ssize_t i;
> > -
> > -	/* Null terminate */
> > -	s[len - 1] = 0;
> > -
> > -	/* Remove non printable chars */
> > -	for (i = 0; i < len - 1; i++) {
> > -		if (s[i] < ' ' || s[i] > 127)
> > -			s[i] = '?';
> > -	}
> > -
> > -	/* Remove trailing spaces */
> > -	strim(s);
> > -}
> > -
> >  /*
> >   * nand_id_has_period - Check if an ID string has a given wraparound
> period
> >   * @id_data: the ID string
> > diff --git a/drivers/mtd/nand/raw/nand_onfi.c
> b/drivers/mtd/nand/raw/nand_onfi.c
> > index 0b879bd0a68c..2e8edfa636ef 100644
> > --- a/drivers/mtd/nand/raw/nand_onfi.c
> > +++ b/drivers/mtd/nand/raw/nand_onfi.c
> > @@ -16,18 +16,6 @@
> >
> >  #include "internals.h"
> >
> > -u16 onfi_crc16(u16 crc, u8 const *p, size_t len)
> > -{
> > -	int i;
> > -	while (len--) {
> > -		crc ^= *p++ << 8;
> > -		for (i = 0; i < 8; i++)
> > -			crc = (crc << 1) ^ ((crc & 0x8000) ? 0x8005 : 0);
> > -	}
> > -
> > -	return crc;
> > -}
> > -
> >  /* Parse the Extended Parameter Page. */
> >  static int nand_flash_detect_ext_param_page(struct nand_chip *chip,
> >  					    struct nand_onfi_params *p)
> > @@ -103,37 +91,6 @@ static int
> nand_flash_detect_ext_param_page(struct nand_chip *chip,
> >  	return ret;
> >  }
> >
> > -/*
> > - * Recover data with bit-wise majority
> > - */
> > -static void nand_bit_wise_majority(const void **srcbufs,
> > -				   unsigned int nsrcbufs,
> > -				   void *dstbuf,
> > -				   unsigned int bufsize)
> > -{
> > -	int i, j, k;
> > -
> > -	for (i = 0; i < bufsize; i++) {
> > -		u8 val = 0;
> > -
> > -		for (j = 0; j < 8; j++) {
> > -			unsigned int cnt = 0;
> > -
> > -			for (k = 0; k < nsrcbufs; k++) {
> > -				const u8 *srcbuf = srcbufs[k];
> > -
> > -				if (srcbuf[i] & BIT(j))
> > -					cnt++;
> > -			}
> > -
> > -			if (cnt > nsrcbufs / 2)
> > -				val |= BIT(j);
> > -		}
> > -
> > -		((u8 *)dstbuf)[i] = val;
> > -	}
> > -}
> > -
> >  /*
> >   * Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise.
> >   */
> 
> Thanks,
> Miquèl

Thanks,
Shiva
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2019-08-19  8:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22  5:56 [PATCH 0/8] Introduce generic ONFI support shiva.linuxworks
2019-07-22  5:56 ` [PATCH 1/8] mtd: nand: move ONFI related functions to onfi.h shiva.linuxworks
2019-08-07  8:34   ` Miquel Raynal
2019-08-19  8:35     ` [EXT] " Shivamurthy Shastri (sshivamurthy)
2019-07-22  5:56 ` [PATCH 2/8] mtd: nand: move support functions for ONFI to nand/onfi.c shiva.linuxworks
2019-08-07  9:03   ` Miquel Raynal
2019-08-19  8:36     ` Shivamurthy Shastri (sshivamurthy) [this message]
2019-07-22  5:56 ` [PATCH 3/8] mtd: nand: create ONFI table parsing instance shiva.linuxworks
2019-08-07  9:09   ` Miquel Raynal
2019-07-22  5:56 ` [PATCH 4/8] mtd: spinand: enabled parameter page support shiva.linuxworks
2019-08-07  9:48   ` Miquel Raynal
2019-08-19  8:51     ` [EXT] " Shivamurthy Shastri (sshivamurthy)
2019-08-19  9:21       ` Miquel Raynal
2019-09-30 13:23         ` Shivamurthy Shastri (sshivamurthy)
2019-10-07  7:52         ` Boris Brezillon
2019-07-22  5:56 ` [PATCH 5/8] mtd: spinand: micron: prepare for generalizing driver shiva.linuxworks
2019-08-07  9:51   ` Miquel Raynal
2019-07-22  5:56 ` [PATCH 6/8] mtd: spinand: micron: Turn driver implementation generic shiva.linuxworks
2019-08-07 10:04   ` Miquel Raynal
2019-08-19  9:03     ` [EXT] " Shivamurthy Shastri (sshivamurthy)
2019-08-19  9:19       ` Miquel Raynal
2019-09-16 10:41         ` Shivamurthy Shastri (sshivamurthy)
2019-10-07  8:13       ` Boris Brezillon
2019-10-14 12:49         ` Shivamurthy Shastri (sshivamurthy)
2019-07-22  5:56 ` [PATCH 7/8] mtd: spinand: micron: Fix read failure in Micron M70A flashes shiva.linuxworks
2019-08-07 10:05   ` Miquel Raynal
2019-07-22  5:56 ` [PATCH 8/8] mtd: spinand: micron: Enable micron flashes with multi-die shiva.linuxworks
2019-08-07 10:08   ` 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=MN2PR08MB5951FC43B93D6B1868D5AD6EB8A80@MN2PR08MB5951.namprd08.prod.outlook.com \
    --to=sshivamurthy@micron.com \
    --cc=bbrezillon@kernel.org \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=gch981213@gmail.com \
    --cc=git-commits@allycomm.com \
    --cc=liaoweixiong@allwinnertech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marcel.ziswiler@toradex.com \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).