linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: computersforpeace@gmail.com (Brian Norris)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] mtd: nand: sunxi: rely on nand_dt_init initialization
Date: Tue, 1 Sep 2015 18:16:16 -0700	[thread overview]
Message-ID: <20150902011616.GP81844@google.com> (raw)
In-Reply-To: <1440411031-8910-1-git-send-email-boris.brezillon@free-electrons.com>

On Mon, Aug 24, 2015 at 12:10:31PM +0200, Boris Brezillon wrote:
> nand_dt_init(), called from nand_scan_ident(), is already parsing the
> generic MTD/NAND DT properties, and initializing the nand_chip struct
> accordingly.
> Rely on this initialization instead of manually parsing those properties.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> Changes since v1:
> - drop unused strength and blk_size variables

Good catch, I was about to comment on v1 :)

> ---
>  drivers/mtd/nand/sunxi_nand.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index 96dda70..92a2c58 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -1164,16 +1164,9 @@ static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc,
>  			       struct device_node *np)
>  {
>  	struct nand_chip *nand = mtd->priv;
> -	int strength;
> -	int blk_size;
>  	int ret;
>  
> -	blk_size = of_get_nand_ecc_step_size(np);
> -	strength = of_get_nand_ecc_strength(np);
> -	if (blk_size > 0 && strength > 0) {
> -		ecc->size = blk_size;
> -		ecc->strength = strength;
> -	} else {
> +	if (!ecc->size) {
>  		ecc->size = nand->ecc_step_ds;
>  		ecc->strength = nand->ecc_strength_ds;
>  	}
> @@ -1183,10 +1176,6 @@ static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc,
>  
>  	ecc->mode = NAND_ECC_HW;
>  
> -	ret = of_get_nand_ecc_mode(np);
> -	if (ret >= 0)
> -		ecc->mode = ret;
> -

I think you've missed something here. You're now *only* allowing HW ECC!
You now want to make this a default case.

There's also a subtle change here that affects more than just here: you
don't have a good way to tell the difference between "no ECC mode
provide" and NAND_ECC_NONE. Perhaps we can modify the nand_ecc_modes_t
enum to include a "uninitialized" value? I'm not sure if that'd work
best as 0, -1, or something else, in case there are people making
assumptions elsewhere...

>  	switch (ecc->mode) {
>  	case NAND_ECC_SOFT_BCH:
>  		break;
> @@ -1312,15 +1301,13 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
>  	/* Default tR value specified in the ONFI spec (chapter 4.15.1) */
>  	nand->chip_delay = 200;
>  	nand->controller = &nfc->controller;
> +	nand->dn = np;
>  	nand->select_chip = sunxi_nfc_select_chip;
>  	nand->cmd_ctrl = sunxi_nfc_cmd_ctrl;
>  	nand->read_buf = sunxi_nfc_read_buf;
>  	nand->write_buf = sunxi_nfc_write_buf;
>  	nand->read_byte = sunxi_nfc_read_byte;
>  
> -	if (of_get_nand_on_flash_bbt(np))
> -		nand->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
> -
>  	mtd = &chip->mtd;
>  	mtd->dev.parent = dev;
>  	mtd->priv = nand;
> @@ -1330,6 +1317,9 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
>  	if (ret)
>  		return ret;
>  
> +	if (nand->bbt_options & NAND_BBT_USE_FLASH)
> +		nand->bbt_options |= NAND_BBT_NO_OOB;
> +
>  	ret = sunxi_nand_chip_init_timings(chip, np);
>  	if (ret) {
>  		dev_err(dev, "could not configure chip timings: %d\n", ret);

Brian

  reply	other threads:[~2015-09-02  1:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24 10:10 [PATCH v2] mtd: nand: sunxi: rely on nand_dt_init initialization Boris Brezillon
2015-09-02  1:16 ` Brian Norris [this message]
2015-09-02  8:21   ` Boris Brezillon
2015-09-04 15:58     ` Brian Norris

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=20150902011616.GP81844@google.com \
    --to=computersforpeace@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).