From patchwork Mon Jun 10 10:26:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Wu X-Patchwork-Id: 2697011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 4C4F03FD4F for ; Mon, 10 Jun 2013 11:39:14 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UlzQq-0004hB-SO; Mon, 10 Jun 2013 10:34:42 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UlzOs-00070I-Re; Mon, 10 Jun 2013 10:32:34 +0000 Received: from eusmtp01.atmel.com ([212.144.249.242]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UlzOq-0006ys-0v; Mon, 10 Jun 2013 10:32:32 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server id 14.2.342.3; Mon, 10 Jun 2013 12:32:09 +0200 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id 14.2.342.3; Mon, 10 Jun 2013 18:32:23 +0800 From: Josh Wu To: , , Subject: [PATCH 6/6] mtd: ofpart: add compatible check for child nodes Date: Mon, 10 Jun 2013 18:26:54 +0800 Message-ID: <1370860014-1770-7-git-send-email-josh.wu@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1370860014-1770-1-git-send-email-josh.wu@atmel.com> References: <1370860014-1770-1-git-send-email-josh.wu@atmel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130610_063232_209420_9BF9D118 X-CRM114-Status: GOOD ( 10.95 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.1 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] Cc: nicolas.ferre@atmel.com, plagnioj@jcrosoft.com, Josh Wu X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If the child node has compatible property then it is a driver not partition. Signed-off-by: Josh Wu --- drivers/mtd/ofpart.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 553d6d6..61ce1f8 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -20,6 +20,10 @@ #include #include +static bool node_has_compatible(struct device_node *pp, int *len) +{ + return of_get_property(pp, "compatible", len); +} static int parse_ofpart_partitions(struct mtd_info *master, struct mtd_partition **pparts, struct mtd_part_parser_data *data) @@ -40,8 +44,13 @@ static int parse_ofpart_partitions(struct mtd_info *master, /* First count the subnodes */ pp = NULL; nr_parts = 0; - while ((pp = of_get_next_child(node, pp))) + while ((pp = of_get_next_child(node, pp))) { + int len; + if (node_has_compatible(pp, &len)) + continue; + nr_parts++; + } if (nr_parts == 0) return 0; @@ -57,6 +66,9 @@ static int parse_ofpart_partitions(struct mtd_info *master, int len; int a_cells, s_cells; + if (node_has_compatible(pp, &len)) + continue; + reg = of_get_property(pp, "reg", &len); if (!reg) { nr_parts--;