From patchwork Thu Aug 31 19:35:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 808395 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Hquw9ot0"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xjt0y4dFvz9s8P for ; Fri, 1 Sep 2017 05:36:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=cfbRgjmazdPQfvTz7cZg2tXosNkbaKULi+XYoX2PUZ0=; b=Hquw9ot0prBsfY OudwIf6xYUeV4AybQ76M2goH0D8ANjwJUmEjx9iRBFoCEixnKcxeTyo6KUBs0Jd9wUgbyHEy7xTF2 ZPzCj4fd1c0HbV37IsDdd6Y0LDJjv08v5TVVSMqocg46v/36TI1LNLQwIqN37dVVLXikyC8Qxmq+u poCyHjygYhB9Ur314YoMFE3iYjTHCCW744/JoDcEu2H1rxTED1kaI5V5iDbhv2SGf4wBcfKrLkZGe fzGURV0qH3YqzPQIceeF/BiPRvbCI6odSGgjN+dXEkv9CVaHad7ByqCJh+QKAu/IPZSALzNpblVWY tvZmE7uOElrt5HnsD3vw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dnVGe-00080W-Vt; Thu, 31 Aug 2017 19:36:45 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dnVGG-0007yI-3r for linux-mtd@lists.infradead.org; Thu, 31 Aug 2017 19:36:21 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dnVFl-00077W-E2; Thu, 31 Aug 2017 21:35:49 +0200 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1dnVFk-0007Me-RX; Thu, 31 Aug 2017 21:35:48 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen Subject: [PATCH] mtd: mtdchar: handle a block that should be marked bad that already is Date: Thu, 31 Aug 2017 21:35:43 +0200 Message-Id: <20170831193543.27543-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170831_123620_363231_6A4C56B1 X-CRM114-Status: GOOD ( 10.29 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, kernel@pengutronix.de Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- 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; }