public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Mike Dunn <mikedunn@newsguy.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Jamie Iles <jamie@jamieiles.com>,
	Scott Branden <sbranden@broadcom.com>,
	Wan ZongShun <mcuos.com@gmail.com>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Andres Salomon <dilinger@queued.net>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Manuel Lauss <manuel.lauss@googlemail.com>,
	linux-mtd@lists.infradead.org, Ralf Baechle <ralf@linux-mips.org>,
	Jiandong Zheng <jdzheng@broadcom.com>,
	Sukumar Ghorai <s-ghorai@ti.com>, Olof Johansson <olof@lixom.net>,
	Vimal Singh <vimal.newwork@gmail.com>,
	Brian Norris <computersforpeace@gmail.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>
Subject: Re: [PATCH 2/5] backport mtd api change to mtd infrastructure
Date: Thu, 01 Dec 2011 10:59:09 +0200	[thread overview]
Message-ID: <1322729952.2332.25.camel@koala> (raw)
In-Reply-To: <1322528536-19700-1-git-send-email-mikedunn@newsguy.com>

On Mon, 2011-11-28 at 17:02 -0800, Mike Dunn wrote:
> diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
> index 7c1dc90..ada714d 100644
> --- a/drivers/mtd/mtdblock.c
> +++ b/drivers/mtd/mtdblock.c
> @@ -182,10 +182,13 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
>  
>  			if (mtdblk->cache_state == STATE_EMPTY ||
>  			    mtdblk->cache_offset != sect_start) {
> +				unsigned int max_bitflips;
> +
>  				/* fill the cache with the current sector */
>  				mtdblk->cache_state = STATE_EMPTY;
>  				ret = mtd->read(mtd, sect_start, sect_size,
> -						&retlen, mtdblk->cache_data);
> +						&retlen, mtdblk->cache_data,
> +						&max_bitflips);

Now difficult would it be to allow for NULL to be passed as the last
argument? I think it makes sense to do so that the callers who do not
care about the max. bit-flips just pass NULL and they would not have to
define an dummy 'int max_bitflips' variable which they do not need at
all. And the amount of changes you introduce would be smaller.

E.g. in this case, you would just add on NULL argument to mtd->read.

Probably the implementations would need to do something like this:

int tmp;

if (!max_bitflips)
	max_bitflips = &tmp;

So it does not seem to be difficult to implement.

> -			ret = mtd->read(mtd, *ppos, len, &retlen, kbuf);
> +			ret = mtd->read(mtd, *ppos, len, &retlen, kbuf,
> +					&max_bitflips);
>  		}
>  		/* Nand returns -EBADMSG on ECC errors, but it returns
>  		 * the data. For our userspace tools it is important
>  		 * to dump areas with ECC errors!
>  		 * For kernel internal usage it also might return -EUCLEAN
> -		 * to signal the caller that a bitflip has occurred and has
> -		 * been corrected by the ECC algorithm.
> +		 * to signal the caller that one or more bitflips have occurred
> +		 * and have been corrected by the ECC algorithm.  The highest
> +		 * number of corrected bits in a single page is returned in the
> +		 * max_bitflips arg.

If you do what I proposed you won't need to change the comment here and
in mtd_do_readoob().

Artem.

      reply	other threads:[~2011-12-01  8:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-29  1:02 [PATCH 2/5] backport mtd api change to mtd infrastructure Mike Dunn
2011-12-01  8:59 ` Artem Bityutskiy [this message]

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=1322729952.2332.25.camel@koala \
    --to=dedekind1@gmail.com \
    --cc=computersforpeace@gmail.com \
    --cc=dbaryshkov@gmail.com \
    --cc=dilinger@queued.net \
    --cc=dwmw2@infradead.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=jamie@jamieiles.com \
    --cc=jdzheng@broadcom.com \
    --cc=kyungmin.park@samsung.com \
    --cc=lars@metafoo.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=manuel.lauss@googlemail.com \
    --cc=mcuos.com@gmail.com \
    --cc=mikedunn@newsguy.com \
    --cc=olof@lixom.net \
    --cc=ralf@linux-mips.org \
    --cc=robert.jarzmik@free.fr \
    --cc=s-ghorai@ti.com \
    --cc=sbranden@broadcom.com \
    --cc=vimal.newwork@gmail.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