@@ -5043,33 +5043,35 @@ static const char * const nand_ecc_algos[] = {
5043
5043
[NAND_ECC_RS ] = "rs" ,
5044
5044
};
5045
5045
5046
- static int of_get_nand_ecc_algo (struct device_node * np )
5046
+ static enum nand_ecc_algo of_get_nand_ecc_algo (struct device_node * np )
5047
5047
{
5048
+ enum nand_ecc_algo ecc_algo ;
5048
5049
const char * pm ;
5049
- int err , i ;
5050
+ int err ;
5050
5051
5051
5052
err = of_property_read_string (np , "nand-ecc-algo" , & pm );
5052
5053
if (!err ) {
5053
- for (i = NAND_ECC_HAMMING ; i < ARRAY_SIZE (nand_ecc_algos ); i ++ )
5054
- if (!strcasecmp (pm , nand_ecc_algos [i ]))
5055
- return i ;
5056
- return - ENODEV ;
5054
+ for (ecc_algo = NAND_ECC_HAMMING ;
5055
+ ecc_algo < ARRAY_SIZE (nand_ecc_algos );
5056
+ ecc_algo ++ ) {
5057
+ if (!strcasecmp (pm , nand_ecc_algos [ecc_algo ]))
5058
+ return ecc_algo ;
5059
+ }
5057
5060
}
5058
5061
5059
5062
/*
5060
5063
* For backward compatibility we also read "nand-ecc-mode" checking
5061
5064
* for some obsoleted values that were specifying ECC algorithm.
5062
5065
*/
5063
5066
err = of_property_read_string (np , "nand-ecc-mode" , & pm );
5064
- if (err < 0 )
5065
- return err ;
5066
-
5067
- if (!strcasecmp (pm , "soft" ))
5068
- return NAND_ECC_HAMMING ;
5069
- else if (!strcasecmp (pm , "soft_bch" ))
5070
- return NAND_ECC_BCH ;
5067
+ if (!err ) {
5068
+ if (!strcasecmp (pm , "soft" ))
5069
+ return NAND_ECC_HAMMING ;
5070
+ else if (!strcasecmp (pm , "soft_bch" ))
5071
+ return NAND_ECC_BCH ;
5072
+ }
5071
5073
5072
- return - ENODEV ;
5074
+ return NAND_ECC_UNKNOWN ;
5073
5075
}
5074
5076
5075
5077
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)
5114
5116
static int nand_dt_init (struct nand_chip * chip )
5115
5117
{
5116
5118
struct device_node * dn = nand_get_flash_node (chip );
5117
- int ecc_mode , ecc_algo , ecc_strength , ecc_step ;
5119
+ enum nand_ecc_algo ecc_algo ;
5120
+ int ecc_mode , ecc_strength , ecc_step ;
5118
5121
5119
5122
if (!dn )
5120
5123
return 0 ;
@@ -5136,7 +5139,7 @@ static int nand_dt_init(struct nand_chip *chip)
5136
5139
if (ecc_mode >= 0 )
5137
5140
chip -> ecc .mode = ecc_mode ;
5138
5141
5139
- if (ecc_algo >= 0 )
5142
+ if (ecc_algo != NAND_ECC_UNKNOWN )
5140
5143
chip -> ecc .algo = ecc_algo ;
5141
5144
5142
5145
if (ecc_strength >= 0 )
0 commit comments