diff options
author | Anton Vorontsov <avorontsov@mvista.com> | 2010-06-22 12:57:42 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-08-04 05:58:24 -0400 |
commit | 9d2c4f3fe50a6d07275de91b392aaaf4773bc8b6 (patch) | |
tree | 64e1ed26300e4bfdfc5406de2dd7097fc2a4198d | |
parent | f7b000904a848b64c36e3b4d0715744aaf345767 (diff) |
mtd: m25p80: Make jedec_probe() return proper errno values
spi_write_then_read() may return its own return codes (e.g. -EIO),
so let's propagate the value down to the probe().
Also, remove jedec == 0 check, it isn't needed as nowadays we use
dedicated SPI device IDs for non-JEDEC flashes.
Suggested-by: Barry Song <21cnbao@gmail.com>
Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/devices/m25p80.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index ff7627a3d075..48bf325e9e84 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
@@ -16,6 +16,8 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/err.h> | ||
20 | #include <linux/errno.h> | ||
19 | #include <linux/module.h> | 21 | #include <linux/module.h> |
20 | #include <linux/device.h> | 22 | #include <linux/device.h> |
21 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
@@ -734,7 +736,7 @@ static const struct spi_device_id *__devinit jedec_probe(struct spi_device *spi) | |||
734 | if (tmp < 0) { | 736 | if (tmp < 0) { |
735 | DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n", | 737 | DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n", |
736 | dev_name(&spi->dev), tmp); | 738 | dev_name(&spi->dev), tmp); |
737 | return NULL; | 739 | return ERR_PTR(tmp); |
738 | } | 740 | } |
739 | jedec = id[0]; | 741 | jedec = id[0]; |
740 | jedec = jedec << 8; | 742 | jedec = jedec << 8; |
@@ -742,14 +744,6 @@ static const struct spi_device_id *__devinit jedec_probe(struct spi_device *spi) | |||
742 | jedec = jedec << 8; | 744 | jedec = jedec << 8; |
743 | jedec |= id[2]; | 745 | jedec |= id[2]; |
744 | 746 | ||
745 | /* | ||
746 | * Some chips (like Numonyx M25P80) have JEDEC and non-JEDEC variants, | ||
747 | * which depend on technology process. Officially RDID command doesn't | ||
748 | * exist for non-JEDEC chips, but for compatibility they return ID 0. | ||
749 | */ | ||
750 | if (jedec == 0) | ||
751 | return NULL; | ||
752 | |||
753 | ext_jedec = id[3] << 8 | id[4]; | 747 | ext_jedec = id[3] << 8 | id[4]; |
754 | 748 | ||
755 | for (tmp = 0; tmp < ARRAY_SIZE(m25p_ids) - 1; tmp++) { | 749 | for (tmp = 0; tmp < ARRAY_SIZE(m25p_ids) - 1; tmp++) { |
@@ -760,7 +754,7 @@ static const struct spi_device_id *__devinit jedec_probe(struct spi_device *spi) | |||
760 | return &m25p_ids[tmp]; | 754 | return &m25p_ids[tmp]; |
761 | } | 755 | } |
762 | } | 756 | } |
763 | return NULL; | 757 | return ERR_PTR(-ENODEV); |
764 | } | 758 | } |
765 | 759 | ||
766 | 760 | ||
@@ -805,8 +799,8 @@ static int __devinit m25p_probe(struct spi_device *spi) | |||
805 | const struct spi_device_id *jid; | 799 | const struct spi_device_id *jid; |
806 | 800 | ||
807 | jid = jedec_probe(spi); | 801 | jid = jedec_probe(spi); |
808 | if (!jid) { | 802 | if (IS_ERR(jid)) { |
809 | return -ENODEV; | 803 | return PTR_ERR(jid); |
810 | } else if (jid != id) { | 804 | } else if (jid != id) { |
811 | /* | 805 | /* |
812 | * JEDEC knows better, so overwrite platform ID. We | 806 | * JEDEC knows better, so overwrite platform ID. We |