From patchwork Wed May 23 17:14:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 919209 X-Patchwork-Delegate: boris.brezillon@free-electrons.com 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=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="a0qkDmne"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gNZg7eQq"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 40rfMs6wp6z9s1b for ; Thu, 24 May 2018 03:17:29 +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:References:In-Reply-To: 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: List-Owner; bh=jfH9DAjSFk0x8SidXOxsFX1+pX+tspveA5W5o4J0uVs=; b=a0qkDmnez0ksn6 ool9fdWdvYPYk1GHHFbUZ9OAf6EKLiXeCSucmL+JPXkYumb6w2rKIDmKDPUT3q9xxWQ7XeG7AWq6E E7ciq+8Gv9eqmfNPFE22U2K9Fgv7WGjEaHmu7KGWT+byk20m1bz6xb0V5IjL1fLWaUVeo+RirQgJI EL0CnC6yCYaY8sIPa7VzRQNzdcjC7vTjn8XNDYiR2IVJ0A52CfA+OnWfPPkKUYhrIwfZWZ7nxZr+L Y9U0qxarOVdTwrph4fofUPIXA9mmMSjoVDn/ehHxd7mpifkZcwfLtLmkcXZEBZqYbnA+GKHJ9kxt4 ywbZ/RofQnGHNiZ3DYdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLXO2-0001z6-6d; Wed, 23 May 2018 17:17:18 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLXNP-0001Yz-9E for linux-mtd@lists.infradead.org; Wed, 23 May 2018 17:16:50 +0000 Received: by mail-wm0-x244.google.com with SMTP id t11-v6so11085903wmt.0 for ; Wed, 23 May 2018 10:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0ydp83cOTiF0yZ15gpWp3rt1C6PORkuPOL1kPI1/R88=; b=gNZg7eQqGgGD0hUlZ2VivRScZNwFmWH7GPXO1Y4n+wv/sS38rlcbdIq3gZBD23292M H2JRaEa84p6GRJH3MX66BrIFTyVVDkCdNKFkbc1dkWEs39V0h7jlXBM6AgenV1u2iRDU AKQrHYmee9yaFK56k9xgcUDCWXatQwkjRmMGL9aNYFVENd9WphlIuhC8NhgskvF9adDu WIy/oVRSwVporVmfsvGZTpZpjiI9SymLZLo/g1c1jxWf6Vctcd47nVIKtcQmFX7TSiDU HVhJN4OCl1xHe3GmdI+z3dYA4dT0sSi2ZsVHGMkNaOAHOkoa3jkGQNQn5mC8b0wqNVbz OfHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0ydp83cOTiF0yZ15gpWp3rt1C6PORkuPOL1kPI1/R88=; b=ea/tq+n4WnrZwI4x/8exs+rr2A/a27Rv6UQyO3ZuEtWzwW+tAyrx24plNnpMdQj2Ke 4fUHpkVudAkknsYzS1ngFE+WgOTsmwS86vq52fhbXdkruzvhMyOO5D5e0apgq72jb36D Dfm7af/iqRyEjSoabCAI5Yi7XrkoZtLKclWuUv9pDW+nz9NlTa30xMrkKclzxzLkuYP9 e0GK2XhIDEMLoWyQMRfeDAHL3kkjSqR+S/NaeqwWQJOvG1ITu2SKpglsOg1sq/WFtS9Q 2Zo/eFDq0HL2qa3EH2j44D+LC4/y2BmWDzzpiqGiGBG1rR1N34UhHdDiX8wyt0VIrQSW ehjQ== X-Gm-Message-State: ALKqPwdR81x/YhBRaIFMBTz7HSv9SXvH69n+bc2Ae5zElbNDYZr3c01E RtPy/6G27+AC2bxpkGUnmQ0= X-Google-Smtp-Source: AB8JxZqrw/dMTDDmQp7m5vkMNeIMRetnbvLNh/1pqjcb1fDw1300WaKTUBMs8jKIEwjIpP86ZChEyg== X-Received: by 2002:a2e:808a:: with SMTP id i10-v6mr2419564ljg.67.1527095787660; Wed, 23 May 2018 10:16:27 -0700 (PDT) Received: from linux-veee.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id l24-v6sm3474724lje.42.2018.05.23.10.16.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 10:16:26 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Brian Norris , David Woodhouse , Boris Brezillon , Marek Vasut , Richard Weinberger , Rob Herring Subject: [PATCH 2/2] mtd: partitions: use DT info for parsing partitions with specified type Date: Wed, 23 May 2018 19:14:48 +0200 Message-Id: <20180523171448.26234-2-zajec5@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180523171448.26234-1-zajec5@gmail.com> References: <20180523171448.26234-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180523_101639_363921_9CFC7964 X-CRM114-Status: GOOD ( 18.00 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:244 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zajec5[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (zajec5[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: Mark Rutland , devicetree@vger.kernel.org, linux-mtd@lists.infradead.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Jonas Gorski Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Rafał Miłecki This supports nested partitions in a DT. If selected partition has a "compatible" property specified it will be parsed looking for subpartitions. Signed-off-by: Rafał Miłecki --- drivers/mtd/mtdpart.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index f8d3a015cdad..52e2cb35fc79 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -322,22 +322,6 @@ static inline void free_partition(struct mtd_part *p) kfree(p); } -/** - * mtd_parse_part - parse MTD partition looking for subpartitions - * - * @slave: part that is supposed to be a container and should be parsed - * @types: NULL-terminated array with names of partition parsers to try - * - * Some partitions are kind of containers with extra subpartitions (volumes). - * There can be various formats of such containers. This function tries to use - * specified parsers to analyze given partition and registers found - * subpartitions on success. - */ -static int mtd_parse_part(struct mtd_part *slave, const char *const *types) -{ - return parse_mtd_partitions(&slave->mtd, types, NULL); -} - static struct mtd_part *allocate_partition(struct mtd_info *parent, const struct mtd_partition *part, int partno, uint64_t cur_offset) @@ -735,8 +719,8 @@ int add_mtd_partitions(struct mtd_info *master, add_mtd_device(&slave->mtd); mtd_add_partition_attrs(slave); - if (parts[i].types) - mtd_parse_part(slave, parts[i].types); + /* Look for subpartitions */ + parse_mtd_partitions(&slave->mtd, parts[i].types, NULL); cur_offset = slave->offset + slave->mtd.size; } @@ -812,6 +796,12 @@ static const char * const default_mtd_part_types[] = { NULL }; +/* Check DT only when looking for subpartitions. */ +static const char * const default_subpartition_types[] = { + "ofpart", + NULL +}; + static int mtd_part_do_parse(struct mtd_part_parser *parser, struct mtd_info *master, struct mtd_partitions *pparts, @@ -882,7 +872,9 @@ static int mtd_part_of_parse(struct mtd_info *master, const char *fixed = "fixed-partitions"; int ret, err = 0; - np = of_get_child_by_name(mtd_get_of_node(master), "partitions"); + np = mtd_get_of_node(master); + if (!mtd_is_partition(master)) + np = of_get_child_by_name(np, "partitions"); of_property_for_each_string(np, "compatible", prop, compat) { parser = mtd_part_get_compatible_parser(compat); if (!parser) @@ -945,7 +937,8 @@ int parse_mtd_partitions(struct mtd_info *master, const char *const *types, int ret, err = 0; if (!types) - types = default_mtd_part_types; + types = mtd_is_partition(master) ? default_subpartition_types : + default_mtd_part_types; for ( ; *types; types++) { /*