linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: mtdchar: handle a block that should be marked bad that already is
@ 2017-08-31 19:35 Uwe Kleine-König
  2017-08-31 20:08 ` Boris Brezillon
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2017-08-31 19:35 UTC (permalink / raw)
  To: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen
  Cc: kernel, linux-mtd

Otherwise at least /sys/class/mtd/mtdX/bad_blocks is increased each time
the same block is remarked as bad.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/mtd/mtdchar.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 3568294d4854..049496a1d7a5 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -916,6 +916,11 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
 
 		if (copy_from_user(&offs, argp, sizeof(loff_t)))
 			return -EFAULT;
+
+		if (mtd_block_isbad(mtd, offs))
+			/* already done */
+			return 0;
+
 		return mtd_block_markbad(mtd, offs);
 		break;
 	}
-- 
2.11.0

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

end of thread, other threads:[~2017-08-31 20:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-31 19:35 [PATCH] mtd: mtdchar: handle a block that should be marked bad that already is Uwe Kleine-König
2017-08-31 20:08 ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).