Commit 5158bd55 authored by Jean-Louis Thekekara's avatar Jean-Louis Thekekara Committed by Boris Brezillon

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
53552d22 for defining ids length in nand_flash_ids[] list.

This commit unifies ids length in nand base driver.
Signed-off-by: default avatarJean-Louis Thekekara <jeanlouis.thekekara@parrot.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent f84674b8
...@@ -3886,7 +3886,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) ...@@ -3886,7 +3886,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
/* Read entire ID string */ /* Read entire ID string */
for (i = 0; i < 8; i++) for (i = 0; i < ARRAY_SIZE(chip->id.data); i++)
id_data[i] = chip->read_byte(mtd); id_data[i] = chip->read_byte(mtd);
if (id_data[0] != maf_id || id_data[1] != dev_id) { 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) ...@@ -3895,7 +3895,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
return -ENODEV; return -ENODEV;
} }
chip->id.len = nand_id_len(id_data, 8); chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data));
/* Try to identify manufacturer */ /* Try to identify manufacturer */
manufacturer = nand_get_manufacturer(maf_id); manufacturer = nand_get_manufacturer(maf_id);
......
...@@ -439,14 +439,16 @@ struct nand_jedec_params { ...@@ -439,14 +439,16 @@ struct nand_jedec_params {
__le16 crc; __le16 crc;
} __packed; } __packed;
/* The maximum expected count of bytes in the NAND ID sequence */
#define NAND_MAX_ID_LEN 8
/** /**
* struct nand_id - NAND id structure * struct nand_id - NAND id structure
* @data: buffer containing the id bytes. Currently 8 bytes large, but can * @data: buffer containing the id bytes.
* be extended if required.
* @len: ID length. * @len: ID length.
*/ */
struct nand_id { struct nand_id {
u8 data[8]; u8 data[NAND_MAX_ID_LEN];
int len; int len;
}; };
...@@ -1018,8 +1020,6 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip) ...@@ -1018,8 +1020,6 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip)
#define NAND_MFR_ATO 0x9b #define NAND_MFR_ATO 0x9b
#define NAND_MFR_WINBOND 0xef #define NAND_MFR_WINBOND 0xef
/* The maximum expected count of bytes in the NAND ID sequence */
#define NAND_MAX_ID_LEN 8
/* /*
* A helper for defining older NAND chips where the second ID byte fully * A helper for defining older NAND chips where the second ID byte fully
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment