mtd: m25p80: Clean up JEDEC manufacturer checks

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue May 24 21:59:05 EDT 2011


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=aa0846534b9c7238187b4276e83efb9969d4c6e3
Commit:     aa0846534b9c7238187b4276e83efb9969d4c6e3
Parent:     16004f3685541c57a280bae3fde6562256fd0ba5
Author:     Kevin Cernekee <cernekee at gmail.com>
AuthorDate: Sun May 8 10:48:00 2011 -0700
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Wed May 25 02:02:30 2011 +0100

    mtd: m25p80: Clean up JEDEC manufacturer checks
    
    Use the manufacturer ID names from cfi.h instead of hard-coding
    hex constants.  Introduce a JEDEC_MFR macro for clarity.
    
    Signed-off-by: Kevin Cernekee <cernekee at gmail.com>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/devices/m25p80.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 15231d6..16adfaa 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -27,6 +27,7 @@
 #include <linux/sched.h>
 #include <linux/mod_devicetable.h>
 
+#include <linux/mtd/cfi.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 
@@ -76,6 +77,8 @@
 #define FAST_READ_DUMMY_BYTE 0
 #endif
 
+#define JEDEC_MFR(_jedec_id)	((_jedec_id) >> 16)
+
 /****************************************************************************/
 
 struct m25p {
@@ -872,9 +875,9 @@ static int __devinit m25p_probe(struct spi_device *spi)
 	 * up with the software protection bits set
 	 */
 
-	if (info->jedec_id >> 16 == 0x1f ||
-	    info->jedec_id >> 16 == 0x89 ||
-	    info->jedec_id >> 16 == 0xbf) {
+	if (JEDEC_MFR(info->jedec_id) == CFI_MFR_ATMEL ||
+	    JEDEC_MFR(info->jedec_id) == CFI_MFR_INTEL ||
+	    JEDEC_MFR(info->jedec_id) == CFI_MFR_SST) {
 		write_enable(flash);
 		write_sr(flash, 0);
 	}
@@ -892,7 +895,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
 	flash->mtd.read = m25p80_read;
 
 	/* sst flash chips use AAI word program */
-	if (info->jedec_id >> 16 == 0xbf)
+	if (JEDEC_MFR(info->jedec_id) == CFI_MFR_SST)
 		flash->mtd.write = sst_write;
 	else
 		flash->mtd.write = m25p80_write;



More information about the linux-mtd-cvs mailing list