mtd: spi-nor: add a helper to find the spi_device_id

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue Jun 10 23:59:03 PDT 2014


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=0d8c11c01274bde227d368daa8954911dd324a9f
Commit:     0d8c11c01274bde227d368daa8954911dd324a9f
Parent:     03e296f613affcc2671c1e86d8c25ecad867204e
Author:     Huang Shijie <b32955 at freescale.com>
AuthorDate: Mon Feb 24 18:37:40 2014 +0800
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Mon Apr 14 11:22:58 2014 -0700

    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 at freescale.com>
    Acked-by: Marek Vasut <marex at denx.de>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 12 ++++++++++++
 include/linux/mtd/spi-nor.h   | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 50b9290..f7c9e63 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,
 	return 0;
 }
 
+const struct spi_device_id *spi_nor_match_id(char *name)
+{
+	const struct spi_device_id *id = spi_nor_ids;
+
+	while (id->name[0]) {
+		if (!strcmp(name, id->name))
+			return id;
+		id++;
+	}
+	return NULL;
+}
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Huang Shijie <shijie8 at gmail.com>");
 MODULE_AUTHOR("Mike Lavender");
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 16d8409..41dae78 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,
 			enum read_mode mode);
 extern const struct spi_device_id spi_nor_ids[];
 
+/**
+ * spi_nor_match_id() - find the spi_device_id by the name
+ * @name:	the name of the spi_device_id
+ *
+ * The drivers use this function to find the spi_device_id
+ * specified by the @name.
+ *
+ * Return: returns the right spi_device_id pointer on success,
+ *         and returns NULL on failure.
+ */
+const struct spi_device_id *spi_nor_match_id(char *name);
+
 #endif



More information about the linux-mtd-cvs mailing list