mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@kymetacorp.com>
To: barebox <barebox@lists.infradead.org>
Subject: [PATCH] cdev: When creating a new cdev, initialize device_node
Date: Fri, 11 Dec 2015 00:23:11 +0000	[thread overview]
Message-ID: <1449793397.26955.94.camel@rtred1test09.kymeta.local> (raw)

If a new cdev doesn't have a device_node defined when passed to
devfs_create(), set it to the device_node of the parent device, if one
exists.

For non-partitions, like ocotp or eeprom devices, this is the correct
thing to do.  Partitions need to use, and do use, a different node.

The code from commit 274e0b8dc48956babeaa2faf70bf8066e656b621 to set
device_node in ocotp can be removed.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---
Tested this to work for loading the env from an at24 eeprom.  Should work
for any other non-partitioned device too.

 arch/arm/mach-imx/ocotp.c | 1 -
 fs/devfs-core.c           | 5 ++++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c
index 6ff5ee4..c99a003 100644
--- a/arch/arm/mach-imx/ocotp.c
+++ b/arch/arm/mach-imx/ocotp.c
@@ -426,7 +426,6 @@ static int imx_ocotp_probe(struct device_d *dev)
 	cdev->priv	= priv;
 	cdev->size	= 192;
 	cdev->name	= "imx-ocotp";
-	cdev->device_node = dev->device_node;
 
 	ret = devfs_create(cdev);
 
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 2541ea3..a5ac5a3 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -260,8 +260,11 @@ int devfs_create(struct cdev *new)
 		return -EEXIST;
 
 	list_add_tail(&new->list, &cdev_list);
-	if (new->dev)
+	if (new->dev) {
 		list_add_tail(&new->devices_list, &new->dev->cdevs);
+		if (!new->device_node)
+			new->device_node = new->dev->device_node;
+	}
 
 	return 0;
 }
-- 
1.8.3.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-12-11  0:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11  0:23 Trent Piepho [this message]
2015-12-14 10:25 ` Sascha Hauer

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=1449793397.26955.94.camel@rtred1test09.kymeta.local \
    --to=tpiepho@kymetacorp.com \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox