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: 32037 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id D2890B7B6B for ; Tue, 25 Aug 2009 23:53:27 +1000 (EST) Received: by ozlabs.org (Postfix) id C6BD5DDDB2; Tue, 25 Aug 2009 23:53:27 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (bilbo.ozlabs.org [203.10.76.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bilbo.ozlabs.org", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id C4E1CDDDA2 for ; Tue, 25 Aug 2009 23:53:27 +1000 (EST) Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id D16CFB7E19 for ; Tue, 25 Aug 2009 23:53:02 +1000 (EST) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id E4CC8B707B for ; Tue, 25 Aug 2009 23:52:56 +1000 (EST) Received: by ozlabs.org (Postfix) id D6B60DDDB2; Tue, 25 Aug 2009 23:52:56 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from cursor.subgra.de (cursor.subgra.de [78.46.252.50]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "cursor.subgra.de", Issuer "cursor.subgra.de" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 7F366DDDA0 for ; Tue, 25 Aug 2009 23:52:56 +1000 (EST) 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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.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);