mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Subject: [PATCH 1/1] mtd:nand:fix nand_lock/unlock() function
@ 2014-07-24  1:00 bpqw
  2014-07-24  1:27 ` Brian Norris
  2014-07-28  6:10 ` Brian Norris
  0 siblings, 2 replies; 13+ messages in thread
From: bpqw @ 2014-07-24  1:00 UTC (permalink / raw)
  To: dwmw2, computersforpeace
  Cc: b32955, artem.bityutskiy, ron, u.kleine-koenig, ezequiel.garcia,
	linux-mtd, linux-kernel

Do nand reset before write protect check
If we want to check the WP# low or high through STATUS READ and check bit 7,
we must reset the device, other operation (eg.erase/program a locked block) can
also clear the bit 7 of status register.

Signed-off-by: White Ding <bpqw@micron.com>
---
 drivers/mtd/nand/nand_base.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 41167e9..22dd3aa 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -965,6 +965,15 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
 
 	chip->select_chip(mtd, chipnr);
 
+	/*
+	 * Reset the chip.
+	 * If we want to check the WP through READ STATUS and check the bit 7
+	 * we must reset the chip
+	 * some operation can also clear the bit 7 of status register
+	 * eg. erase/program a locked block
+	 */
+	chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
+
 	/* Check, if it is write protected */
 	if (nand_check_wp(mtd)) {
 		pr_debug("%s: device is write protected!\n",
@@ -1015,6 +1024,15 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
 
 	chip->select_chip(mtd, chipnr);
 
+	/*
+	 * Reset the chip.
+	 * If we want to check the WP through READ STATUS and check the bit 7
+	 * we must reset the chip
+	 * some operation can also clear the bit 7 of status register
+	 * eg. erase/program a locked block
+	 */
+	chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
+
 	/* Check, if it is write protected */
 	if (nand_check_wp(mtd)) {
 		pr_debug("%s: device is write protected!\n",
-- 
1.7.9.5

Br
White Ding 
____________________________
EBU APAC Application Engineering
Tel:86-21-38997078
Mobile: 86-13761729112
Address: No 601 Fasai Rd, Waigaoqiao Free Trade Zone Pudong, Shanghai, China


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

end of thread, other threads:[~2014-08-05  3:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-24  1:00 Subject: [PATCH 1/1] mtd:nand:fix nand_lock/unlock() function bpqw
2014-07-24  1:27 ` Brian Norris
2014-07-24  1:31   ` Brian Norris
2014-07-24  7:54   ` Gupta, Pekon
2014-07-24 16:56     ` Brian Norris
2014-07-25  2:29       ` bpqw
2014-07-28  6:10 ` Brian Norris
2014-07-28  7:46   ` bpqw
2014-07-31  0:31     ` bpqw
2014-08-04  5:41     ` bpqw
2014-08-04 22:47     ` Brian Norris
2014-08-05  1:54       ` bpqw
2014-08-05  3:01         ` Brian Norris

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

all inboxes | Powered by JetHome®