From: Brian Norris <computersforpeace@gmail.com>
To: Pekon Gupta <pekon@ti.com>
Cc: Stefan Roese <sr@denx.de>, Tony Lindgren <tony@atomide.com>,
Felipe Balbi <balbi@ti.com>,
linux-mtd <linux-mtd@lists.infradead.org>,
Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
linux-omap <linux-omap@vger.kernel.org>
Subject: Re: [PATCH v4 3/4] mtd: nand: omap: add support for BCH16_ECC - NAND driver updates
Date: Tue, 20 May 2014 18:36:32 -0700 [thread overview]
Message-ID: <20140521013632.GD22233@ld-irv-0074> (raw)
In-Reply-To: <1400486082-4345-4-git-send-email-pekon@ti.com>
On Mon, May 19, 2014 at 01:24:41PM +0530, Pekon Gupta wrote:
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -1201,6 +1219,41 @@ static int __maybe_unused omap_calculate_ecc_bch(struct mtd_info *mtd,
> *ecc_code++ = ((bch_val1 >> 4) & 0xFF);
> *ecc_code++ = ((bch_val1 & 0xF) << 4);
> break;
> + case OMAP_ECC_BCH16_CODE_HW:
> + val = readl(gpmc_regs->gpmc_bch_result6[i]);
For all of these 'gpmc_bch_resultX' fields, couldn't you make this into
a 2-D array? So to access BCH result 6 at sector i, it would be:
val = readl(gpmc_regs->gpmc_bch_result[6][i];
This could help you to rewrite some of this stuff as loops, instead of
giant blocks of copy-paste-modify.
> + ecc_code[0] = ((val >> 8) & 0xFF);
> + ecc_code[1] = ((val >> 0) & 0xFF);
> + val = readl(gpmc_regs->gpmc_bch_result5[i]);
> + ecc_code[2] = ((val >> 24) & 0xFF);
> + ecc_code[3] = ((val >> 16) & 0xFF);
> + ecc_code[4] = ((val >> 8) & 0xFF);
> + ecc_code[5] = ((val >> 0) & 0xFF);
A lot of this code can be rewritten to use the endian swapping macros, I
expect. Something like this looks equivalent:
*((uint32_t *)&ecc_code[2]) = cpu_to_be32(val);
You could probably fix the types up to make this look a little nicer.
> + val = readl(gpmc_regs->gpmc_bch_result4[i]);
> + ecc_code[6] = ((val >> 24) & 0xFF);
> + ecc_code[7] = ((val >> 16) & 0xFF);
> + ecc_code[8] = ((val >> 8) & 0xFF);
> + ecc_code[9] = ((val >> 0) & 0xFF);
> + val = readl(gpmc_regs->gpmc_bch_result3[i]);
> + ecc_code[10] = ((val >> 24) & 0xFF);
> + ecc_code[11] = ((val >> 16) & 0xFF);
> + ecc_code[12] = ((val >> 8) & 0xFF);
> + ecc_code[13] = ((val >> 0) & 0xFF);
> + val = readl(gpmc_regs->gpmc_bch_result2[i]);
> + ecc_code[14] = ((val >> 24) & 0xFF);
> + ecc_code[15] = ((val >> 16) & 0xFF);
> + ecc_code[16] = ((val >> 8) & 0xFF);
> + ecc_code[17] = ((val >> 0) & 0xFF);
> + val = readl(gpmc_regs->gpmc_bch_result1[i]);
> + ecc_code[18] = ((val >> 24) & 0xFF);
> + ecc_code[19] = ((val >> 16) & 0xFF);
> + ecc_code[20] = ((val >> 8) & 0xFF);
> + ecc_code[21] = ((val >> 0) & 0xFF);
> + val = readl(gpmc_regs->gpmc_bch_result0[i]);
> + ecc_code[22] = ((val >> 24) & 0xFF);
> + ecc_code[23] = ((val >> 16) & 0xFF);
> + ecc_code[24] = ((val >> 8) & 0xFF);
> + ecc_code[25] = ((val >> 0) & 0xFF);
> + break;
> default:
> return -EINVAL;
> }
Brian
next prev parent reply other threads:[~2014-05-21 1:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 7:54 [PATCH v4 0/4] mtd: nand: omap: add support for BCH16_ECC Pekon Gupta
2014-05-19 7:54 ` [PATCH v4 1/4] mtd: nand: omap: add support for BCH16_ECC - GPMC driver updates Pekon Gupta
2014-05-19 22:35 ` Tony Lindgren
2014-05-19 7:54 ` [PATCH v4 2/4] mtd: nand: omap: add support for BCH16_ECC - ELM " Pekon Gupta
2014-05-19 7:54 ` [PATCH v4 3/4] mtd: nand: omap: add support for BCH16_ECC - NAND " Pekon Gupta
2014-05-21 1:36 ` Brian Norris [this message]
2014-05-19 7:54 ` [PATCH v4 4/4] mtd: nand: omap: Documentation: How to select correct ECC scheme for your device ? Pekon Gupta
2014-05-21 1:05 ` [PATCH v4 0/4] mtd: nand: omap: add support for BCH16_ECC 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=20140521013632.GD22233@ld-irv-0074 \
--to=computersforpeace@gmail.com \
--cc=balbi@ti.com \
--cc=ezequiel.garcia@free-electrons.com \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=pekon@ti.com \
--cc=sr@denx.de \
--cc=tony@atomide.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