* [PATCH 1/2] bus_for_each_device/bus_for_each_driver: add () to allow use &bus
2012-11-03 15:08 [PATCH 0/2 v2] add bus device Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-03 15:11 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-03 15:11 ` [PATCH 2/2] bus: add bus device Jean-Christophe PLAGNIOL-VILLARD
2012-11-15 10:11 ` [PATCH 0/2 v2] " Jean-Christophe PLAGNIOL-VILLARD
2012-11-19 10:36 ` Sascha Hauer
2 siblings, 1 reply; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-03 15:11 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
include/driver.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/driver.h b/include/driver.h
index 4918054..dd22c77 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -393,11 +393,11 @@ extern struct list_head bus_list;
/* Iterate over all devices of a bus
*/
-#define bus_for_each_device(bus, dev) list_for_each_entry(dev, &bus->device_list, bus_list)
+#define bus_for_each_device(bus, dev) list_for_each_entry(dev, &(bus)->device_list, bus_list)
/* Iterate over all drivers of a bus
*/
-#define bus_for_each_driver(bus, drv) list_for_each_entry(drv, &bus->driver_list, 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;
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] bus: add bus device
2012-11-03 15:11 ` [PATCH 1/2] bus_for_each_device/bus_for_each_driver: add () to allow use &bus Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-03 15:11 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-03 15:11 UTC (permalink / raw)
To: barebox
automatically add it as parent of any bus device if none already specified
we have now a nice output per bus
barebox@Atmel at91sam9x5-ek:/
devices:
`---- platform
`---- atmel_usart0
`---- cs0
`---- atmel_usart1
`---- cs1
`---- mem0
`---- 0x00000000-0x07ffffff: /dev/ram0
`---- mem1
`---- 0x00000000-0x00007fff: /dev/sram0
`---- mem2
`---- 0x00000000-0x000037bf: /dev/defaultenv
`---- mem3
`---- 0x00000000-0xfffffffe: /dev/mem
`---- cs2
`---- w1-gpio
`---- w1_bus0
`---- w1-2d-0
`---- 0x00000000-0x0000007f: /dev/ds24310
`---- w1-2d-1
`---- 0x00000000-0x0000007f: /dev/ds24311
`---- w1-23-0
`---- 0x00000000-0x000001ff: /dev/ds24330
`---- at91sam9x5cm
`---- at91sam9x5ek
`---- at91sam9x5dm
`---- atmel_nand0
`---- nand0
`---- 0x00000000-0x1fffffff: /dev/nand0
`---- 0x00000000-0x0003ffff: /dev/at91bootstrap_raw
`---- 0x00040000-0x0009ffff: /dev/self_raw
`---- 0x000a0000-0x000bffff: /dev/env_raw
`---- 0x000c0000-0x000dffff: /dev/env_raw1
`---- 0x00000000-0x0003ffff: /dev/nand0.at91bootstrap
`---- 0x00040000-0x0009ffff: /dev/nand0.barebox
`---- 0x000a0000-0x000bffff: /dev/nand0.bareboxenv
`---- 0x000c0000-0x000dffff: /dev/nand0.bareboxenv2
`---- 0x000e0000-0x000fffff: /dev/nand0.oftree
`---- 0x00100000-0x001fffff: /dev/nand0.free
`---- 0x00200000-0x007fffff: /dev/nand0.kernel
`---- 0x00800000-0x07ffffff: /dev/nand0.rootfs
`---- 0x08000000-0x1fffffff: /dev/nand0.data
`---- macb0
`---- miibus0
`---- eth0
`---- atmel_spi0
`---- mtd_dataflash0
`---- dataflash0
`---- 0x00000000-0x0041ffff: /dev/dataflash0
`---- atmel_mci0
`---- mci0
`---- 0x00000000-0x1d9bfffff: /dev/disk0
`---- 0x00100000-0x064fffff: /dev/disk0.0
`---- 0x06500000-0x1d9bfffff: /dev/disk0.1
`---- i2c-gpio0
`---- i2c0
`---- qt10700
`---- cs3
`---- mdio_bus
`---- spi
`---- i2c
`---- w1_bus
`---- fs
`---- ramfs0
`---- devfs0
`---- net
`---- global
drivers:
atmel_usart
ramfs
devfs
fat
macb
Generic PHY
atmel_nand
mtd_dataflash
m25p80
atmel_spi
i2c-gpio
mci
atmel_mci
qt1070
w1-gpio
ds2431
ds2433
mem
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/base/bus.c | 10 ++++++++++
drivers/base/driver.c | 5 +++++
include/driver.h | 2 ++
3 files changed, 17 insertions(+)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 69782d2..e2204da 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -25,9 +25,19 @@ static struct bus_type *get_bus_by_name(const char *name)
int bus_register(struct bus_type *bus)
{
+ int ret;
+
if (get_bus_by_name(bus->name))
return -EEXIST;
+ strcpy(bus->dev.name, bus->name);
+ bus->dev.id = DEVICE_ID_SINGLE;
+
+ ret = register_device(&bus->dev);
+ if (ret)
+ return ret;
+
+
INIT_LIST_HEAD(&bus->device_list);
INIT_LIST_HEAD(&bus->driver_list);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 64fe289..eaedac7 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -120,6 +120,11 @@ int register_device(struct device_d *new_device)
if (!new_device->bus)
return 0;
+ if (!new_device->parent) {
+ new_device->parent = &new_device->bus->dev;
+ dev_add_child(new_device->parent, new_device);
+ }
+
list_add_tail(&new_device->bus_list, &new_device->bus->device_list);
bus_for_each_driver(new_device->bus, drv) {
diff --git a/include/driver.h b/include/driver.h
index dd22c77..5d433ec 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -378,6 +378,8 @@ struct bus_type {
int (*probe)(struct device_d *dev);
void (*remove)(struct device_d *dev);
+ struct device_d dev;
+
struct list_head list;
struct list_head device_list;
struct list_head driver_list;
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2 v2] add bus device
2012-11-03 15:08 [PATCH 0/2 v2] add bus device Jean-Christophe PLAGNIOL-VILLARD
2012-11-03 15:11 ` [PATCH 1/2] bus_for_each_device/bus_for_each_driver: add () to allow use &bus Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-15 10:11 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-19 10:36 ` Sascha Hauer
2 siblings, 0 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-15 10:11 UTC (permalink / raw)
To: barebox
ping
On 16:08 Sat 03 Nov , Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
>
> The following changes since commit 37b37cb2bff79f4edbbcaf316149d814e11a358e:
>
> eth: register device a pure device (2012-11-03 07:48:12 +0800)
>
> are available in the git repository at:
>
> git://git.jcrosoft.org/barebox.git tags/bus_device
>
> for you to fetch changes up to 35f8933bf003b5049131487882d8ae57a1a50d3a:
>
> bus: add bus device (2012-11-03 07:52:49 +0800)
>
> ----------------------------------------------------------------
> add bus device
>
> This patch serie add a pure device for each bus
>
> And set this device to each bus device as a parent if the device
> does not have a parent already
>
> we have now a nice output per bus
>
> barebox@Atmel at91sam9x5-ek:/
> devices:
> `---- platform
> `---- atmel_usart0
> `---- cs0
> `---- atmel_usart1
> `---- cs1
> `---- mem0
> `---- 0x00000000-0x07ffffff: /dev/ram0
> `---- mem1
> `---- 0x00000000-0x00007fff: /dev/sram0
> `---- mem2
> `---- 0x00000000-0x000037bf: /dev/defaultenv
> `---- mem3
> `---- 0x00000000-0xfffffffe: /dev/mem
> `---- cs2
> `---- w1-gpio
> `---- w1_bus0
> `---- w1-2d-0
> `---- 0x00000000-0x0000007f: /dev/ds24310
> `---- w1-2d-1
> `---- 0x00000000-0x0000007f: /dev/ds24311
> `---- w1-23-0
> `---- 0x00000000-0x000001ff: /dev/ds24330
> `---- at91sam9x5cm
> `---- at91sam9x5ek
> `---- at91sam9x5dm
> `---- atmel_nand0
> `---- nand0
> `---- 0x00000000-0x1fffffff: /dev/nand0
> `---- 0x00000000-0x0003ffff: /dev/at91bootstrap_raw
> `---- 0x00040000-0x0009ffff: /dev/self_raw
> `---- 0x000a0000-0x000bffff: /dev/env_raw
> `---- 0x000c0000-0x000dffff: /dev/env_raw1
> `---- 0x00000000-0x0003ffff: /dev/nand0.at91bootstrap
> `---- 0x00040000-0x0009ffff: /dev/nand0.barebox
> `---- 0x000a0000-0x000bffff: /dev/nand0.bareboxenv
> `---- 0x000c0000-0x000dffff: /dev/nand0.bareboxenv2
> `---- 0x000e0000-0x000fffff: /dev/nand0.oftree
> `---- 0x00100000-0x001fffff: /dev/nand0.free
> `---- 0x00200000-0x007fffff: /dev/nand0.kernel
> `---- 0x00800000-0x07ffffff: /dev/nand0.rootfs
> `---- 0x08000000-0x1fffffff: /dev/nand0.data
> `---- macb0
> `---- miibus0
> `---- eth0
> `---- atmel_spi0
> `---- mtd_dataflash0
> `---- 0x00000000-0x0041ffff: /dev/dataflash0
> `---- atmel_mci0
> `---- mci0
> `---- 0x00000000-0x1d9bfffff: /dev/disk0
> `---- 0x00100000-0x064fffff: /dev/disk0.0
> `---- 0x06500000-0x1d9bfffff: /dev/disk0.1
> `---- i2c-gpio0
> `---- i2c0
> `---- qt10700
> `---- cs3
> `---- mdio_bus
> `---- spi
> `---- i2c
> `---- w1_bus
> `---- fs
> `---- ramfs0
> `---- devfs0
> `---- net
> `---- global
>
> drivers:
> atmel_usart
> ramfs
> devfs
> fat
> macb
> Generic PHY
> atmel_nand
> mtd_dataflash
> m25p80
> atmel_spi
> i2c-gpio
> mci
> atmel_mci
> qt1070
> w1-gpio
> ds2431
> ds2433
> mem
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
>
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
> bus_for_each_device/bus_for_each_driver: add () to allow use &bus
> bus: add bus device
>
> drivers/base/bus.c | 10 ++++++++++
> drivers/base/driver.c | 5 +++++
> include/driver.h | 6 ++++--
> 3 files changed, 19 insertions(+), 2 deletions(-)
>
> Best Regards,
> J.
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2 v2] add bus device
2012-11-03 15:08 [PATCH 0/2 v2] add bus device Jean-Christophe PLAGNIOL-VILLARD
2012-11-03 15:11 ` [PATCH 1/2] bus_for_each_device/bus_for_each_driver: add () to allow use &bus Jean-Christophe PLAGNIOL-VILLARD
2012-11-15 10:11 ` [PATCH 0/2 v2] " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-11-19 10:36 ` Sascha Hauer
2 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2012-11-19 10:36 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Sat, Nov 03, 2012 at 04:08:23PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
>
> The following changes since commit 37b37cb2bff79f4edbbcaf316149d814e11a358e:
>
> eth: register device a pure device (2012-11-03 07:48:12 +0800)
>
> are available in the git repository at:
>
> git://git.jcrosoft.org/barebox.git tags/bus_device
>
> for you to fetch changes up to 35f8933bf003b5049131487882d8ae57a1a50d3a:
>
> bus: add bus device (2012-11-03 07:52:49 +0800)
Applied, thanks
Sascha
>
> ----------------------------------------------------------------
> add bus device
>
> This patch serie add a pure device for each bus
>
> And set this device to each bus device as a parent if the device
> does not have a parent already
>
> we have now a nice output per bus
>
> barebox@Atmel at91sam9x5-ek:/
> devices:
> `---- platform
> `---- atmel_usart0
> `---- cs0
> `---- atmel_usart1
> `---- cs1
> `---- mem0
> `---- 0x00000000-0x07ffffff: /dev/ram0
> `---- mem1
> `---- 0x00000000-0x00007fff: /dev/sram0
> `---- mem2
> `---- 0x00000000-0x000037bf: /dev/defaultenv
> `---- mem3
> `---- 0x00000000-0xfffffffe: /dev/mem
> `---- cs2
> `---- w1-gpio
> `---- w1_bus0
> `---- w1-2d-0
> `---- 0x00000000-0x0000007f: /dev/ds24310
> `---- w1-2d-1
> `---- 0x00000000-0x0000007f: /dev/ds24311
> `---- w1-23-0
> `---- 0x00000000-0x000001ff: /dev/ds24330
> `---- at91sam9x5cm
> `---- at91sam9x5ek
> `---- at91sam9x5dm
> `---- atmel_nand0
> `---- nand0
> `---- 0x00000000-0x1fffffff: /dev/nand0
> `---- 0x00000000-0x0003ffff: /dev/at91bootstrap_raw
> `---- 0x00040000-0x0009ffff: /dev/self_raw
> `---- 0x000a0000-0x000bffff: /dev/env_raw
> `---- 0x000c0000-0x000dffff: /dev/env_raw1
> `---- 0x00000000-0x0003ffff: /dev/nand0.at91bootstrap
> `---- 0x00040000-0x0009ffff: /dev/nand0.barebox
> `---- 0x000a0000-0x000bffff: /dev/nand0.bareboxenv
> `---- 0x000c0000-0x000dffff: /dev/nand0.bareboxenv2
> `---- 0x000e0000-0x000fffff: /dev/nand0.oftree
> `---- 0x00100000-0x001fffff: /dev/nand0.free
> `---- 0x00200000-0x007fffff: /dev/nand0.kernel
> `---- 0x00800000-0x07ffffff: /dev/nand0.rootfs
> `---- 0x08000000-0x1fffffff: /dev/nand0.data
> `---- macb0
> `---- miibus0
> `---- eth0
> `---- atmel_spi0
> `---- mtd_dataflash0
> `---- 0x00000000-0x0041ffff: /dev/dataflash0
> `---- atmel_mci0
> `---- mci0
> `---- 0x00000000-0x1d9bfffff: /dev/disk0
> `---- 0x00100000-0x064fffff: /dev/disk0.0
> `---- 0x06500000-0x1d9bfffff: /dev/disk0.1
> `---- i2c-gpio0
> `---- i2c0
> `---- qt10700
> `---- cs3
> `---- mdio_bus
> `---- spi
> `---- i2c
> `---- w1_bus
> `---- fs
> `---- ramfs0
> `---- devfs0
> `---- net
> `---- global
>
> drivers:
> atmel_usart
> ramfs
> devfs
> fat
> macb
> Generic PHY
> atmel_nand
> mtd_dataflash
> m25p80
> atmel_spi
> i2c-gpio
> mci
> atmel_mci
> qt1070
> w1-gpio
> ds2431
> ds2433
> mem
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
>
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
> bus_for_each_device/bus_for_each_driver: add () to allow use &bus
> bus: add bus device
>
> drivers/base/bus.c | 10 ++++++++++
> drivers/base/driver.c | 5 +++++
> include/driver.h | 6 ++++--
> 3 files changed, 19 insertions(+), 2 deletions(-)
>
> Best Regards,
> J.
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread