public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH 0/3] mtd: nand: add enum nand_ecc_algo
Date: Wed, 23 Mar 2016 10:00:59 +0100	[thread overview]
Message-ID: <20160323100059.64ad9bb3@bbrezillon> (raw)
In-Reply-To: <1458687254-26181-1-git-send-email-zajec5@gmail.com>

Hi Rafal,

On Tue, 22 Mar 2016 23:54:11 +0100
Rafał Miłecki <zajec5@gmail.com> wrote:

> Some time ago I started working on a new "nand-ecc-algo" property to allow
> specifying ECC algorithm for hardware ECC mode as well.
> Boris pointed out it's becoming a bit messy that way as we already have value
> NAND_ECC_SOFT_BCH.
> I suggested deprecating "soft_bch" value from nand-ecc-mode property and got
> Boris agreed and no objections from others. So there is how I want to implement
> this.
> If you agree on this way & apply my patches, I'll start modifying NAND drivers
> (similarly to the nandsim) and then will try to drop NAND_ECC_SOFT_BCH except
> for handling backward compatibility.
> Then finally we should be able to add "nand-ecc-algo" property support properly.

I agree with patch 1 and 3, but I think we should create an
of_get_nand_ecc_algo() helper right now instead of relying on the
ecc->mode value to set ecc->algo (I'm referring to patch 2).

int of_get_nand_ecc_algo(struct device_node *np)
{
	const char *pm;
	int err, i;

	err = of_property_read_string(np, "nand-ecc-algo", &pm);
	if (err < 0) {
		if (!of_property_read_string(np, "nand-ecc-mode", &pm)){
			if (!strcasecmp(pm, "soft"))
				err = NAND_ECC_HAMMING;
			else if (!strcasecmp(pm, "soft_bch"))
				err = NAND_ECC_BCH;
		}

		return err;
	}

	for (i = 0; i < ARRAY_SIZE(nand_ecc_algos); i++)
		if (!strcasecmp(pm, nand_ecc_algos[i]))
			return i;

	return -EINVAL;
}
EXPORT_SYMBOL_GPL(of_get_nand_ecc_algo);

This way you'll be able to completely drop NAND_ECC_SOFT_BCH value when
all drivers have been patched.
BTW, even if we deprecate the DT property, we still have to support the
old format, so this extra "nand-ecc-mode" parsing will remain anyway.

And has already said ealier, I think we should also move the ecc layout
info somewhere else, and only leave ECC_NONE, ECC_HW and ECC_SOFT in
nand_ecc_modes_t enum. I'm not asking you to do that though, just
clarifying the separation I'd like to see ;).

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  parent reply	other threads:[~2016-03-23  9:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 22:54 [PATCH 0/3] mtd: nand: add enum nand_ecc_algo Rafał Miłecki
2016-03-22 22:54 ` [PATCH 1/3] mtd: nand: add new enum for storing ECC algorithm Rafał Miłecki
2016-03-22 22:54 ` [PATCH 2/3] mtd: nand: set ECC algorithm in nand_dt_init Rafał Miłecki
2016-03-22 22:54 ` [PATCH 3/3] mtd: nand: nandsim: set ECC algorithm explicitly Rafał Miłecki
2016-03-23  9:00 ` Boris Brezillon [this message]
2016-03-23  9:10   ` [PATCH 0/3] mtd: nand: add enum nand_ecc_algo Rafał Miłecki

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=20160323100059.64ad9bb3@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=zajec5@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