From patchwork Tue Nov 15 21:47:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 20599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2957103wru; Tue, 15 Nov 2022 13:52:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7R6puVmoizqsCAqdA56oD607iXcttDdQirQ62mhpdSEA+aAy/1G4rzHPTKCvu334/SDVh9 X-Received: by 2002:a05:6a00:244e:b0:56b:fb4f:3d7c with SMTP id d14-20020a056a00244e00b0056bfb4f3d7cmr20359597pfj.54.1668549142706; Tue, 15 Nov 2022 13:52:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668549142; cv=none; d=google.com; s=arc-20160816; b=jslVTwRFX4jWGB+7wnV39Dz95s57a/BndrQoWymwb53eG8uOjAIy1P3Px+HMIydKIu +PFZBZULIgSm9BSzxO82LMDYKqh+M08gr7A6QBgHfzzkhG0AYrOregi4U3l1M4IwXr4r pqtRszpclBOeihC2jkl70ojuLfc197P/WjGQGPX4Pquc1zbUaeDDwy90Ozx+R9UYzWww WmK51NoItT7pcwxpZsWDqiJG3887WeiLt1YKCgZKqDmHl0ov2TIFsnB7H0O6FT/EzODy CIgWaW7jBNnZQFg8MO56hjhNy5gfUD9aT9CoYBN4EzuA/gCBbZn7iFKT55vW6a8vQzIC CqSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=nzzL2XFihfA+KJlyFLaA/TO9hi4VKnKzUv6kwR5rZpw=; b=QAFymOuHu0xjLi7Oxwj5yg5kMQuKMCYDA8qUDGBkC2RFocaIIA0rlnJgeRa8EU9Q+Q YTc5G9yOIUN/sfbrW4wgrDaHZMNqOMQtvKryX9RZjcJ/EgL7nDDnmJbAwG8SUCvasry8 oHGMgtx+0ampALWln8vTutLGYNXc4FzKNma2eU8Y4cBnAgPPP9XCf9JmrkRJb7MeWLE3 EQ5m6aE/iDawqyFgZ/+Z2kll+TKhOLqVQMQ9E8Z27tx82l62XAKmsdBSsYxSzqQXNDzz LY1aQLCrgk4t6oG0bKV8+RCAYsez8QyPlsAtyGNUhAWKOJnIZZdCdJaL30YPwRFpWITf dEJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a635607000000b00475abba079bsi10044242pgb.405.2022.11.15.13.52.06; Tue, 15 Nov 2022 13:52:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231723AbiKOVtE (ORCPT + 99 others); Tue, 15 Nov 2022 16:49:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbiKOVtB (ORCPT ); Tue, 15 Nov 2022 16:49:01 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F412462FA; Tue, 15 Nov 2022 13:48:59 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.94.2) (envelope-from ) id 1ov3nW-0005KN-32; Tue, 15 Nov 2022 22:48:50 +0100 Date: Tue, 15 Nov 2022 21:47:25 +0000 From: Daniel Golle To: Jens Axboe , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Matthew Wilcox , Daniel Golle , "Martin K. Petersen" , Chaitanya Kulkarni , Michal Orzel , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v5 4/4] mtd: add option to enable scanning for partitions Message-ID: <88d7c15691af5d956275b5326303d5aeb3ea1d2f.1668548123.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749600586006538236?= X-GMAIL-MSGID: =?utf-8?q?1749600586006538236?= Add Kconfig boolean CONFIG_MTD_BLOCK_PARTITIONS and enable block partition parsers on non-NAND mtdblock as well as ubiblock devices in case it is selected. Never scan partitions on NAND-backed mtdblock devices, ubiblock should be used instead. Signed-off-by: Daniel Golle Acked-by: Miquel Raynal --- drivers/mtd/Kconfig | 11 +++++++++++ drivers/mtd/mtd_blkdevs.c | 4 +++- drivers/mtd/ubi/block.c | 5 ++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index 796a2eccbef0..12874dec1569 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig @@ -69,6 +69,17 @@ config MTD_BLOCK_RO You do not need this option for use with the DiskOnChip devices. For those, enable NFTL support (CONFIG_NFTL) instead. +config MTD_BLOCK_PARTITIONS + bool "Scan for partitions on MTD block devices" + depends on MTD_BLOCK || MTD_BLOCK_RO + default y if FIT_PARTITION + help + Scan MTD block devices for partitions (ie. MBR, GPT, uImage.FIT, ...). + (NAND devices are omitted, ubiblock should be used instead when) + + Unless your MTD partitions contain sub-partitions mapped using a + partition table, say no. + comment "Note that in some cases UBI block is preferred. See MTD_UBI_BLOCK." depends on MTD_BLOCK || MTD_BLOCK_RO diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 60b222799871..e6f2e0888246 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -359,7 +359,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) } else { snprintf(gd->disk_name, sizeof(gd->disk_name), "%s%d", tr->name, new->devnum); - gd->flags |= GENHD_FL_NO_PART; + + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd)) + gd->flags |= GENHD_FL_NO_PART; } set_capacity(gd, ((u64)new->size * tr->blksize) >> 9); diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 75eaecc8639f..e617635ff6e6 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -430,7 +430,10 @@ int ubiblock_create(struct ubi_volume_info *vi) ret = -ENODEV; goto out_cleanup_disk; } - gd->flags |= GENHD_FL_NO_PART; + + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS)) + gd->flags |= GENHD_FL_NO_PART; + gd->private_data = dev; sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id); set_capacity(gd, disk_capacity);