Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[MTD] [NAND] Replace -1 with -EBADMSG in nand error correction code

Magic numerical values are just bad style. Particularly so when
undocumented.

Signed-off-by: Jörn Engel <joern@logfs.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>

authored by

Jörn Engel and committed by
David Woodhouse
eb684507 1dd7fdb1

+6 -4
+2 -2
drivers/mtd/nand/diskonchip.c
··· 220 220 } 221 221 } 222 222 /* If the parity is wrong, no rescue possible */ 223 - return parity ? -1 : nerr; 223 + return parity ? -EBADMSG : nerr; 224 224 } 225 225 226 226 static void DoC_Delay(struct doc_priv *doc, unsigned short cycles) ··· 1034 1034 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf); 1035 1035 else 1036 1036 WriteDOC(DOC_ECC_DIS, docptr, ECCConf); 1037 - if (no_ecc_failures && (ret == -1)) { 1037 + if (no_ecc_failures && (ret == -EBADMSG)) { 1038 1038 printk(KERN_ERR "suppressing ECC failure\n"); 1039 1039 ret = 0; 1040 1040 }
+1 -1
drivers/mtd/nand/nand_ecc.c
··· 189 189 if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1) 190 190 return 1; 191 191 192 - return -1; 192 + return -EBADMSG; 193 193 } 194 194 EXPORT_SYMBOL(nand_correct_data); 195 195
+1 -1
lib/reed_solomon/decode_rs.c
··· 202 202 * deg(lambda) unequal to number of roots => uncorrectable 203 203 * error detected 204 204 */ 205 - count = -1; 205 + count = -EBADMSG; 206 206 goto finish; 207 207 } 208 208 /*
+2
lib/reed_solomon/reed_solomon.c
··· 320 320 * The syndrome and parity uses a uint16_t data type to enable 321 321 * symbol size > 8. The calling code must take care of decoding of the 322 322 * syndrome result and the received parity before calling this code. 323 + * Returns the number of corrected bits or -EBADMSG for uncorrectable errors. 323 324 */ 324 325 int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, 325 326 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, ··· 364 363 * @corr: buffer to store correction bitmask on eras_pos 365 364 * 366 365 * Each field in the data array contains up to symbol size bits of valid data. 366 + * Returns the number of corrected bits or -EBADMSG for uncorrectable errors. 367 367 */ 368 368 int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, 369 369 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,