All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: mtdchar: Exit write loop when hitting end of OTP memory
@ 2013-04-26 17:56 Christian Riesch
  2013-05-29  7:08 ` Artem Bityutskiy
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Riesch @ 2013-04-26 17:56 UTC (permalink / raw)
  To: linux-mtd; +Cc: Christian Riesch

If a write to one time programmable memory (OTP) hits the end
of this memory area, no more data can be written and count does not
decrease anymore. We are trapped in the loop forever.

Therefore drop the remaining data if retlen != len.

Signed-off-by: Christian Riesch <christian.riesch@omicron.at>
---
 drivers/mtd/mtdchar.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index e0e59bf..70c18c2 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -321,6 +321,10 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 		case MTD_FILE_MODE_OTP_USER:
 			ret = mtd_write_user_prot_reg(mtd, *ppos, len,
 						      &retlen, kbuf);
+
+			/* if we hit the end of otp memory, drop the rest */
+			if (retlen != len)
+				count -= len - retlen;
 			break;
 
 		case MTD_FILE_MODE_RAW:
-- 
1.7.9.5

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

end of thread, other threads:[~2013-06-03  9:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-26 17:56 [PATCH] mtd: mtdchar: Exit write loop when hitting end of OTP memory Christian Riesch
2013-05-29  7:08 ` Artem Bityutskiy
2013-05-29 13:19   ` Christian Riesch
2013-05-29 13:56     ` Artem Bityutskiy
2013-05-29 14:27       ` Christian Riesch
2013-06-03  9:39         ` Artem Bityutskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.