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:
Родитель
74e24cd237
Коммит
dbc2f2e6d5
|
@ -5043,17 +5043,20 @@ static const char * const nand_ecc_algos[] = {
|
|||
[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;
|
||||
int err, i;
|
||||
int err;
|
||||
|
||||
err = of_property_read_string(np, "nand-ecc-algo", &pm);
|
||||
if (!err) {
|
||||
for (i = NAND_ECC_HAMMING; i < ARRAY_SIZE(nand_ecc_algos); i++)
|
||||
if (!strcasecmp(pm, nand_ecc_algos[i]))
|
||||
return i;
|
||||
return -ENODEV;
|
||||
for (ecc_algo = NAND_ECC_HAMMING;
|
||||
ecc_algo < ARRAY_SIZE(nand_ecc_algos);
|
||||
ecc_algo++) {
|
||||
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.
|
||||
*/
|
||||
err = of_property_read_string(np, "nand-ecc-mode", &pm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
if (!err) {
|
||||
if (!strcasecmp(pm, "soft"))
|
||||
return NAND_ECC_HAMMING;
|
||||
else if (!strcasecmp(pm, "soft_bch"))
|
||||
return NAND_ECC_BCH;
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
return NAND_ECC_UNKNOWN;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
return 0;
|
||||
|
@ -5136,7 +5139,7 @@ static int nand_dt_init(struct nand_chip *chip)
|
|||
if (ecc_mode >= 0)
|
||||
chip->ecc.mode = ecc_mode;
|
||||
|
||||
if (ecc_algo >= 0)
|
||||
if (ecc_algo != NAND_ECC_UNKNOWN)
|
||||
chip->ecc.algo = ecc_algo;
|
||||
|
||||
if (ecc_strength >= 0)
|
||||
|
|
Загрузка…
Ссылка в новой задаче