@@ -4387,102 +4387,6 @@ void sanitize_string(uint8_t *s, size_t len)
43874387 strim (s );
43884388}
43894389
4390- /*
4391- * Check if the NAND chip is JEDEC compliant, returns 1 if it is, 0 otherwise.
4392- */
4393- static int nand_flash_detect_jedec (struct nand_chip * chip )
4394- {
4395- struct mtd_info * mtd = nand_to_mtd (chip );
4396- struct nand_jedec_params * p ;
4397- struct jedec_ecc_info * ecc ;
4398- int jedec_version = 0 ;
4399- char id [5 ];
4400- int i , val , ret ;
4401-
4402- /* Try JEDEC for unknown chip or LP */
4403- ret = nand_readid_op (chip , 0x40 , id , sizeof (id ));
4404- if (ret || strncmp (id , "JEDEC" , sizeof (id )))
4405- return 0 ;
4406-
4407- /* JEDEC chip: allocate a buffer to hold its parameter page */
4408- p = kzalloc (sizeof (* p ), GFP_KERNEL );
4409- if (!p )
4410- return - ENOMEM ;
4411-
4412- ret = nand_read_param_page_op (chip , 0x40 , NULL , 0 );
4413- if (ret ) {
4414- ret = 0 ;
4415- goto free_jedec_param_page ;
4416- }
4417-
4418- for (i = 0 ; i < 3 ; i ++ ) {
4419- ret = nand_read_data_op (chip , p , sizeof (* p ), true);
4420- if (ret ) {
4421- ret = 0 ;
4422- goto free_jedec_param_page ;
4423- }
4424-
4425- if (onfi_crc16 (ONFI_CRC_BASE , (uint8_t * )p , 510 ) ==
4426- le16_to_cpu (p -> crc ))
4427- break ;
4428- }
4429-
4430- if (i == 3 ) {
4431- pr_err ("Could not find valid JEDEC parameter page; aborting\n" );
4432- goto free_jedec_param_page ;
4433- }
4434-
4435- /* Check version */
4436- val = le16_to_cpu (p -> revision );
4437- if (val & (1 << 2 ))
4438- jedec_version = 10 ;
4439- else if (val & (1 << 1 ))
4440- jedec_version = 1 ; /* vendor specific version */
4441-
4442- if (!jedec_version ) {
4443- pr_info ("unsupported JEDEC version: %d\n" , val );
4444- goto free_jedec_param_page ;
4445- }
4446-
4447- sanitize_string (p -> manufacturer , sizeof (p -> manufacturer ));
4448- sanitize_string (p -> model , sizeof (p -> model ));
4449- chip -> parameters .model = kstrdup (p -> model , GFP_KERNEL );
4450- if (!chip -> parameters .model ) {
4451- ret = - ENOMEM ;
4452- goto free_jedec_param_page ;
4453- }
4454-
4455- mtd -> writesize = le32_to_cpu (p -> byte_per_page );
4456-
4457- /* Please reference to the comment for nand_flash_detect_onfi. */
4458- mtd -> erasesize = 1 << (fls (le32_to_cpu (p -> pages_per_block )) - 1 );
4459- mtd -> erasesize *= mtd -> writesize ;
4460-
4461- mtd -> oobsize = le16_to_cpu (p -> spare_bytes_per_page );
4462-
4463- /* Please reference to the comment for nand_flash_detect_onfi. */
4464- chip -> chipsize = 1 << (fls (le32_to_cpu (p -> blocks_per_lun )) - 1 );
4465- chip -> chipsize *= (uint64_t )mtd -> erasesize * p -> lun_count ;
4466- chip -> bits_per_cell = p -> bits_per_cell ;
4467-
4468- if (le16_to_cpu (p -> features ) & JEDEC_FEATURE_16_BIT_BUS )
4469- chip -> options |= NAND_BUSWIDTH_16 ;
4470-
4471- /* ECC info */
4472- ecc = & p -> ecc_info [0 ];
4473-
4474- if (ecc -> codeword_size >= 9 ) {
4475- chip -> ecc_strength_ds = ecc -> ecc_bits ;
4476- chip -> ecc_step_ds = 1 << ecc -> codeword_size ;
4477- } else {
4478- pr_warn ("Invalid codeword size\n" );
4479- }
4480-
4481- free_jedec_param_page :
4482- kfree (p );
4483- return ret ;
4484- }
4485-
44864390/*
44874391 * nand_id_has_period - Check if an ID string has a given wraparound period
44884392 * @id_data: the ID string
@@ -4795,7 +4699,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
47954699 goto ident_done ;
47964700
47974701 /* Check if the chip is JEDEC compliant */
4798- ret = nand_flash_detect_jedec (chip );
4702+ ret = nand_jedec_detect (chip );
47994703 if (ret < 0 )
48004704 return ret ;
48014705 else if (ret )
0 commit comments