aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2014-02-24 05:37:40 -0500
committerBrian Norris <computersforpeace@gmail.com>2014-04-14 14:22:58 -0400
commit0d8c11c01274bde227d368daa8954911dd324a9f (patch)
tree74a5cea5d6cbe628aba708aa2117d344ca6475c1
parent03e296f613affcc2671c1e86d8c25ecad867204e (diff)
mtd: spi-nor: add a helper to find the spi_device_id
Add the spi_nor_match_id() to find the proper spi_device_id with the NOR flash's name in the spi_nor_ids table. Signed-off-by: Huang Shijie <b32955@freescale.com> Acked-by: Marek Vasut <marex@denx.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c12
-rw-r--r--include/linux/mtd/spi-nor.h12
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 50b929095bdb..f7c9e638623b 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1082,6 +1082,18 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
1082 return 0; 1082 return 0;
1083} 1083}
1084 1084
1085const struct spi_device_id *spi_nor_match_id(char *name)
1086{
1087 const struct spi_device_id *id = spi_nor_ids;
1088
1089 while (id->name[0]) {
1090 if (!strcmp(name, id->name))
1091 return id;
1092 id++;
1093 }
1094 return NULL;
1095}
1096
1085MODULE_LICENSE("GPL"); 1097MODULE_LICENSE("GPL");
1086MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>"); 1098MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>");
1087MODULE_AUTHOR("Mike Lavender"); 1099MODULE_AUTHOR("Mike Lavender");
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 16d8409abcdc..41dae78fbd1d 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -182,4 +182,16 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
182 enum read_mode mode); 182 enum read_mode mode);
183extern const struct spi_device_id spi_nor_ids[]; 183extern const struct spi_device_id spi_nor_ids[];
184 184
185/**
186 * spi_nor_match_id() - find the spi_device_id by the name
187 * @name: the name of the spi_device_id
188 *
189 * The drivers use this function to find the spi_device_id
190 * specified by the @name.
191 *
192 * Return: returns the right spi_device_id pointer on success,
193 * and returns NULL on failure.
194 */
195const struct spi_device_id *spi_nor_match_id(char *name);
196
185#endif 197#endif