mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
mtd: rawnand: Return an enum from of_get_nand_ecc_algo()
There is an enumeration to list ECC algorithm, let's use it instead of returning an int. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Link: https://lore.kernel.org/linux-mtd/20200526195633.11543-6-miquel.raynal@bootlin.com
This commit is contained in:
parent
74e24cd237
commit
dbc2f2e6d5
1 changed files with 19 additions and 16 deletions
|
@ -5043,17 +5043,20 @@ static const char * const nand_ecc_algos[] = {
|
||||||
[NAND_ECC_RS] = "rs",
|
[NAND_ECC_RS] = "rs",
|
||||||
};
|
};
|
||||||
|
|
||||||
static int of_get_nand_ecc_algo(struct device_node *np)
|
static enum nand_ecc_algo of_get_nand_ecc_algo(struct device_node *np)
|
||||||
{
|
{
|
||||||
|
enum nand_ecc_algo ecc_algo;
|
||||||
const char *pm;
|
const char *pm;
|
||||||
int err, i;
|
int err;
|
||||||
|
|
||||||
err = of_property_read_string(np, "nand-ecc-algo", &pm);
|
err = of_property_read_string(np, "nand-ecc-algo", &pm);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
for (i = NAND_ECC_HAMMING; i < ARRAY_SIZE(nand_ecc_algos); i++)
|
for (ecc_algo = NAND_ECC_HAMMING;
|
||||||
if (!strcasecmp(pm, nand_ecc_algos[i]))
|
ecc_algo < ARRAY_SIZE(nand_ecc_algos);
|
||||||
return i;
|
ecc_algo++) {
|
||||||
return -ENODEV;
|
if (!strcasecmp(pm, nand_ecc_algos[ecc_algo]))
|
||||||
|
return ecc_algo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5061,15 +5064,14 @@ static int of_get_nand_ecc_algo(struct device_node *np)
|
||||||
* for some obsoleted values that were specifying ECC algorithm.
|
* for some obsoleted values that were specifying ECC algorithm.
|
||||||
*/
|
*/
|
||||||
err = of_property_read_string(np, "nand-ecc-mode", &pm);
|
err = of_property_read_string(np, "nand-ecc-mode", &pm);
|
||||||
if (err < 0)
|
if (!err) {
|
||||||
return err;
|
if (!strcasecmp(pm, "soft"))
|
||||||
|
return NAND_ECC_HAMMING;
|
||||||
|
else if (!strcasecmp(pm, "soft_bch"))
|
||||||
|
return NAND_ECC_BCH;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcasecmp(pm, "soft"))
|
return NAND_ECC_UNKNOWN;
|
||||||
return NAND_ECC_HAMMING;
|
|
||||||
else if (!strcasecmp(pm, "soft_bch"))
|
|
||||||
return NAND_ECC_BCH;
|
|
||||||
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int of_get_nand_ecc_step_size(struct device_node *np)
|
static int of_get_nand_ecc_step_size(struct device_node *np)
|
||||||
|
@ -5114,7 +5116,8 @@ static bool of_get_nand_on_flash_bbt(struct device_node *np)
|
||||||
static int nand_dt_init(struct nand_chip *chip)
|
static int nand_dt_init(struct nand_chip *chip)
|
||||||
{
|
{
|
||||||
struct device_node *dn = nand_get_flash_node(chip);
|
struct device_node *dn = nand_get_flash_node(chip);
|
||||||
int ecc_mode, ecc_algo, ecc_strength, ecc_step;
|
enum nand_ecc_algo ecc_algo;
|
||||||
|
int ecc_mode, ecc_strength, ecc_step;
|
||||||
|
|
||||||
if (!dn)
|
if (!dn)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5136,7 +5139,7 @@ static int nand_dt_init(struct nand_chip *chip)
|
||||||
if (ecc_mode >= 0)
|
if (ecc_mode >= 0)
|
||||||
chip->ecc.mode = ecc_mode;
|
chip->ecc.mode = ecc_mode;
|
||||||
|
|
||||||
if (ecc_algo >= 0)
|
if (ecc_algo != NAND_ECC_UNKNOWN)
|
||||||
chip->ecc.algo = ecc_algo;
|
chip->ecc.algo = ecc_algo;
|
||||||
|
|
||||||
if (ecc_strength >= 0)
|
if (ecc_strength >= 0)
|
||||||
|
|
Loading…
Reference in a new issue