@@ -75,7 +75,7 @@ static const char bitsperbyte[256] = {
7575 * addressbits is a lookup table to filter out the bits from the xor-ed
7676 * ECC data that identify the faulty location.
7777 * this is only used for repairing parity
78- * see the comments in nand_correct_data for more details
78+ * see the comments in nand_ecc_sw_hamming_correct for more details
7979 */
8080static const char addressbits [256 ] = {
8181 0x00 , 0x00 , 0x01 , 0x01 , 0x00 , 0x00 , 0x01 , 0x01 ,
@@ -112,11 +112,11 @@ static const char addressbits[256] = {
112112 0x0e , 0x0e , 0x0f , 0x0f , 0x0e , 0x0e , 0x0f , 0x0f
113113};
114114
115- void __nand_calculate_ecc (const unsigned char * buf , unsigned int eccsize ,
116- unsigned char * code , bool sm_order )
115+ int ecc_sw_hamming_calculate (const unsigned char * buf , unsigned int step_size ,
116+ unsigned char * code , bool sm_order )
117117{
118118 const u32 * bp = (uint32_t * )buf ;
119- const u32 eccsize_mult = eccsize >> 8 ;
119+ const u32 eccsize_mult = step_size >> 8 ;
120120 /* current value in buffer */
121121 u32 cur ;
122122 /* rp0..rp17 are the various accumulated parities (per byte) */
@@ -347,31 +347,32 @@ void __nand_calculate_ecc(const unsigned char *buf, unsigned int eccsize,
347347 (invparity [par & 0x55 ] << 2 ) |
348348 (invparity [rp17 ] << 1 ) |
349349 (invparity [rp16 ] << 0 );
350+
351+ return 0 ;
350352}
351- EXPORT_SYMBOL (__nand_calculate_ecc );
353+ EXPORT_SYMBOL (ecc_sw_hamming_calculate );
352354
353355/**
354- * nand_calculate_ecc - Calculate 3-byte ECC for 256/512-byte block
355- * @chip : NAND chip object
356+ * nand_ecc_sw_hamming_calculate - Calculate 3-byte ECC for 256/512-byte block
357+ * @nand : NAND device
356358 * @buf: Input buffer with raw data
357359 * @code: Output buffer with ECC
358360 */
359- int nand_calculate_ecc (struct nand_chip * chip , const unsigned char * buf ,
360- unsigned char * code )
361+ int nand_ecc_sw_hamming_calculate (struct nand_device * nand ,
362+ const unsigned char * buf , unsigned char * code )
361363{
364+ struct nand_chip * chip = mtd_to_nand (nanddev_to_mtd (nand ));
362365 bool sm_order = chip -> ecc .options & NAND_ECC_SOFT_HAMMING_SM_ORDER ;
363366
364- __nand_calculate_ecc (buf , chip -> ecc .size , code , sm_order );
365-
366- return 0 ;
367+ return ecc_sw_hamming_calculate (buf , chip -> ecc .size , code , sm_order );
367368}
368- EXPORT_SYMBOL (nand_calculate_ecc );
369+ EXPORT_SYMBOL (nand_ecc_sw_hamming_calculate );
369370
370- int __nand_correct_data (unsigned char * buf ,
371- unsigned char * read_ecc , unsigned char * calc_ecc ,
372- unsigned int eccsize , bool sm_order )
371+ int ecc_sw_hamming_correct (unsigned char * buf , unsigned char * read_ecc ,
372+ unsigned char * calc_ecc , unsigned int step_size ,
373+ bool sm_order )
373374{
374- const u32 eccsize_mult = eccsize >> 8 ;
375+ const u32 eccsize_mult = step_size >> 8 ;
375376 unsigned char b0 , b1 , b2 , bit_addr ;
376377 unsigned int byte_addr ;
377378
@@ -437,26 +438,28 @@ int __nand_correct_data(unsigned char *buf,
437438 pr_err ("%s: uncorrectable ECC error\n" , __func__ );
438439 return - EBADMSG ;
439440}
440- EXPORT_SYMBOL (__nand_correct_data );
441+ EXPORT_SYMBOL (ecc_sw_hamming_correct );
441442
442443/**
443- * nand_correct_data - Detect and correct bit error(s)
444- * @chip : NAND chip object
444+ * nand_ecc_sw_hamming_correct - Detect and correct bit error(s)
445+ * @nand : NAND device
445446 * @buf: Raw data read from the chip
446447 * @read_ecc: ECC bytes read from the chip
447448 * @calc_ecc: ECC calculated from the raw data
448449 *
449450 * Detect and correct up to 1 bit error per 256/512-byte block.
450451 */
451- int nand_correct_data (struct nand_chip * chip , unsigned char * buf ,
452- unsigned char * read_ecc , unsigned char * calc_ecc )
452+ int nand_ecc_sw_hamming_correct (struct nand_device * nand , unsigned char * buf ,
453+ unsigned char * read_ecc ,
454+ unsigned char * calc_ecc )
453455{
456+ struct nand_chip * chip = mtd_to_nand (nanddev_to_mtd (nand ));
454457 bool sm_order = chip -> ecc .options & NAND_ECC_SOFT_HAMMING_SM_ORDER ;
455458
456- return __nand_correct_data (buf , read_ecc , calc_ecc , chip -> ecc .size ,
457- sm_order );
459+ return ecc_sw_hamming_correct (buf , read_ecc , calc_ecc , chip -> ecc .size ,
460+ sm_order );
458461}
459- EXPORT_SYMBOL (nand_correct_data );
462+ EXPORT_SYMBOL (nand_ecc_sw_hamming_correct );
460463
461464MODULE_LICENSE ("GPL" );
462465MODULE_AUTHOR ("Frans Meulenbroeks <fransmeulenbroeks@gmail.com>" );
0 commit comments