diff options
author | Boris Brezillon <boris.brezillon@free-electrons.com> | 2017-01-07 15:48:25 +0100 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2017-03-08 23:21:18 +0100 |
commit | bcc678c2d7a0e0af14cb3d858ebd367be378c172 (patch) | |
tree | bf65c4f754e0cfc612b300722571e62bb1cda958 /drivers/mtd/nand/nand_ids.c | |
parent | f16bd7ca045729e1104a9353dfd792ea98931b80 (diff) | |
download | linux-bcc678c2d7a0e0af14cb3d858ebd367be378c172.tar.bz2 |
mtd: nand: Do not expose the NAND manufacturer table directly
There is no reason to expose the NAND manufacturer table. Provide an
helper function to find manufacturers by their id.
We also turn the nand_manufacturers table into a const array, since its
members are not modified after the initial assignment.
Finally, we remove the sentinel manufacturer entry from the manufacturers
table (we already have the array size information given by ARRAY_SIZE()),
and add the nand_manufacturer_name() helper to handle the "Unknown" case
properly.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'drivers/mtd/nand/nand_ids.c')
-rw-r--r-- | drivers/mtd/nand/nand_ids.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c index bd267ade0742..06f59a6b74ff 100644 --- a/drivers/mtd/nand/nand_ids.c +++ b/drivers/mtd/nand/nand_ids.c @@ -169,7 +169,7 @@ struct nand_flash_dev nand_flash_ids[] = { }; /* Manufacturer IDs */ -struct nand_manufacturer nand_manuf_ids[] = { +static const struct nand_manufacturer nand_manufacturers[] = { {NAND_MFR_TOSHIBA, "Toshiba"}, {NAND_MFR_ESMT, "ESMT"}, {NAND_MFR_SAMSUNG, "Samsung"}, @@ -186,5 +186,23 @@ struct nand_manufacturer nand_manuf_ids[] = { {NAND_MFR_INTEL, "Intel"}, {NAND_MFR_ATO, "ATO"}, {NAND_MFR_WINBOND, "Winbond"}, - {0x0, "Unknown"} }; + +/** + * nand_get_manufacturer - Get manufacturer information from the manufacturer + * ID + * @id: manufacturer ID + * + * Returns a pointer a nand_manufacturer object if the manufacturer is defined + * in the NAND manufacturers database, NULL otherwise. + */ +const struct nand_manufacturer *nand_get_manufacturer(u8 id) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(nand_manufacturers); i++) + if (nand_manufacturers[i].id == id) + return &nand_manufacturers[i]; + + return NULL; +} |