public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Ivan Djelic <ivan.djelic@parrot.com>
To: Hong Xu <hong.xu@atmel.com>
Cc: "dwmw2@infradead.org" <dwmw2@infradead.org>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"dedekind1@gmail.com" <dedekind1@gmail.com>
Subject: Re: [PATCH] MTD: atmel_nand: Update driver to support Programmable HW ECC controller
Date: Tue, 31 Jan 2012 10:05:20 +0100	[thread overview]
Message-ID: <20120131090520.GA4993@parrot.com> (raw)
In-Reply-To: <1327979470-11522-1-git-send-email-hong.xu@atmel.com>

On Tue, Jan 31, 2012 at 03:11:10AM +0000, Hong Xu wrote:
(...)
> +static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf,
> +               int extra_bytes, int err_nbr)
> +{
> +       int                     i = 0;
> +       int                     byte_pos, bit_pos;
> +       int                     sector_size, ecc_size;
> +       uint32_t                tmp;
> +       struct nand_chip        *nand_chip = mtd->priv;
> +       struct atmel_nand_host  *host = nand_chip->priv;
> +
> +       sector_size = host->board->sector_size;
> +       ecc_size = nand_chip->ecc.bytes;
> +
> +       while (err_nbr) {
> +               byte_pos = (pmerrloc_readl_el(host->pmerrloc_base, i) - 1) / 8;
> +               bit_pos = (pmerrloc_readl_el(host->pmerrloc_base, i) - 1) % 8;

Hello,
do you really need to read this register twice?

> +               dev_info(host->dev, "PMECC correction, byte_pos: %d "
> +                       "bit_pos: %d\n", byte_pos, bit_pos);
> +
> +               if (byte_pos < (sector_size + extra_bytes)) {
> +                       tmp = sector_size + pmecc_readl(host->ecc, SADDR);
> +                       if (byte_pos < tmp) {

> +                               if (*(buf + byte_pos) & (1 << bit_pos))
> +                                       *(buf + byte_pos) &=
> +                                               (0xFF ^ (1 << bit_pos));
> +                               else
> +                                       *(buf + byte_pos) |= (1 << bit_pos);

why not replace the 5 lines above with:  *(buf + byte_pos) ^= 1 << bit_pos;

> +                       } else {
> +                               if (*(buf + byte_pos + ecc_size) &
> +                                    (1 << bit_pos))
> +                                       *(buf + byte_pos + ecc_size) &=
> +                                               (0xFF ^ (1 << bit_pos));
> +                               else
> +                                       *(buf + byte_pos + ecc_size) |=
> +                                               (1 << bit_pos);

same idea:   *(buf + byte_pos + ecc_size) ^= 1 << bit_pos;

BR,
--
Ivan

  reply	other threads:[~2012-01-31  9:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-31  3:11 [PATCH] MTD: atmel_nand: Update driver to support Programmable HW ECC controller Hong Xu
2012-01-31  9:05 ` Ivan Djelic [this message]
2012-01-31  9:35   ` Xu, Hong
  -- strict thread matches above, loose matches on Subject: below --
2012-02-13  7:17 Hong Xu
2012-02-13  8:45 ` Jean-Christophe PLAGNIOL-VILLARD
2012-02-13  9:04   ` Xu, Hong
2012-02-13 12:08 ` Artem Bityutskiy
2012-02-14  1:10   ` Xu, Hong

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=20120131090520.GA4993@parrot.com \
    --to=ivan.djelic@parrot.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=hong.xu@atmel.com \
    --cc=linux-mtd@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