public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Peter Pan <peterpansjtu@gmail.com>
Cc: Peter Pan <peterpandong@micron.com>,
	Richard Weinberger <richard@nod.at>,
	Brian Norris <computersforpeace@gmail.com>,
	linux-mtd@lists.infradead.org,
	"linshunquan (A)" <linshunquan1@hisilicon.com>
Subject: Re: [PATCH 04/11] nand: spi: Add read function support
Date: Tue, 21 Feb 2017 12:02:13 +0100	[thread overview]
Message-ID: <20170221120213.1f7c7728@bbrezillon> (raw)
In-Reply-To: <CAAyFORKDNpkycQ-n5yg=H+fmu6v4teUhwzcXEa-SROV_8kVOBA@mail.gmail.com>

On Tue, 21 Feb 2017 18:06:03 +0800
Peter Pan <peterpansjtu@gmail.com> wrote:



> >> +/**
> >> + * spi_nand_transfer_oob - transfer oob to client buffer
> >> + * @chip: SPI-NAND device structure
> >> + * @oob: oob destination address
> >> + * @ops: oob ops structure
> >> + * @len: size of oob to transfer
> >> + */
> >> +static void spi_nand_transfer_oob(struct spi_nand_chip *chip, u8 *oob,
> >> +                               struct mtd_oob_ops *ops, size_t len)
> >> +{
> >> +     struct mtd_info *mtd = spi_nand_to_mtd(chip);
> >> +     int ret;
> >> +
> >> +     switch (ops->mode) {
> >> +
> >> +     case MTD_OPS_PLACE_OOB:
> >> +     case MTD_OPS_RAW:
> >> +             memcpy(oob, chip->oobbuf + ops->ooboffs, len);
> >> +             return;
> >> +
> >> +     case MTD_OPS_AUTO_OOB:
> >> +             ret = mtd_ooblayout_get_databytes(mtd, oob, chip->oobbuf,
> >> +                                               ops->ooboffs, len);
> >> +             BUG_ON(ret);
> >> +             return;
> >> +
> >> +     default:
> >> +             BUG();  
> >
> > Let's try to avoid these BUG_ON() calls. If you want transfer_oob() to
> > report an error, change the function prototype and check the ret code
> > in the caller.  
> 
> I will remove the BUG_ON()s in v2. Boris, I think this part can be put in
> new NAND core, what do you think?

Well, assuming we move the ->oob buffer in nand_device struct, then
yes. That's exactly for this reason I wanted to see a version of the
SPI NAND framework before merging the "interface-agnostic NAND layer".
I guess we'll find other candidates for factorization, but I also think
we should not try to get the perfect implementation before merging
something (IOW, let's keep this improvement on our TODO list).

> 
> >  
> >> +     }
> >> +}

  parent reply	other threads:[~2017-02-21 11:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21  7:59 [PATCH 00/11] Introduction to SPI NAND framework Peter Pan
2017-02-21  8:00 ` [PATCH 01/11] nand: Add SPI NAND cmd set and register definition Peter Pan
2017-02-21  8:44   ` Boris Brezillon
2017-02-21  9:16     ` Peter Pan
2017-02-21  8:00 ` [PATCH 02/11] nand: spi: create spi_nand_chip struct Peter Pan
2017-02-21  8:34   ` Boris Brezillon
2017-02-21  9:08     ` Peter Pan
2017-02-21  8:00 ` [PATCH 03/11] nand: spi: Abstract SPI NAND cmd set to functions Peter Pan
2017-02-21  9:01   ` Arnaud Mouiche
2017-02-21  9:40     ` Peter Pan
2017-02-21 10:22       ` Arnaud Mouiche
2017-02-21 10:50         ` Boris Brezillon
2017-02-21  9:06   ` Boris Brezillon
2017-02-21  9:27     ` Peter Pan
2017-02-21  8:00 ` [PATCH 04/11] nand: spi: Add read function support Peter Pan
2017-02-21  9:51   ` Boris Brezillon
2017-02-21 10:06     ` Peter Pan
2017-02-21 10:39       ` Boris Brezillon
2017-02-21 11:02       ` Boris Brezillon [this message]
2017-02-21  8:00 ` [PATCH 05/11] nand: spi: Add write " Peter Pan
2017-02-21  8:00 ` [PATCH 06/11] nand: spi: Add erase " Peter Pan
2017-02-21  8:00 ` [PATCH 07/11] nand: spi: Add init/release function Peter Pan
2017-02-21  8:00 ` [PATCH 08/11] nand: spi: Add bad block support Peter Pan
2017-02-21  8:00 ` [PATCH 09/11] nand: spi: Add BBT support Peter Pan
2017-02-21  8:00 ` [PATCH 10/11] nand: spi: Add generic SPI controller support Peter Pan
2017-02-21  8:03   ` Richard Weinberger
2017-02-21  8:17     ` Peter Pan
2017-02-21  9:25   ` Arnaud Mouiche
2017-02-21  9:37     ` Peter Pan
2017-02-21  8:00 ` [PATCH 11/11] nand: spi: Add arguments check for read/write Peter Pan
2017-02-21  8:05 ` [PATCH 00/11] Introduction to SPI NAND framework Richard Weinberger
2017-02-21  8:11   ` Peter Pan
2017-02-21  8:18     ` Peter Pan
2017-02-21  8:43 ` Boris Brezillon
2017-02-21  9:15   ` Peter Pan

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=20170221120213.1f7c7728@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=linshunquan1@hisilicon.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=peterpandong@micron.com \
    --cc=peterpansjtu@gmail.com \
    --cc=richard@nod.at \
    /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