All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valentine Barshak <vbarshak@ru.mvista.com>
To: linuxppc-dev@ozlabs.org
Cc: linux-mtd@lists.infradead.org
Subject: [PATCH] MTD: small physmap_of partition parsing fixes
Date: Mon, 29 Oct 2007 23:29:02 +0300	[thread overview]
Message-ID: <20071029202902.GA2200@ru.mvista.com> (raw)

Use of_get_next_child for proper ref counting as suggested by Stephen Rothwell
and remove add_mtd_partitions from parse_partitions to avoid duplicate
mtd device registration for RedBoot partitions.

Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
---
 drivers/mtd/maps/physmap_of.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff -pruN linux-2.6.orig/drivers/mtd/maps/physmap_of.c linux-2.6/drivers/mtd/maps/physmap_of.c
--- linux-2.6.orig/drivers/mtd/maps/physmap_of.c	2007-10-29 16:02:37.000000000 +0300
+++ linux-2.6/drivers/mtd/maps/physmap_of.c	2007-10-29 22:41:08.000000000 +0300
@@ -94,14 +94,13 @@ static int __devinit parse_partitions(st
 	 * line, these take precedence over device tree information */
 	nr_parts = parse_mtd_partitions(info->mtd, part_probe_types,
 					&info->parts, 0);
-	if (nr_parts > 0) {
-		add_mtd_partitions(info->mtd, info->parts, nr_parts);
-		return 0;
-	}
+	if (nr_parts > 0)
+		return nr_parts;
 
 	/* First count the subnodes */
 	nr_parts = 0;
-	for (pp = dp->child; pp; pp = pp->sibling)
+	for (pp = of_get_next_child(dp, NULL); pp;
+	     pp = of_get_next_child(dp, pp))
 		nr_parts++;
 
 	if (nr_parts == 0)
@@ -112,12 +111,14 @@ static int __devinit parse_partitions(st
 	if (!info->parts)
 		return -ENOMEM;
 
-	for (pp = dp->child, i = 0; pp; pp = pp->sibling, i++) {
+	for (pp = of_get_next_child(dp, NULL), i = 0; pp;
+	     pp = of_get_next_child(dp, pp), i++) {
 		const u32 *reg;
 		int len;
 
 		reg = of_get_property(pp, "reg", &len);
 		if (!reg || (len != 2*sizeof(u32))) {
+			of_node_put(pp);
 			dev_err(&dev->dev, "Invalid 'reg' on %s\n",
 				dp->full_name);
 			kfree(info->parts);

             reply	other threads:[~2007-10-29 19:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-29 20:29 Valentine Barshak [this message]
2007-10-30  0:10 ` [PATCH] MTD: small physmap_of partition parsing fixes David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071029202902.GA2200@ru.mvista.com \
    --to=vbarshak@ru.mvista.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.