@@ -6085,24 +6085,17 @@ static int nand_set_ecc_soft_ops(struct mtd_info *mtd)
6085
6085
* by the controller and the calculated ECC bytes fit within the chip's OOB.
6086
6086
* On success, the calculated ECC bytes is set.
6087
6087
*/
6088
- int nand_check_ecc_caps (struct nand_chip * chip ,
6089
- const struct nand_ecc_caps * caps , int oobavail )
6088
+ static int
6089
+ nand_check_ecc_caps (struct nand_chip * chip ,
6090
+ const struct nand_ecc_caps * caps , int oobavail )
6090
6091
{
6091
6092
struct mtd_info * mtd = nand_to_mtd (chip );
6092
6093
const struct nand_ecc_step_info * stepinfo ;
6093
6094
int preset_step = chip -> ecc .size ;
6094
6095
int preset_strength = chip -> ecc .strength ;
6095
- int nsteps , ecc_bytes ;
6096
+ int ecc_bytes , nsteps = mtd -> writesize / preset_step ;
6096
6097
int i , j ;
6097
6098
6098
- if (WARN_ON (oobavail < 0 ))
6099
- return - EINVAL ;
6100
-
6101
- if (!preset_step || !preset_strength )
6102
- return - ENODATA ;
6103
-
6104
- nsteps = mtd -> writesize / preset_step ;
6105
-
6106
6099
for (i = 0 ; i < caps -> nstepinfos ; i ++ ) {
6107
6100
stepinfo = & caps -> stepinfos [i ];
6108
6101
@@ -6135,7 +6128,6 @@ int nand_check_ecc_caps(struct nand_chip *chip,
6135
6128
6136
6129
return - ENOTSUPP ;
6137
6130
}
6138
- EXPORT_SYMBOL_GPL (nand_check_ecc_caps );
6139
6131
6140
6132
/**
6141
6133
* nand_match_ecc_req - meet the chip's requirement with least ECC bytes
@@ -6147,8 +6139,9 @@ EXPORT_SYMBOL_GPL(nand_check_ecc_caps);
6147
6139
* number of ECC bytes (i.e. with the largest number of OOB-free bytes).
6148
6140
* On success, the chosen ECC settings are set.
6149
6141
*/
6150
- int nand_match_ecc_req (struct nand_chip * chip ,
6151
- const struct nand_ecc_caps * caps , int oobavail )
6142
+ static int
6143
+ nand_match_ecc_req (struct nand_chip * chip ,
6144
+ const struct nand_ecc_caps * caps , int oobavail )
6152
6145
{
6153
6146
struct mtd_info * mtd = nand_to_mtd (chip );
6154
6147
const struct nand_ecc_step_info * stepinfo ;
@@ -6159,9 +6152,6 @@ int nand_match_ecc_req(struct nand_chip *chip,
6159
6152
int best_ecc_bytes_total = INT_MAX ;
6160
6153
int i , j ;
6161
6154
6162
- if (WARN_ON (oobavail < 0 ))
6163
- return - EINVAL ;
6164
-
6165
6155
/* No information provided by the NAND chip */
6166
6156
if (!req_step || !req_strength )
6167
6157
return - ENOTSUPP ;
@@ -6220,7 +6210,6 @@ int nand_match_ecc_req(struct nand_chip *chip,
6220
6210
6221
6211
return 0 ;
6222
6212
}
6223
- EXPORT_SYMBOL_GPL (nand_match_ecc_req );
6224
6213
6225
6214
/**
6226
6215
* nand_maximize_ecc - choose the max ECC strength available
@@ -6231,8 +6220,9 @@ EXPORT_SYMBOL_GPL(nand_match_ecc_req);
6231
6220
* Choose the max ECC strength that is supported on the controller, and can fit
6232
6221
* within the chip's OOB. On success, the chosen ECC settings are set.
6233
6222
*/
6234
- int nand_maximize_ecc (struct nand_chip * chip ,
6235
- const struct nand_ecc_caps * caps , int oobavail )
6223
+ static int
6224
+ nand_maximize_ecc (struct nand_chip * chip ,
6225
+ const struct nand_ecc_caps * caps , int oobavail )
6236
6226
{
6237
6227
struct mtd_info * mtd = nand_to_mtd (chip );
6238
6228
const struct nand_ecc_step_info * stepinfo ;
@@ -6242,9 +6232,6 @@ int nand_maximize_ecc(struct nand_chip *chip,
6242
6232
int best_strength , best_ecc_bytes ;
6243
6233
int i , j ;
6244
6234
6245
- if (WARN_ON (oobavail < 0 ))
6246
- return - EINVAL ;
6247
-
6248
6235
for (i = 0 ; i < caps -> nstepinfos ; i ++ ) {
6249
6236
stepinfo = & caps -> stepinfos [i ];
6250
6237
step_size = stepinfo -> stepsize ;
@@ -6293,7 +6280,6 @@ int nand_maximize_ecc(struct nand_chip *chip,
6293
6280
6294
6281
return 0 ;
6295
6282
}
6296
- EXPORT_SYMBOL_GPL (nand_maximize_ecc );
6297
6283
6298
6284
/**
6299
6285
* nand_ecc_choose_conf - Set the ECC strength and ECC step size
@@ -6315,6 +6301,11 @@ EXPORT_SYMBOL_GPL(nand_maximize_ecc);
6315
6301
int nand_ecc_choose_conf (struct nand_chip * chip ,
6316
6302
const struct nand_ecc_caps * caps , int oobavail )
6317
6303
{
6304
+ struct mtd_info * mtd = nand_to_mtd (chip );
6305
+
6306
+ if (WARN_ON (oobavail < 0 || oobavail > mtd -> oobsize ))
6307
+ return - EINVAL ;
6308
+
6318
6309
if (chip -> ecc .size && chip -> ecc .strength )
6319
6310
return nand_check_ecc_caps (chip , caps , oobavail );
6320
6311
0 commit comments