public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1 v2] driver:mtd:spi-nor:fix spi_nor_scan overwrite platform ID point
@ 2014-10-14  1:26 Bean Huo 霍斌斌 (beanhuo)
  2014-10-14 22:45 ` Marek Vasut
  2014-10-16  7:05 ` Rafał Miłecki
  0 siblings, 2 replies; 11+ messages in thread
From: Bean Huo 霍斌斌 (beanhuo) @ 2014-10-14  1:26 UTC (permalink / raw)
  To: Marek Vasut, dwmw2@infradead.org, Brian Norris
  Cc: shijie8@gmail.com, geert+renesas@glider.be, grmoore@altera.com,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org

This patch used to modify the method of spi_nor_scan overwrite platform ID point.

If type of platform data match with the name of spi_nor_ids set,
and JEDEC ID also match with INFO ID of spi_nor_ids set,spi device
ID point(this is before probed according to device name) shouldn't be
overwrote.Otherwise,this point will be overwrote by new spi_nor_ids
set point that probed according to JEDEC ID.

Signed-off-by: bean huo <beanhuo@micron.com>
---
v1-v2:
	add extended ID match judgment.

 drivers/mtd/spi-nor/spi-nor.c |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index b5ad6be..3bb8077 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -963,16 +963,23 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
 			return PTR_ERR(jid);
 		} else if (jid != id) {
 			/*
-			 * JEDEC knows better, so overwrite platform ID. We
-			 * can't trust partitions any longer, but we'll let
-			 * mtd apply them anyway, since some partitions may be
-			 * marked read-only, and we don't want to lose that
-			 * information, even if it's not 100% accurate.
+			 * If type of platform data match with the name of
+			 * spi_nor_ids set,and JEDEC ID also match with
+			 * INFO ID of spi_nor_ids set,shouldn't overwrite
+			 * spi device info point.Otherwise,will overwrite
+			 * it.
 			 */
-			dev_warn(dev, "found %s, expected %s\n",
-				 jid->name, id->name);
-			id = jid;
-			info = (void *)jid->driver_data;
+			struct flash_info *tmpinfo;
+
+			tmpinfo = (void *)jid->driver_data;
+			if (tmpinfo->jedec_id != info->jedec_id ||
+					(info->ext_id != 0 &&
+					 tmpinfo->ext_id != info->ext_id)) {
+				dev_warn(dev, "found %s, expected %s\n",
+						jid->name, id->name);
+				id = jid;
+				info = (void *)jid->driver_data;
+			}
 		}
 	}
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-10-27 14:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-14  1:26 [PATCH 1/1 v2] driver:mtd:spi-nor:fix spi_nor_scan overwrite platform ID point Bean Huo 霍斌斌 (beanhuo)
2014-10-14 22:45 ` Marek Vasut
2014-10-16  0:52   ` bpqw
2014-10-22  7:06     ` Rafał Miłecki
2014-10-27  8:44       ` bpqw
2014-10-27 14:59         ` Rafał Miłecki
2014-10-16  7:05 ` Rafał Miłecki
2014-10-16  8:00   ` Bean Huo 霍斌斌 (beanhuo)
2014-10-16  8:12     ` Rafał Miłecki
2014-10-16  8:41       ` bpqw
2014-10-16 10:19         ` Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox