mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 04/12] fs: add bus device
Date: Sun, 14 Oct 2012 23:01:10 +0200	[thread overview]
Message-ID: <1350248478-19359-4-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1350248478-19359-1-git-send-email-plagnioj@jcrosoft.com>

automatically add it as parent of any fs device

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/fs.c |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index b9a1f17..b63a005 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1131,7 +1131,12 @@ static void fs_remove(struct device_d *dev)
 	free(fsdev);
 }
 
-struct bus_type fs_bus = {
+struct device_d fs_bus = {
+	.name = "fs",
+	.id = DEVICE_ID_SINGLE,
+};
+
+struct bus_type fs_bus_type = {
 	.name = "fs",
 	.match = fs_match,
 	.probe = fs_probe,
@@ -1140,13 +1145,14 @@ struct bus_type fs_bus = {
 
 static int fs_bus_init(void)
 {
-	return bus_register(&fs_bus);
+	register_device(&fs_bus);
+	return bus_register(&fs_bus_type);
 }
 pure_initcall(fs_bus_init);
 
 int register_fs_driver(struct fs_driver_d *fsdrv)
 {
-	fsdrv->drv.bus = &fs_bus;
+	fsdrv->drv.bus = &fs_bus_type;
 	register_driver(&fsdrv->drv);
 
 	return 0;
@@ -1162,10 +1168,7 @@ static const char *detect_fs(const char *filename)
 	if (type == filetype_unknown)
 		return NULL;
 
-	for_each_driver(drv) {
-		if (drv->bus != &fs_bus)
-			continue;
-
+	bus_for_each_driver(&fs_bus_type, drv) {
 		fdrv = drv_to_fs_driver(drv);
 
 		if (type == fdrv->type)
@@ -1217,11 +1220,15 @@ int mount(const char *device, const char *fsname, const char *_path)
 	safe_strncpy(fsdev->dev.name, fsname, MAX_DRIVER_NAME);
 	fsdev->dev.id = get_free_deviceid(fsdev->dev.name);
 	fsdev->path = xstrdup(path);
-	fsdev->dev.bus = &fs_bus;
+	fsdev->dev.bus = &fs_bus_type;
 
 	if (!strncmp(device, "/dev/", 5))
 		fsdev->cdev = cdev_by_name(device + 5);
 
+	if (!fsdev->dev.parent) {
+		fsdev->dev.parent = &fs_bus;
+		dev_add_child(fsdev->dev.parent, &fsdev->dev);
+	}
 	ret = register_device(&fsdev->dev);
 	if (ret)
 		goto err_register;
-- 
1.7.10.4


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

  parent reply	other threads:[~2012-10-14 21:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-14 20:59 [PATCH 00/12] " Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01 ` [PATCH 01/12] bus_for_each_device/bus_for_each_driver: add () to allow use &bus Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 02/12] platform: add bus device Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 03/12] amba: " Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-10-14 21:01   ` [PATCH 05/12] mdio: " Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 06/12] i2c: " Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 07/12] spi: " Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 08/12] usb: " Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 09/12] fb: " Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 10/12] mtd: register device a pure device Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 11/12] mtd: add parent support Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01   ` [PATCH 12/12] eth: register device a pure device Jean-Christophe PLAGNIOL-VILLARD
2012-10-15  7:10 ` [PATCH 00/12] add bus device Sascha Hauer
2012-10-15 10:23   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-15 13:21     ` Sascha Hauer
2012-10-15 14:49       ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-15 19:09         ` Sascha Hauer
2012-10-29 10:41         ` 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=1350248478-19359-4-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.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