From patchwork Tue Aug 25 13:52:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Krill X-Patchwork-Id: 32039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 2FDE4B7B7E for ; Tue, 25 Aug 2009 23:55:42 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MfwSI-0007Qq-AV; Tue, 25 Aug 2009 13:52:58 +0000 Received: from cursor.subgra.de ([78.46.252.50]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1MfwSC-0007PP-66 for linux-mtd@lists.infradead.org; Tue, 25 Aug 2009 13:52:56 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by cursor.subgra.de (Postfix) with ESMTP id D981D16000A; Tue, 25 Aug 2009 15:57:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at cursor.subgra.de Received: from cursor.subgra.de ([127.0.0.1]) by localhost (cursor.subgra.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GAfhzY4mO+Se; Tue, 25 Aug 2009 15:57:25 +0200 (CEST) Received: from caupo.subgra.de (caupo.subgra.de [78.46.252.49]) by cursor.subgra.de (Postfix) with SMTP id 518E916000B; Tue, 25 Aug 2009 15:57:24 +0200 (CEST) Received: by caupo.subgra.de (sSMTP sendmail emulation); Tue, 25 Aug 2009 15:52:41 +0200 Date: Tue, 25 Aug 2009 15:52:41 +0200 From: Benjamin Krill To: Kumar Gala , David Woodhouse , linux-mtd@lists.infradead.org, linuxppc-dev@ozlabs.org Subject: [PATCH] MTD ofpart: Check availability of reg property instead of name property Message-ID: <20090825135241.GA20036@codiert.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: mutt-ng/devel-r804 (Linux) X-Spam-Score: 0.0 (/) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The previous implementation breaks the dts binding "mtd-physmap.txt". This implementation fixes the issue by checking the availability of the reg property instead of the name property. Signed-off-by: Benjamin Krill --- drivers/mtd/ofpart.c | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 3e164f0..62d6a78 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -46,21 +46,12 @@ int __devinit of_mtd_parse_partitions(struct device *dev, const u32 *reg; int len; - /* check if this is a partition node */ - partname = of_get_property(pp, "name", &len); - if (strcmp(partname, "partition") != 0) { + reg = of_get_property(pp, "reg", &len); + if (!reg) { nr_parts--; continue; } - reg = of_get_property(pp, "reg", &len); - if (!reg || (len != 2 * sizeof(u32))) { - of_node_put(pp); - dev_err(dev, "Invalid 'reg' on %s\n", node->full_name); - kfree(*pparts); - *pparts = NULL; - return -EINVAL; - } (*pparts)[i].offset = reg[0]; (*pparts)[i].size = reg[1]; @@ -75,6 +66,14 @@ int __devinit of_mtd_parse_partitions(struct device *dev, i++; } + if (!i) { + of_node_put(pp); + dev_err(dev, "No valid partition found on %s\n", node->full_name); + kfree(*pparts); + *pparts = NULL; + return -EINVAL; + } + return nr_parts; } EXPORT_SYMBOL(of_mtd_parse_partitions);