Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1206809pxy; Sun, 1 Aug 2021 16:47:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1/ef3Vi84j6Aw9vKxrh0XAnS/z889CuNcx+rGobwOgJpPMkUednGVhjFFmM5xHntanoiP X-Received: by 2002:a17:906:2bd3:: with SMTP id n19mr13251040ejg.232.1627861640579; Sun, 01 Aug 2021 16:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627861640; cv=none; d=google.com; s=arc-20160816; b=dLnUA+hmhVkxWTDE6CRhIpSdoT+FxFG7VxMStG7P1mY5WVK5p4HLYXZLmVV8cTDac5 luSH0GPyn0vfO6NBRdjc6jkbcD1CJNrpsmeCJnSuoveoN1fL2csqv6AQzDEhYjhQ69k0 3EGCd/ENyTsdKq/dRySqYhw/hReYV/RcIJvo5fEOqu359VNvHVEFnqZvKXy42FcEbwiX W11Ej2R/gKM5Mg6ZA3AhF0FftmsPkTHmoq7NUy/LsNEHneWtF/TVRedfAAXUu2CHcj0Y js+BKIUheMT52TrUuPo1judp8X+Gl1QJSOrxyKDZjyGM0fK81CLBmHQsSaS2QUZ9EnOJ S9IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gVHEHlseyDZHvboi7M7oJcrbSupQYM6dYT3x56GRfmE=; b=DcawYgpUrNUXT7f7LZseITltIUiqftMJdZ1ZqbzqmksvBK3XG11oBymTLSzVHNghJ8 8691X7mQmUiCkUaMFSkvU32CONT7+LOXLWXUARu1/ZtbdJuDTUaiYiH+oGQDVUUcghD7 PYyW+iXn7bVcCsdJrgX0R2CB4Gmfr9bpY5JJC9iEAdNH7zYSmRWfkk6Vujgb28vG4bvV YWl71RobrU3uuJcmVHH/vgF/x2fYggx1SDp1Jf9KjLEILPHA7vOcsdmHKQVTJTboSeoy a+UquDqThQfaafbwoRyhWC2jDnwJj/1Q1T8QOucsBBHB7Cd30E7nM+N4XqZWPE4bOdJM rqIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si8624725ejl.218.2021.08.01.16.46.58; Sun, 01 Aug 2021 16:47:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbhHAXpk (ORCPT + 99 others); Sun, 1 Aug 2021 19:45:40 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:50942 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231877AbhHAXpi (ORCPT ); Sun, 1 Aug 2021 19:45:38 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 93EF11F424CD From: Ezequiel Garcia To: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Richard Weinberger Cc: Miquel Raynal , Vignesh Raghavendra , Ezequiel Garcia Subject: [PATCH 3/3] mtdblock: Warn if the added for a NAND device Date: Sun, 1 Aug 2021 20:45:05 -0300 Message-Id: <20210801234509.18774-4-ezequiel@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210801234509.18774-1-ezequiel@collabora.com> References: <20210801234509.18774-1-ezequiel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a surprisingly large number of tutorials that suggest using mtdblock to mount SquashFS filesystems on flash devices, including NAND devices. This approach is suboptimal than using UBI. If the flash device is NAND, this is specially true, due to wear leveling, bit-flips and badblocks. In this case UBI is strongly preferred, so be nice to users and print a warning suggesting to consider UBI block, if mtdblock is added for a NAND device. Signed-off-by: Ezequiel Garcia Untracked files not listed --- drivers/mtd/mtdblock.c | 4 ++++ drivers/mtd/mtdblock_ro.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c index b2d5ed1cbc94..7c02643f862f 100644 --- a/drivers/mtd/mtdblock.c +++ b/drivers/mtd/mtdblock.c @@ -332,6 +332,10 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) if (!(mtd->flags & MTD_WRITEABLE)) dev->mbd.readonly = 1; + if (mtd_type_is_nand(mtd)) + pr_warn("%s: MTD device '%s' is NAND, please consider using UBI block devices instead.\n", + tr->name, mtd->name); + if (add_mtd_blktrans_dev(&dev->mbd)) kfree(dev); } diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c index fb5dc89369de..a438e2f6089c 100644 --- a/drivers/mtd/mtdblock_ro.c +++ b/drivers/mtd/mtdblock_ro.c @@ -60,6 +60,10 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) dev->tr = tr; dev->readonly = 1; + if (mtd_type_is_nand(mtd)) + pr_warn("%s: MTD device '%s' is NAND, please consider using UBI block devices instead.\n", + tr->name, mtd->name); + if (add_mtd_blktrans_dev(dev)) kfree(dev); } -- 2.32.0