From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 02/12] platform: add bus device
Date: Sun, 14 Oct 2012 23:01:08 +0200 [thread overview]
Message-ID: <1350248478-19359-2-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1350248478-19359-1-git-send-email-plagnioj@jcrosoft.com>
automatically add it as parent if the device does not have a parent already
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/base/platform.c | 18 ++++++++++++++----
include/driver.h | 3 ++-
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index ea4e37b..08787f6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -57,19 +57,28 @@ static void platform_remove(struct device_d *dev)
int platform_driver_register(struct driver_d *drv)
{
- drv->bus = &platform_bus;
+ drv->bus = &platform_bus_type;
return register_driver(drv);
}
int platform_device_register(struct device_d *new_device)
{
- new_device->bus = &platform_bus;
+ new_device->bus = &platform_bus_type;
+ if (!new_device->parent) {
+ new_device->parent = &platform_bus;
+ dev_add_child(new_device->parent, new_device);
+ }
return register_device(new_device);
}
-struct bus_type platform_bus = {
+struct device_d platform_bus = {
+ .name = "platfrom",
+ .id = DEVICE_ID_SINGLE,
+};
+
+struct bus_type platform_bus_type = {
.name = "platform",
.match = platform_match,
.probe = platform_probe,
@@ -78,6 +87,7 @@ struct bus_type platform_bus = {
static int plarform_init(void)
{
- return bus_register(&platform_bus);
+ register_device(&platform_bus);
+ return bus_register(&platform_bus_type);
}
pure_initcall(plarform_init);
diff --git a/include/driver.h b/include/driver.h
index dd22c77..5d85c1d 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -399,7 +399,8 @@ extern struct list_head bus_list;
*/
#define bus_for_each_driver(bus, drv) list_for_each_entry(drv, &(bus)->driver_list, bus_list)
-extern struct bus_type platform_bus;
+extern struct bus_type platform_bus_type;
+extern struct device_d platform_bus;
int platform_driver_register(struct driver_d *drv);
int platform_device_register(struct device_d *new_device);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev 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 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-10-14 21:01 ` [PATCH 03/12] amba: add bus device Jean-Christophe PLAGNIOL-VILLARD
2012-10-14 21:01 ` [PATCH 04/12] fs: " Jean-Christophe PLAGNIOL-VILLARD
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-2-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