From patchwork Wed Jul 29 09:54:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Suchanek X-Patchwork-Id: 6893721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6FDF7C05AC for ; Wed, 29 Jul 2015 12:06:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8452B207A2 for ; Wed, 29 Jul 2015 12:06:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BC7620690 for ; Wed, 29 Jul 2015 12:06:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKQ6L-0008Ba-Bs; Wed, 29 Jul 2015 12:04:49 +0000 Received: from dec59.ruk.cuni.cz ([2001:718:1e03:4::11]) by bombadil.infradead.org with smtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKQ5l-0007y6-TL for linux-arm-kernel@lists.infradead.org; Wed, 29 Jul 2015 12:04:18 +0000 Received: (qmail 63113 invoked by uid 2313); 29 Jul 2015 12:03:48 -0000 MBOX-Line: From 43664a3e43716ef4a7a9a2c25c5e673f011f89f1 Mon Sep 17 00:00:00 2001 Message-Id: <43664a3e43716ef4a7a9a2c25c5e673f011f89f1.1438170519.git.hramrach@gmail.com> In-Reply-To: References: From: Michal Suchanek Date: Wed, 29 Jul 2015 11:54:54 +0200 Subject: [RFC PATCH 1/2] dt: mtd: ofpart: use compatible for partitions To: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , David Woodhouse , Brian Norris , Kukjin Kim , Krzysztof Kozlowski , Mark Brown , Michal Suchanek , Padmavathi Venna , Boris BREZILLON , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-spi@vger.kernel.org, X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150729_050414_573611_99E2461D X-CRM114-Status: GOOD ( 15.41 ) X-Spam-Score: -4.5 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ofpart is confused when nodes without compatible that are not partitions exist so add compatible for partitions to make tevicetrees unambiguous. Signed-off-by: Michal Suchanek --- .../devicetree/bindings/mtd/partition.txt | 7 +++++- drivers/mtd/ofpart.c | 26 +++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/partition.txt b/Documentation/devicetree/bindings/mtd/partition.txt index 8e5557d..6308c56 100644 --- a/Documentation/devicetree/bindings/mtd/partition.txt +++ b/Documentation/devicetree/bindings/mtd/partition.txt @@ -4,7 +4,7 @@ Partitions can be represented by sub-nodes of an mtd device. This can be used on platforms which have strong conventions about which portions of a flash are used for what purposes, but which don't use an on-flash partition table such as RedBoot. -NOTE: if the sub-node has a compatible string, then it is not a partition. +NOTE: the subnode should have compatible string linux,ofpart-partition #address-cells & #size-cells must both be present in the mtd device. There are two valid values for both: @@ -32,12 +32,14 @@ flash@0 { #size-cells = <1>; partition@0 { + compatible = "linux,ofpart-partition"; label = "u-boot"; reg = <0x0000000 0x100000>; read-only; }; uimage@100000 { + compatible = "linux,ofpart-partition"; reg = <0x0100000 0x200000>; }; }; @@ -48,6 +50,7 @@ flash@1 { /* a 4 GiB partition */ partition@0 { + compatible = "linux,ofpart-partition"; label = "filesystem"; reg = <0x00000000 0x1 0x00000000>; }; @@ -59,12 +62,14 @@ flash@2 { /* an 8 GiB partition */ partition@0 { + compatible = "linux,ofpart-partition"; label = "filesystem #1"; reg = <0x0 0x00000000 0x2 0x00000000>; }; /* a 4 GiB partition */ partition@200000000 { + compatible = "linux,ofpart-partition"; label = "filesystem #2"; reg = <0x2 0x00000000 0x1 0x00000000>; }; diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index aa26c32..f64830b 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -20,9 +20,14 @@ #include #include -static bool node_has_compatible(struct device_node *pp) +const char * OFPART_COMPATIBLE = "linux,ofpart-partition"; + +static bool node_is_compatible(struct device_node *pp) { - return of_get_property(pp, "compatible", NULL); + return of_get_property(pp, "reg", NULL) && + (!of_get_property(pp, "compatible", NULL) || + !strcmp(OFPART_COMPATIBLE, + of_get_property(pp, "compatible", NULL))); } static int parse_ofpart_partitions(struct mtd_info *master, @@ -45,7 +50,7 @@ static int parse_ofpart_partitions(struct mtd_info *master, /* First count the subnodes */ nr_parts = 0; for_each_child_of_node(node, pp) { - if (node_has_compatible(pp)) + if (!node_is_compatible(pp)) continue; nr_parts++; @@ -64,14 +69,11 @@ static int parse_ofpart_partitions(struct mtd_info *master, int len; int a_cells, s_cells; - if (node_has_compatible(pp)) + if (!node_is_compatible(pp)) continue; + /* this should exist due to node_is_compatible */ reg = of_get_property(pp, "reg", &len); - if (!reg) { - nr_parts--; - continue; - } a_cells = of_n_addr_cells(pp); s_cells = of_n_size_cells(pp); @@ -89,15 +91,19 @@ static int parse_ofpart_partitions(struct mtd_info *master, if (of_get_property(pp, "lock", &len)) (*pparts)[i].mask_flags |= MTD_POWERUP_LOCK; + if (!of_get_property(pp, "compatible", NULL)) + pr_warn("%s: DT subnode without compatible parsed as ofpart partition!\n", + node->full_name); + i++; } if (!i) { of_node_put(pp); - pr_err("No valid partition found on %s\n", node->full_name); + pr_notice("No valid ofpart partition found on %s\n", + node->full_name); kfree(*pparts); *pparts = NULL; - return -EINVAL; } return nr_parts;