Skip to content

Commit 5158bd5

Browse files
Jean-Louis ThekekaraBoris Brezillon
authored andcommitted
mtd: nand: remove hard-coded NAND ids length
This commit removes hard-coded '8' used for looping into struct nand_chip.id.data array. NAND_MAX_ID_LEN has been introduced by Artem Bityutskiy in 53552d2 for defining ids length in nand_flash_ids[] list. This commit unifies ids length in nand base driver. Signed-off-by: Jean-Louis Thekekara <jeanlouis.thekekara@parrot.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
1 parent f84674b commit 5158bd5

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3886,7 +3886,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
38863886
chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
38873887

38883888
/* Read entire ID string */
3889-
for (i = 0; i < 8; i++)
3889+
for (i = 0; i < ARRAY_SIZE(chip->id.data); i++)
38903890
id_data[i] = chip->read_byte(mtd);
38913891

38923892
if (id_data[0] != maf_id || id_data[1] != dev_id) {
@@ -3895,7 +3895,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
38953895
return -ENODEV;
38963896
}
38973897

3898-
chip->id.len = nand_id_len(id_data, 8);
3898+
chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data));
38993899

39003900
/* Try to identify manufacturer */
39013901
manufacturer = nand_get_manufacturer(maf_id);

‎include/linux/mtd/nand.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,16 @@ struct nand_jedec_params {
439439
__le16 crc;
440440
} __packed;
441441

442+
/* The maximum expected count of bytes in the NAND ID sequence */
443+
#define NAND_MAX_ID_LEN 8
444+
442445
/**
443446
* struct nand_id - NAND id structure
444-
* @data: buffer containing the id bytes. Currently 8 bytes large, but can
445-
* be extended if required.
447+
* @data: buffer containing the id bytes.
446448
* @len: ID length.
447449
*/
448450
struct nand_id {
449-
u8 data[8];
451+
u8 data[NAND_MAX_ID_LEN];
450452
int len;
451453
};
452454

@@ -1018,8 +1020,6 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip)
10181020
#define NAND_MFR_ATO 0x9b
10191021
#define NAND_MFR_WINBOND 0xef
10201022

1021-
/* The maximum expected count of bytes in the NAND ID sequence */
1022-
#define NAND_MAX_ID_LEN 8
10231023

10241024
/*
10251025
* A helper for defining older NAND chips where the second ID byte fully

0 commit comments

Comments
 (0)