mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] parent fixups
@ 2011-08-15  8:46 Sascha Hauer
  2011-08-15  8:46 ` [PATCH 1/7] mci: embed mci_dev into mci_host instead of allocating it seperately Sascha Hauer
                   ` (11 more replies)
  0 siblings, 12 replies; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15  8:46 UTC (permalink / raw)
  To: barebox

Hi,

We have a nice devinfo command which can print the devices as a tree.
Let's make more use of it and make spi/network/console devices children
of the corresponding hardware devices.
Also, when a file under /dev/ is associated to a device, print the
start and end with the information.

On a i.MX51 babbage board we change from:

devices:
|----imx_serial0
|----cs0
|----mem0 (ram0)
|----imx_iim0 (imx_iim_bank0, imx_iim_bank1, imx_iim_bank2, imx_iim_bank3, imx_iim_bank4, imx_iim_bank5, imx_iim_bank6, imx_iim_bank7)
|----ramfs0
|----devfs0
|----mem1 (defaultenv)
|----mem2 (mem)
|----fec_imx0
|----miidev0 (phy0)
|----eth0
|----imx-esdhc0
|----mci0
|----disk0
|----imx_spi0
|----mc13892-spi0 (mc13892)

to this:

devices:
`---- imx_serial0
     `---- cs0
`---- mem0
     `---- 0x00000000-0x1fffffff: /dev/ram0
`---- imx_iim0
     `---- 0x00000000-0x0000001f: /dev/imx_iim_bank0
     `---- 0x00000000-0x0000001f: /dev/imx_iim_bank1
     `---- 0x00000000-0x0000001f: /dev/imx_iim_bank2
     `---- 0x00000000-0x0000001f: /dev/imx_iim_bank3
     `---- 0x00000000-0x0000001f: /dev/imx_iim_bank4
     `---- 0x00000000-0x0000001f: /dev/imx_iim_bank5
     `---- 0x00000000-0x0000001f: /dev/imx_iim_bank6
     `---- 0x00000000-0x0000001f: /dev/imx_iim_bank7
`---- ramfs0
`---- devfs0
`---- mem1
     `---- 0x00000000-0x00001e08: /dev/defaultenv
`---- mem2
     `---- 0x00000000-0xfffffffe: /dev/mem
`---- fec_imx0
     `---- miidev0
          `---- 0x00000000-0x0000003f: /dev/phy0
     `---- eth0
`---- imx-esdhc0
     `---- mci0
          `---- disk0
`---- imx_spi0
     `---- mc13892-spi0
          `---- 0x00000000-0x000000ff: /dev/mc13892


Sascha Hauer (7):
      mci: embed mci_dev into mci_host instead of allocating it seperately
      net: make the ethernet device a child of the hardware device
      net mii: add a parent pointer to miidevs and set it to the hardware device
      console: make console device a child of the hardware device
      mci: parent fixups
      spi: make the spi devices children of the parent bus
      devinfo: beautify output

 common/console.c           |    2 ++
 drivers/base/driver.c      |   27 ++++++++++++++-------------
 drivers/mci/atmel_mci.c    |    1 +
 drivers/mci/imx-esdhc.c    |    1 +
 drivers/mci/imx.c          |    1 +
 drivers/mci/mci-core.c     |    9 +++++----
 drivers/mci/omap_hsmmc.c   |    1 +
 drivers/net/altera_tse.c   |    2 ++
 drivers/net/at91_ether.c   |    1 +
 drivers/net/cs8900.c       |    1 +
 drivers/net/dm9000.c       |    2 ++
 drivers/net/ep93xx.c       |    2 ++
 drivers/net/fec_imx.c      |    2 ++
 drivers/net/fec_mpc5200.c  |    2 ++
 drivers/net/macb.c         |    2 ++
 drivers/net/miidev.c       |    2 ++
 drivers/net/netx_eth.c     |    2 ++
 drivers/net/smc91111.c     |    2 ++
 drivers/net/smc911x.c      |    2 ++
 drivers/net/usb/asix.c     |    1 +
 drivers/net/usb/smsc95xx.c |    1 +
 drivers/net/usb/usbnet.c   |    1 +
 drivers/spi/spi.c          |    1 +
 include/mci.h              |    1 +
 include/miidev.h           |    1 +
 include/net.h              |    1 +
 net/eth.c                  |    4 ++++
 27 files changed, 58 insertions(+), 17 deletions(-)

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/7] mci: embed mci_dev into mci_host instead of allocating it seperately
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
@ 2011-08-15  8:46 ` Sascha Hauer
  2011-08-15  8:46 ` [PATCH 2/7] net: make the ethernet device a child of the hardware device Sascha Hauer
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15  8:46 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c |    4 +---
 include/mci.h          |    1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index fea2691..6a29619 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1359,9 +1359,7 @@ device_initcall(mci_init);
  */
 int mci_register(struct mci_host *host)
 {
-	struct device_d *mci_dev;
-
-	mci_dev = xzalloc(sizeof(struct device_d));
+	struct device_d *mci_dev = &host->dev;
 
 	strcpy(mci_dev->name, mci_driver.name);
 	mci_dev->platform_data = (void*)host;
diff --git a/include/mci.h b/include/mci.h
index 8c669ca..69cffe8 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -194,6 +194,7 @@ struct mci_data {
 /** host information */
 struct mci_host {
 	struct device_d *hw_dev;	/**< the host MCI hardware device */
+	struct device_d dev;		/**< our device */
 	unsigned voltages;
 	unsigned host_caps;	/**< Host's interface capabilities, refer MMC_VDD_* */
 	unsigned f_min;		/**< host interface lower limit */
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 2/7] net: make the ethernet device a child of the hardware device
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
  2011-08-15  8:46 ` [PATCH 1/7] mci: embed mci_dev into mci_host instead of allocating it seperately Sascha Hauer
@ 2011-08-15  8:46 ` Sascha Hauer
  2011-08-15  8:46 ` [PATCH 3/7] net mii: add a parent pointer to miidevs and set it to " Sascha Hauer
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15  8:46 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/altera_tse.c  |    1 +
 drivers/net/at91_ether.c  |    1 +
 drivers/net/cs8900.c      |    1 +
 drivers/net/dm9000.c      |    1 +
 drivers/net/ep93xx.c      |    1 +
 drivers/net/fec_imx.c     |    1 +
 drivers/net/fec_mpc5200.c |    1 +
 drivers/net/macb.c        |    1 +
 drivers/net/netx_eth.c    |    1 +
 drivers/net/smc91111.c    |    1 +
 drivers/net/smc911x.c     |    1 +
 drivers/net/usb/usbnet.c  |    1 +
 include/net.h             |    1 +
 net/eth.c                 |    4 ++++
 14 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index e7dabda..ac8dea4 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -518,6 +518,7 @@ static int tse_probe(struct device_d *dev)
 	edev->halt = tse_eth_halt;
 	edev->get_ethaddr = tse_get_ethaddr;
 	edev->set_ethaddr = tse_set_ethaddr;
+	edev->parent = dev;
 
 #ifdef CONFIG_TSE_USE_DEDICATED_DESC_MEM
 	tx_desc = dev_request_mem_region(dev, 3);
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index d5e26a1..8d0b43b 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -272,6 +272,7 @@ static int at91rm9200_eth_init (struct device_d *dev)
 	edev->halt = at91rm9200_eth_halt;
 	edev->get_ethaddr = at91rm9200_get_ethaddr;
 	edev->set_ethaddr = at91rm9200_set_ethaddr;
+	edev->parent = dev;
 
 	p_mac = AT91C_BASE_EMAC;
 
diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index d954e39..33afc5e 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -458,6 +458,7 @@ static int cs8900_probe(struct device_d *dev)
 	edev->halt = cs8900_halt;
 	edev->get_ethaddr = cs8900_get_ethaddr;
 	edev->set_ethaddr = cs8900_set_ethaddr;
+	edev->parent = dev;
 
 	eth_register(edev);
 	return 0;
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index be14317..98134ce 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -513,6 +513,7 @@ static int dm9000_probe(struct device_d *dev)
 	edev->halt = dm9000_eth_halt;
 	edev->set_ethaddr = dm9000_set_ethaddr;
 	edev->get_ethaddr = dm9000_get_ethaddr;
+	edev->parent = dev;
 
 	/* RESET device */
 	dm9000_reset(priv);
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
index 7821cd2..55848cf 100644
--- a/drivers/net/ep93xx.c
+++ b/drivers/net/ep93xx.c
@@ -497,6 +497,7 @@ static int ep93xx_eth_probe(struct device_d *dev)
 	edev->halt = ep93xx_eth_halt;
 	edev->get_ethaddr = ep93xx_eth_get_ethaddr;
 	edev->set_ethaddr = ep93xx_eth_set_ethaddr;
+	edev->parent = dev;
 
 	priv->miidev.read = ep93xx_phy_read;
 	priv->miidev.write = ep93xx_phy_write;
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 8b4f439..bbce2b6 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -612,6 +612,7 @@ static int fec_probe(struct device_d *dev)
 	edev->halt = fec_halt;
 	edev->get_ethaddr = fec_get_hwaddr;
 	edev->set_ethaddr = fec_set_hwaddr;
+	edev->parent = dev;
 
 	fec->regs = dev_request_mem_region(dev, 0);
 
diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c
index 310d70d..84be3c7 100644
--- a/drivers/net/fec_mpc5200.c
+++ b/drivers/net/fec_mpc5200.c
@@ -672,6 +672,7 @@ int mpc5xxx_fec_probe(struct device_d *dev)
 	edev->halt = mpc5xxx_fec_halt;
 	edev->get_ethaddr = mpc5xxx_fec_get_ethaddr;
 	edev->set_ethaddr = mpc5xxx_fec_set_ethaddr;
+	edev->parent = dev;
 
 	fec->eth = dev_request_mem_region(dev, 0);
 	fec->tbdBase = (FEC_TBD *)FEC_BD_BASE;
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 95ad3d7..435fa28 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -433,6 +433,7 @@ static int macb_probe(struct device_d *dev)
 	edev->halt = macb_halt;
 	edev->get_ethaddr = pdata->get_ethaddr ? pdata->get_ethaddr : macb_get_ethaddr;
 	edev->set_ethaddr = macb_set_ethaddr;
+	edev->parent = dev;
 
 	macb->miidev.read = macb_phy_read;
 	macb->miidev.write = macb_phy_write;
diff --git a/drivers/net/netx_eth.c b/drivers/net/netx_eth.c
index fd40f62..fd09983 100644
--- a/drivers/net/netx_eth.c
+++ b/drivers/net/netx_eth.c
@@ -258,6 +258,7 @@ static int netx_eth_probe(struct device_d *dev)
 	edev->halt = netx_eth_halt;
 	edev->get_ethaddr = netx_eth_get_ethaddr;
 	edev->set_ethaddr = netx_eth_set_ethaddr;
+	edev->parent = dev;
 
 	priv->miidev.read = netx_miidev_read;
 	priv->miidev.write = netx_miidev_write;
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 1c1ffea..edb0f68 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -1311,6 +1311,7 @@ static int smc91c111_probe(struct device_d *dev)
 	edev->halt = smc91c111_eth_halt;
 	edev->get_ethaddr = smc91c111_get_ethaddr;
 	edev->set_ethaddr = smc91c111_set_ethaddr;
+	edev->parent = dev;
 
 	priv->miidev.read = smc91c111_phy_read;
 	priv->miidev.write = smc91c111_phy_write;
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 8c6f9fc..45d24ad 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -725,6 +725,7 @@ static int smc911x_probe(struct device_d *dev)
 	edev->halt = smc911x_eth_halt;
 	edev->get_ethaddr = smc911x_get_ethaddr;
 	edev->set_ethaddr = smc911x_set_ethaddr;
+	edev->parent = dev;
 
 	priv->miidev.read = smc911x_phy_read;
 	priv->miidev.write = smc911x_phy_write;
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index cd658ed..5ffd7a6 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -206,6 +206,7 @@ int usbnet_probe(struct usb_device *usbdev, const struct usb_device_id *prod)
 	edev->recv = usbnet_recv,
 	edev->halt = usbnet_halt,
 	edev->priv = undev;
+	edev->parent = &usbdev->dev;
 
 	info = (struct driver_info *)prod->driver_info;
 	undev->driver_info = info;
diff --git a/include/net.h b/include/net.h
index 1272f23..d0f8341 100644
--- a/include/net.h
+++ b/include/net.h
@@ -43,6 +43,7 @@ struct eth_device {
 	void *priv;
 
 	struct device_d dev;
+	struct device_d *parent;
 
 	struct list_head list;
 };
diff --git a/net/eth.c b/net/eth.c
index 2a801f5..621cb59 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -199,6 +199,10 @@ int eth_register(struct eth_device *edev)
 
 	strcpy(edev->dev.name, "eth");
 	edev->dev.id = -1;
+
+	if (edev->parent)
+		dev_add_child(edev->parent, &edev->dev);
+
 	register_device(&edev->dev);
 
 	dev->type_data = edev;
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 3/7] net mii: add a parent pointer to miidevs and set it to the hardware device
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
  2011-08-15  8:46 ` [PATCH 1/7] mci: embed mci_dev into mci_host instead of allocating it seperately Sascha Hauer
  2011-08-15  8:46 ` [PATCH 2/7] net: make the ethernet device a child of the hardware device Sascha Hauer
@ 2011-08-15  8:46 ` Sascha Hauer
  2011-08-15  8:46 ` [PATCH 4/7] console: make console device a child of " Sascha Hauer
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15  8:46 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/altera_tse.c   |    1 +
 drivers/net/dm9000.c       |    1 +
 drivers/net/ep93xx.c       |    1 +
 drivers/net/fec_imx.c      |    1 +
 drivers/net/fec_mpc5200.c  |    1 +
 drivers/net/macb.c         |    1 +
 drivers/net/miidev.c       |    2 ++
 drivers/net/netx_eth.c     |    1 +
 drivers/net/smc91111.c     |    1 +
 drivers/net/smc911x.c      |    1 +
 drivers/net/usb/asix.c     |    1 +
 drivers/net/usb/smsc95xx.c |    1 +
 include/miidev.h           |    1 +
 13 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index ac8dea4..7e456c7 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -549,6 +549,7 @@ static int tse_probe(struct device_d *dev)
 	miidev->write = tse_phy_write;
 	miidev->flags = 0;
 	miidev->edev = edev;
+	miidev->parent = dev;
 
 	if (dev->platform_data != NULL)
 		miidev->address = *((int8_t *)(dev->platform_data));
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 98134ce..e9ec61b 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -541,6 +541,7 @@ static int dm9000_probe(struct device_d *dev)
 	priv->miidev.address = 0;
 	priv->miidev.flags = 0;
 	priv->miidev.edev = edev;
+	priv->miidev.parent = dev;
 
 	mii_register(&priv->miidev);
 	eth_register(edev);
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
index 55848cf..954ec78 100644
--- a/drivers/net/ep93xx.c
+++ b/drivers/net/ep93xx.c
@@ -503,6 +503,7 @@ static int ep93xx_eth_probe(struct device_d *dev)
 	priv->miidev.write = ep93xx_phy_write;
 	priv->miidev.address = 0;
 	priv->miidev.flags = 0;
+	priv->miidev.parent = dev;
 
 	priv->tx_dq.base = calloc(NUMTXDESC,
 				sizeof(struct tx_descriptor));
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index bbce2b6..3b0f266 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -645,6 +645,7 @@ static int fec_probe(struct device_d *dev)
 		fec->miidev.address = pdata->phy_addr;
 		fec->miidev.flags = pdata->xcv_type == MII10 ? MIIDEV_FORCE_10 : 0;
 		fec->miidev.edev = edev;
+		fec->miidev.parent = dev;
 
 		mii_register(&fec->miidev);
 	}
diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c
index 84be3c7..403aad5 100644
--- a/drivers/net/fec_mpc5200.c
+++ b/drivers/net/fec_mpc5200.c
@@ -688,6 +688,7 @@ int mpc5xxx_fec_probe(struct device_d *dev)
 		fec->miidev.address = CONFIG_PHY_ADDR;
 		fec->miidev.flags = pdata->xcv_type == MII10 ? MIIDEV_FORCE_10 : 0;
 		fec->miidev.edev = edev;
+		fec->miidev.parent = dev;
 
 		mii_register(&fec->miidev);
 	}
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 435fa28..898cf3d 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -441,6 +441,7 @@ static int macb_probe(struct device_d *dev)
 	macb->miidev.flags = pdata->flags & AT91SAM_ETHER_FORCE_LINK ?
 		MIIDEV_FORCE_LINK : 0;
 	macb->miidev.edev = edev;
+	macb->miidev.parent = dev;
 	macb->flags = pdata->flags;
 
 	macb->rx_buffer = xmalloc(CFG_MACB_RX_BUFFER_SIZE); 
diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
index fa9d79e..501a4f8 100644
--- a/drivers/net/miidev.c
+++ b/drivers/net/miidev.c
@@ -210,6 +210,8 @@ int mii_register(struct mii_device *mdev)
 	mdev->dev.priv = mdev;
 	mdev->dev.id = -1;
 	strcpy(mdev->dev.name, "miidev");
+	if (mdev->parent)
+		dev_add_child(mdev->parent, &mdev->dev);
 
 	return register_device(&mdev->dev);
 }
diff --git a/drivers/net/netx_eth.c b/drivers/net/netx_eth.c
index fd09983..5503bc9 100644
--- a/drivers/net/netx_eth.c
+++ b/drivers/net/netx_eth.c
@@ -264,6 +264,7 @@ static int netx_eth_probe(struct device_d *dev)
 	priv->miidev.write = netx_miidev_write;
 	priv->miidev.address = 0;
 	priv->miidev.flags = 0;
+	priv->miidev.parent = dev;
 
 	netx_eth_init_phy();
 	mii_register(&priv->miidev);
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index edb0f68..2313aae 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -1318,6 +1318,7 @@ static int smc91c111_probe(struct device_d *dev)
 	priv->miidev.address = 0;
 	priv->miidev.flags = 0;
 	priv->miidev.edev = edev;
+	priv->miidev.parent = dev;
 	priv->base = dev_request_mem_region(dev, 0);
 
 	smc91c111_reset(edev);
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 45d24ad..fba61c4 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -732,6 +732,7 @@ static int smc911x_probe(struct device_d *dev)
 	priv->miidev.address = 1;
 	priv->miidev.flags = 0;
 	priv->miidev.edev = edev;
+	priv->miidev.parent = dev;
 	priv->base = base;
 
 	smc911x_reset(edev);
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index d148925..be5a170 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -474,6 +474,7 @@ static int asix_init_mii(struct usbnet *dev)
 	dev->miidev.address = asix_get_phy_addr(dev);
 	dev->miidev.flags = 0;
 	dev->miidev.edev = &dev->edev;
+	dev->miidev.parent = &dev->udev->dev;
 
 	return mii_register(&dev->miidev);
 }
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index ae137fb..b518992 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -444,6 +444,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
 	dev->miidev.address = 1; /* FIXME: asix_get_phy_addr(dev); */
 	dev->miidev.flags = 0;
 	dev->miidev.edev = &dev->edev;
+	dev->miidev.parent = &dev->udev->dev;
 //	dev->miidev.name = dev->edev.name;
 
 	/* reset phy and wait for reset to complete */
diff --git a/include/miidev.h b/include/miidev.h
index 6f653d9..21727ef 100644
--- a/include/miidev.h
+++ b/include/miidev.h
@@ -33,6 +33,7 @@
 
 struct mii_device {
 	struct device_d dev;
+	struct device_d *parent;
 
 	int address;	/* The address the phy has on the bus */
 	int	(*read) (struct mii_device *dev, int addr, int reg);
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 4/7] console: make console device a child of the hardware device
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (2 preceding siblings ...)
  2011-08-15  8:46 ` [PATCH 3/7] net mii: add a parent pointer to miidevs and set it to " Sascha Hauer
@ 2011-08-15  8:46 ` Sascha Hauer
  2011-08-15  8:46 ` [PATCH 5/7] mci: parent fixups Sascha Hauer
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15  8:46 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/console.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/common/console.c b/common/console.c
index d60e57f..1f6ee93 100644
--- a/common/console.c
+++ b/common/console.c
@@ -132,6 +132,8 @@ int console_register(struct console_device *newcdev)
 	dev->id = -1;
 	strcpy(dev->name, "cs");
 	dev->type_data = newcdev;
+	if (newcdev->dev)
+		dev_add_child(newcdev->dev, dev);
 	register_device(dev);
 
 	if (newcdev->setbrg) {
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 5/7] mci: parent fixups
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (3 preceding siblings ...)
  2011-08-15  8:46 ` [PATCH 4/7] console: make console device a child of " Sascha Hauer
@ 2011-08-15  8:46 ` Sascha Hauer
  2011-08-16 15:39   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-08-15  8:46 ` [PATCH 6/7] spi: make the spi devices children of the parent bus Sascha Hauer
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15  8:46 UTC (permalink / raw)
  To: barebox

Make the mci host a child of the hardware device and the disk
a child of the mci host.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/atmel_mci.c  |    1 +
 drivers/mci/imx-esdhc.c  |    1 +
 drivers/mci/imx.c        |    1 +
 drivers/mci/mci-core.c   |    5 ++++-
 drivers/mci/omap_hsmmc.c |    1 +
 5 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c
index b4489dd..47e3924 100644
--- a/drivers/mci/atmel_mci.c
+++ b/drivers/mci/atmel_mci.c
@@ -449,6 +449,7 @@ static int mci_probe(struct device_d *hw_dev)
 	host->mci.send_cmd = mci_request;
 	host->mci.set_ios = mci_set_ios;
 	host->mci.init = mci_reset;
+	host->mci.hw_dev = dev;
 
 	host->mci.host_caps = pd->host_caps;
 	if (pd->bus_width >= 4)
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index e20b3b7..358f0dc 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -485,6 +485,7 @@ static int fsl_esdhc_probe(struct device_d *dev)
 	host->mci.set_ios = esdhc_set_ios;
 	host->mci.init = esdhc_init;
 	host->mci.host_caps = MMC_MODE_4BIT;
+	host->mci.hw_dev = dev;
 
 	host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 
diff --git a/drivers/mci/imx.c b/drivers/mci/imx.c
index 1f96e96..905c251 100644
--- a/drivers/mci/imx.c
+++ b/drivers/mci/imx.c
@@ -492,6 +492,7 @@ static int mxcmci_probe(struct device_d *dev)
 	host->mci.set_ios = mxcmci_set_ios;
 	host->mci.init = mxcmci_init;
 	host->mci.host_caps = MMC_MODE_4BIT;
+	host->mci.hw_dev = dev;
 
 	host->base = dev_request_mem_region(dev, 0);
 
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 6a29619..681de0a 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1177,6 +1177,7 @@ static int mci_card_probe(struct device_d *mci_dev)
 	struct mci_host *host = GET_MCI_PDATA(mci_dev);
 	struct ata_interface *p;
 	int rc;
+	struct device_d *dev;
 
 	/* start with a host interface reset */
 	rc = (host->init)(host, mci_dev);
@@ -1228,7 +1229,8 @@ static int mci_card_probe(struct device_d *mci_dev)
 	p->read = mci_sd_read;
 	p->priv = mci_dev;
 
-	add_generic_device("disk", -1, NULL, 0, mci->capacity, IORESOURCE_MEM, p);
+	dev = add_generic_device("disk", -1, NULL, 0, mci->capacity, IORESOURCE_MEM, p);
+	dev_add_child(&host->dev, dev);
 
 	pr_debug("SD Card successfully added\n");
 
@@ -1363,6 +1365,7 @@ int mci_register(struct mci_host *host)
 
 	strcpy(mci_dev->name, mci_driver.name);
 	mci_dev->platform_data = (void*)host;
+	dev_add_child(host->hw_dev, mci_dev);
 
 	return register_device(mci_dev);
 }
diff --git a/drivers/mci/omap_hsmmc.c b/drivers/mci/omap_hsmmc.c
index f47f190..5fdf445 100644
--- a/drivers/mci/omap_hsmmc.c
+++ b/drivers/mci/omap_hsmmc.c
@@ -557,6 +557,7 @@ static int omap_mmc_probe(struct device_d *dev)
 	hsmmc->mci.set_ios = mmc_set_ios;
 	hsmmc->mci.init = mmc_init_setup;
 	hsmmc->mci.host_caps = MMC_MODE_4BIT | MMC_MODE_HS_52MHz | MMC_MODE_HS;
+	hsmmc->mci.hw_dev = dev;
 
 	hsmmc->base = dev_request_mem_region(dev, 0);
 
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 6/7] spi: make the spi devices children of the parent bus
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (4 preceding siblings ...)
  2011-08-15  8:46 ` [PATCH 5/7] mci: parent fixups Sascha Hauer
@ 2011-08-15  8:46 ` Sascha Hauer
  2011-08-15  8:46 ` [PATCH 7/7] devinfo: beautify output Sascha Hauer
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15  8:46 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/spi/spi.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 8058694..b561f9d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -79,6 +79,7 @@ struct spi_device *spi_new_device(struct spi_master *master,
 	proxy->dev.platform_data = chip->platform_data;
 	strcpy(proxy->dev.name, chip->name);
 	proxy->dev.type_data = proxy;
+	dev_add_child(master->dev, &proxy->dev);
 	status = register_device(&proxy->dev);
 
 	/* drivers may modify this initial i/o setup */
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 7/7] devinfo: beautify output
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (5 preceding siblings ...)
  2011-08-15  8:46 ` [PATCH 6/7] spi: make the spi devices children of the parent bus Sascha Hauer
@ 2011-08-15  8:46 ` Sascha Hauer
  2011-08-15  9:14 ` [PATCH] parent fixups Jean-Christophe PLAGNIOL-VILLARD
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15  8:46 UTC (permalink / raw)
  To: barebox

Files associated to a device showed up in a long list. Instead,
print them in seperate lines and also show offset/size information

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/base/driver.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index b8b2f39..0b80103 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -283,32 +283,33 @@ void devices_shutdown(void)
 }
 
 #ifdef CONFIG_CMD_DEVINFO
-static int do_devinfo_subtree(struct device_d *dev, int depth, char edge)
+static int do_devinfo_subtree(struct device_d *dev, int depth)
 {
 	struct device_d *child;
 	struct cdev *cdev;
 	int i;
 
 	for (i = 0; i < depth; i++)
-		printf("|    ");
+		printf("     ");
 
-	printf("%c----%s", edge, dev_name(dev));
+	printf("`---- %s", dev_name(dev));
 	if (!list_empty(&dev->cdevs)) {
-		printf(" (");
+		printf("\n");
 		list_for_each_entry(cdev, &dev->cdevs, devices_list) {
-			printf("%s", cdev->name);
-			if (!list_is_last(&cdev->devices_list, &dev->cdevs))
-				printf(", ");
+			for (i = 0; i < depth + 1; i++)
+				printf("     ");
+			printf("`---- 0x%08lx-0x%08lx: /dev/%s\n",
+					cdev->offset,
+					cdev->offset + cdev->size - 1,
+					cdev->name);
 		}
-		printf(")");
+	} else {
+		printf("\n");
 	}
-	printf("\n");
 
 	if (!list_empty(&dev->children)) {
 		device_for_each_child(dev, child) {
-			do_devinfo_subtree(child, depth + 1,
-					list_is_last(&child->sibling,
-						&dev->children) ? '`' : '|');
+			do_devinfo_subtree(child, depth + 1);
 		}
 	}
 
@@ -328,7 +329,7 @@ static int do_devinfo(struct command *cmdtp, int argc, char *argv[])
 
 		for_each_device(dev) {
 			if (!dev->parent)
-				do_devinfo_subtree(dev, 0, '|');
+				do_devinfo_subtree(dev, 0);
 		}
 
 		printf("\ndrivers:\n");
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] parent fixups
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (6 preceding siblings ...)
  2011-08-15  8:46 ` [PATCH 7/7] devinfo: beautify output Sascha Hauer
@ 2011-08-15  9:14 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-08-15 15:50   ` Sascha Hauer
  2011-08-16  5:36 ` [PATCH 1/4] device: update id support to allow device without id Jean-Christophe PLAGNIOL-VILLARD
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-08-15  9:14 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 10:46 Mon 15 Aug     , Sascha Hauer wrote:
> Hi,
> 
> We have a nice devinfo command which can print the devices as a tree.
> Let's make more use of it and make spi/network/console devices children
> of the corresponding hardware devices.
> Also, when a file under /dev/ is associated to a device, print the
> start and end with the information.
> 
> On a i.MX51 babbage board we change from:
> 
> devices:
> |----imx_serial0
> |----cs0
> |----mem0 (ram0)
> |----imx_iim0 (imx_iim_bank0, imx_iim_bank1, imx_iim_bank2, imx_iim_bank3, imx_iim_bank4, imx_iim_bank5, imx_iim_bank6, imx_iim_bank7)
> |----ramfs0
> |----devfs0
> |----mem1 (defaultenv)
> |----mem2 (mem)
> |----fec_imx0
> |----miidev0 (phy0)
> |----eth0
> |----imx-esdhc0
> |----mci0
> |----disk0
> |----imx_spi0
> |----mc13892-spi0 (mc13892)
> 
> to this:
> 
> devices:
> `---- imx_serial0
>      `---- cs0
> `---- mem0
>      `---- 0x00000000-0x1fffffff: /dev/ram0
> `---- imx_iim0
>      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank0
>      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank1
>      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank2
>      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank3
>      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank4
>      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank5
>      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank6
>      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank7
> `---- ramfs0
> `---- devfs0
> `---- mem1
>      `---- 0x00000000-0x00001e08: /dev/defaultenv
> `---- mem2
>      `---- 0x00000000-0xfffffffe: /dev/mem
> `---- fec_imx0
>      `---- miidev0
>           `---- 0x00000000-0x0000003f: /dev/phy0
>      `---- eth0
> `---- imx-esdhc0
>      `---- mci0
>           `---- disk0
> `---- imx_spi0
>      `---- mc13892-spi0
>           `---- 0x00000000-0x000000ff: /dev/mc13892
can we split tehem by bus?

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] parent fixups
  2011-08-15  9:14 ` [PATCH] parent fixups Jean-Christophe PLAGNIOL-VILLARD
@ 2011-08-15 15:50   ` Sascha Hauer
  2011-08-16  5:29     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 19+ messages in thread
From: Sascha Hauer @ 2011-08-15 15:50 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Mon, Aug 15, 2011 at 11:14:06AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:46 Mon 15 Aug     , Sascha Hauer wrote:
> > Hi,
> > 
> > We have a nice devinfo command which can print the devices as a tree.
> > Let's make more use of it and make spi/network/console devices children
> > of the corresponding hardware devices.
> > Also, when a file under /dev/ is associated to a device, print the
> > start and end with the information.
> > 
> > On a i.MX51 babbage board we change from:
> > 
> > devices:
> > |----imx_serial0
> > |----cs0
> > |----mem0 (ram0)
> > |----imx_iim0 (imx_iim_bank0, imx_iim_bank1, imx_iim_bank2, imx_iim_bank3, imx_iim_bank4, imx_iim_bank5, imx_iim_bank6, imx_iim_bank7)
> > |----ramfs0
> > |----devfs0
> > |----mem1 (defaultenv)
> > |----mem2 (mem)
> > |----fec_imx0
> > |----miidev0 (phy0)
> > |----eth0
> > |----imx-esdhc0
> > |----mci0
> > |----disk0
> > |----imx_spi0
> > |----mc13892-spi0 (mc13892)
> > 
> > to this:
> > 
> > devices:
> > `---- imx_serial0
> >      `---- cs0
> > `---- mem0
> >      `---- 0x00000000-0x1fffffff: /dev/ram0
> > `---- imx_iim0
> >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank0
> >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank1
> >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank2
> >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank3
> >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank4
> >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank5
> >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank6
> >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank7
> > `---- ramfs0
> > `---- devfs0
> > `---- mem1
> >      `---- 0x00000000-0x00001e08: /dev/defaultenv
> > `---- mem2
> >      `---- 0x00000000-0xfffffffe: /dev/mem
> > `---- fec_imx0
> >      `---- miidev0
> >           `---- 0x00000000-0x0000003f: /dev/phy0
> >      `---- eth0
> > `---- imx-esdhc0
> >      `---- mci0
> >           `---- disk0
> > `---- imx_spi0
> >      `---- mc13892-spi0
> >           `---- 0x00000000-0x000000ff: /dev/mc13892
> can we split tehem by bus?

We can add the bus information above, but I think splitting it by bus
does not look very nice. Also, at the moment barebox does not know which
busses exist since they are not explicitely registered.

Sascha

-- 
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] 19+ messages in thread

* Re: [PATCH] parent fixups
  2011-08-15 15:50   ` Sascha Hauer
@ 2011-08-16  5:29     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 19+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-08-16  5:29 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 17:50 Mon 15 Aug     , Sascha Hauer wrote:
> On Mon, Aug 15, 2011 at 11:14:06AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 10:46 Mon 15 Aug     , Sascha Hauer wrote:
> > > Hi,
> > > 
> > > We have a nice devinfo command which can print the devices as a tree.
> > > Let's make more use of it and make spi/network/console devices children
> > > of the corresponding hardware devices.
> > > Also, when a file under /dev/ is associated to a device, print the
> > > start and end with the information.
> > > 
> > > On a i.MX51 babbage board we change from:
> > > 
> > > devices:
> > > |----imx_serial0
> > > |----cs0
> > > |----mem0 (ram0)
> > > |----imx_iim0 (imx_iim_bank0, imx_iim_bank1, imx_iim_bank2, imx_iim_bank3, imx_iim_bank4, imx_iim_bank5, imx_iim_bank6, imx_iim_bank7)
> > > |----ramfs0
> > > |----devfs0
> > > |----mem1 (defaultenv)
> > > |----mem2 (mem)
> > > |----fec_imx0
> > > |----miidev0 (phy0)
> > > |----eth0
> > > |----imx-esdhc0
> > > |----mci0
> > > |----disk0
> > > |----imx_spi0
> > > |----mc13892-spi0 (mc13892)
> > > 
> > > to this:
> > > 
> > > devices:
> > > `---- imx_serial0
> > >      `---- cs0
> > > `---- mem0
> > >      `---- 0x00000000-0x1fffffff: /dev/ram0
> > > `---- imx_iim0
> > >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank0
> > >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank1
> > >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank2
> > >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank3
> > >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank4
> > >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank5
> > >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank6
> > >      `---- 0x00000000-0x0000001f: /dev/imx_iim_bank7
> > > `---- ramfs0
> > > `---- devfs0
> > > `---- mem1
> > >      `---- 0x00000000-0x00001e08: /dev/defaultenv
> > > `---- mem2
> > >      `---- 0x00000000-0xfffffffe: /dev/mem
> > > `---- fec_imx0
> > >      `---- miidev0
> > >           `---- 0x00000000-0x0000003f: /dev/phy0
> > >      `---- eth0
> > > `---- imx-esdhc0
> > >      `---- mci0
> > >           `---- disk0
> > > `---- imx_spi0
> > >      `---- mc13892-spi0
> > >           `---- 0x00000000-0x000000ff: /dev/mc13892
> > can we split tehem by bus?
> 
> We can add the bus information above, but I think splitting it by bus
> does not look very nice. Also, at the moment barebox does not know which
> busses exist since they are not explicitely registered.
I push some patch that I did yesterday night
to add full bus support to barebox

It will help to add pci and mii device/driverr support to have really phy
device need by at91rm9200ek as example

the output is nice

PCI: register_pci_controller() 


barebox 2011.08.0-00217-gb2fe734-dirty (Aug 16 2011 - 03:05:33)

Board: qemu malta
rtl8139_probe()
found rtl8139 (rev 20) at 90: 0200 (base=b1000000)
rtl8139_init_dev()
rtl8139_chip_reset()
eth@eth0: got MAC address from EEPROM: 52:54:00:12:34:56
registered netconsole as cs1
Malloc space: 0xa0400000 -> 0xa0800000 (size  4 MB)
Open /dev/env0 No such file or directory
running /env/bin/init...
not found
barebox:/ devinfo 
devices:
`---- platform
     `---- serial_ns165500
          `---- cs0
     `---- ramfs0
     `---- devfs0
     `---- mem0
          `---- 0x00000000-0xfffffffe: /dev/mem
     `---- cs1
`---- pci_bus0
     `---- pci0
     `---- pci1
     `---- pci2
     `---- pci3
     `---- pci4
     `---- pci5
          `---- miidev0
               `---- 0x00000000-0x0000003f: /dev/phy0
          `---- eth0

drivers:
serial_ns16550
     ramfs
     devfs
       fat
    miidev
 cfi_flash
rtl8139_eth
       mem
    cramfs
barebox:/

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/4] device: update id support to allow device without id
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (7 preceding siblings ...)
  2011-08-15  9:14 ` [PATCH] parent fixups Jean-Christophe PLAGNIOL-VILLARD
@ 2011-08-16  5:36 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-08-18  5:26   ` Sascha Hauer
  2011-08-16  5:36 ` [PATCH 2/4] add bus registration support Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-08-16  5:36 UTC (permalink / raw)
  To: barebox

as in linux use -1 for this

as example on bus we may have only one device so no need to have
devname<number>

for automatic id use -2 now
udpate all the device that use -1 to -2

device that really want -1 will have to update later

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/a9m2410/a9m2410.c                 |    6 +++---
 arch/arm/boards/a9m2440/a9m2440.c                 |    6 +++---
 arch/arm/boards/chumby_falconwing/falconwing.c    |    2 +-
 arch/arm/boards/edb93xx/edb93xx.c                 |    6 +++---
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c |    4 ++--
 arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c |    8 ++++----
 arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c |    4 ++--
 arch/arm/boards/freescale-mx25-3-stack/3stack.c   |    2 +-
 arch/arm/boards/freescale-mx35-3-stack/3stack.c   |    4 ++--
 arch/arm/boards/guf-neso/board.c                  |    2 +-
 arch/arm/boards/imx21ads/imx21ads.c               |    4 ++--
 arch/arm/boards/imx27ads/imx27ads.c               |    2 +-
 arch/arm/boards/mini2440/mini2440.c               |    4 ++--
 arch/arm/boards/netx/netx.c                       |    8 ++++----
 arch/arm/boards/nhk8815/setup.c                   |    4 ++--
 arch/arm/boards/omap/board-beagle.c               |    8 ++++----
 arch/arm/boards/omap/board-omap3evm.c             |    2 +-
 arch/arm/boards/omap/board-sdp343x.c              |    2 +-
 arch/arm/boards/panda/board.c                     |    6 +++---
 arch/arm/boards/pcm037/pcm037.c                   |    8 ++++----
 arch/arm/boards/pcm038/pcm038.c                   |    4 ++--
 arch/arm/boards/pcm043/pcm043.c                   |    2 +-
 arch/arm/boards/pcm049/board.c                    |    6 +++---
 arch/arm/boards/phycard-i.MX27/pca100.c           |    4 ++--
 arch/arm/boards/scb9328/scb9328.c                 |    4 ++--
 arch/arm/boards/versatile/versatilepb.c           |    4 ++--
 arch/arm/mach-at91/at91sam9263_devices.c          |    2 +-
 arch/arm/mach-at91/at91sam9g45_devices.c          |    2 +-
 arch/arm/mach-imx/devices.c                       |    8 ++++----
 arch/arm/mach-omap/devices-gpmc-nand.c            |    2 +-
 arch/blackfin/boards/ipe337/ipe337.c              |    6 +++---
 arch/mips/boards/dlink-dir-320/serial.c           |    2 +-
 arch/mips/boards/qemu-malta/serial.c              |    2 +-
 arch/nios2/boards/generic/generic.c               |    6 +++---
 arch/ppc/boards/pcm030/pcm030.c                   |    8 ++++----
 arch/sandbox/board/hostfile.c                     |    2 +-
 arch/x86/boards/x86_generic/generic_pc.c          |    4 ++--
 common/console.c                                  |    2 +-
 drivers/base/driver.c                             |    5 ++++-
 drivers/mci/mci-core.c                            |    2 +-
 drivers/net/miidev.c                              |    2 +-
 include/driver.h                                  |    2 +-
 net/eth.c                                         |    2 +-
 43 files changed, 89 insertions(+), 86 deletions(-)

diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c
index 44ac44b..0d26da9 100644
--- a/arch/arm/boards/a9m2410/a9m2410.c
+++ b/arch/arm/boards/a9m2410/a9m2410.c
@@ -131,14 +131,14 @@ static int a9m2410_devices_init(void)
 	writel(reg, MISCCR);
 
 	/* ----------- the devices the boot loader should work with -------- */
-	add_generic_device("s3c24x0_nand", -1, NULL, S3C24X0_NAND_BASE, 0,
+	add_generic_device("s3c24x0_nand", -2, NULL, S3C24X0_NAND_BASE, 0,
 			   IORESOURCE_MEM, &nand_info);
 	/*
 	 * SMSC 91C111 network controller on the baseboard
 	 * connected to CS line 1 and interrupt line
 	 * GPIO3, data width is 32 bit
 	 */
-	add_generic_device("smc91c111", -1, NULL, CS1_BASE + 0x300, 16,
+	add_generic_device("smc91c111", -2, NULL, CS1_BASE + 0x300, 16,
 			   IORESOURCE_MEM, NULL);
 
 #ifdef CONFIG_NAND
@@ -167,7 +167,7 @@ void __bare_init nand_boot(void)
 
 static int a9m2410_console_init(void)
 {
-	add_generic_device("s3c24x0_serial", -1, NULL, UART1_BASE, UART1_SIZE,
+	add_generic_device("s3c24x0_serial", -2, NULL, UART1_BASE, UART1_SIZE,
 			   IORESOURCE_MEM, NULL);
 	return 0;
 }
diff --git a/arch/arm/boards/a9m2440/a9m2440.c b/arch/arm/boards/a9m2440/a9m2440.c
index 89c9cdf..fece4ac 100644
--- a/arch/arm/boards/a9m2440/a9m2440.c
+++ b/arch/arm/boards/a9m2440/a9m2440.c
@@ -133,14 +133,14 @@ static int a9m2440_devices_init(void)
 	writel(reg, MISCCR);
 
 	/* ----------- the devices the boot loader should work with -------- */
-	add_generic_device("s3c24x0_nand", -1, NULL, S3C24X0_NAND_BASE, 0,
+	add_generic_device("s3c24x0_nand", -2, NULL, S3C24X0_NAND_BASE, 0,
 			   IORESOURCE_MEM, &nand_info);
 	/*
 	 * cs8900 network controller onboard
 	 * Connected to CS line 5 + A24 and interrupt line EINT9,
 	 * data width is 16 bit
 	 */
-	add_generic_device("cs8900", -1, NULL, CS5_BASE + (1 << 24) + 0x300, 16,
+	add_generic_device("cs8900", -2, NULL, CS5_BASE + (1 << 24) + 0x300, 16,
 			   IORESOURCE_MEM, NULL);
 
 #ifdef CONFIG_NAND
@@ -168,7 +168,7 @@ void __bare_init nand_boot(void)
 
 static int a9m2440_console_init(void)
 {
-	add_generic_device("s3c24x0_serial", -1, NULL, UART1_BASE, UART1_SIZE,
+	add_generic_device("s3c24x0_serial", -2, NULL, UART1_BASE, UART1_SIZE,
 			   IORESOURCE_MEM, NULL);
 	return 0;
 }
diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c
index 1c66eb2..db9974b 100644
--- a/arch/arm/boards/chumby_falconwing/falconwing.c
+++ b/arch/arm/boards/chumby_falconwing/falconwing.c
@@ -318,7 +318,7 @@ static void falconwing_init_usb(void)
 
 	imx_usb_phy_enable();
 
-	add_generic_usb_ehci_device(-1, IMX_USB_BASE, NULL);
+	add_generic_usb_ehci_device(-2, IMX_USB_BASE, NULL);
 }
 
 static int falconwing_devices_init(void)
diff --git a/arch/arm/boards/edb93xx/edb93xx.c b/arch/arm/boards/edb93xx/edb93xx.c
index 3e4e0b0..1ec93f7 100644
--- a/arch/arm/boards/edb93xx/edb93xx.c
+++ b/arch/arm/boards/edb93xx/edb93xx.c
@@ -57,7 +57,7 @@ mem_initcall(ep93xx_mem_init);
 
 static int ep93xx_devices_init(void)
 {
-	add_cfi_flash_device(-1, 0x60000000, EDB93XX_CFI_FLASH_SIZE, 0);
+	add_cfi_flash_device(-2, 0x60000000, EDB93XX_CFI_FLASH_SIZE, 0);
 
 	/*
 	 * Create partitions that should be
@@ -72,7 +72,7 @@ static int ep93xx_devices_init(void)
 	 * Up to 32MiB NOR type flash, connected to
 	 * CS line 6, data width is 16 bit
 	 */
-	add_generic_device("ep93xx_eth", -1, NULL, 0, 0, IORESOURCE_MEM, NULL);
+	add_generic_device("ep93xx_eth", -2, NULL, 0, 0, IORESOURCE_MEM, NULL);
 
 	armlinux_set_bootparams((void *)CONFIG_EP93XX_SDRAM_BANK0_BASE + 0x100);
 
@@ -101,7 +101,7 @@ static int edb93xx_console_init(void)
 	writel(0xAA, &syscon->sysswlock);
 	writel(value, &syscon->devicecfg);
 
-	add_generic_device("pl010_serial", -1, NULL, UART1_BASE, 4096,
+	add_generic_device("pl010_serial", -2, NULL, UART1_BASE, 4096,
 			   IORESOURCE_MEM, NULL);
 
 	return 0;
diff --git a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
index 1c54202..c589ec6 100644
--- a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
+++ b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
@@ -253,9 +253,9 @@ static int eukrea_cpuimx25_devices_init(void)
 
 #ifdef CONFIG_USB
 	imx25_usb_init();
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE + 0x400, NULL);
 #endif
-	add_generic_device("fsl-udc", -1, NULL, IMX_OTG_BASE, 0x200,
+	add_generic_device("fsl-udc", -2, NULL, IMX_OTG_BASE, 0x200,
 			   IORESOURCE_MEM, &usb_pdata);
 
 	armlinux_set_bootparams((void *)0x80000100);
diff --git a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
index a5aadac..5ee8b54 100644
--- a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -191,9 +191,9 @@ static int eukrea_cpuimx27_devices_init(void)
 	for (i = 0; i < ARRAY_SIZE(mode); i++)
 		imx_gpio_mode(mode[i]);
 
-	add_cfi_flash_device(-1, 0xC0000000, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, 0xC0000000, 32 * 1024 * 1024, 0);
 #ifdef CONFIG_EUKREA_CPUIMX27_NOR_64MB
-	add_cfi_flash_device(-1, 0xC2000000, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, 0xC2000000, 32 * 1024 * 1024, 0);
 #endif
 	imx27_add_nand(&nand_info);
 
@@ -227,7 +227,7 @@ device_initcall(eukrea_cpuimx27_devices_init);
 static int eukrea_cpuimx27_console_init(void)
 {
 #ifdef CONFIG_DRIVER_SERIAL_IMX
-	imx_add_uart((void *)IMX_UART1_BASE, -1);
+	imx_add_uart((void *)IMX_UART1_BASE, -2);
 #endif
 	/* configure 8 bit UART on cs3 */
 	FMCR &= ~0x2;
@@ -235,7 +235,7 @@ static int eukrea_cpuimx27_console_init(void)
 	CS3L = 0x0D1D0D01;
 	CS3A = 0x00D20000;
 #ifdef CONFIG_DRIVER_SERIAL_NS16550
-	add_ns16550_device(-1, IMX_CS3_BASE + QUART_OFFSET, 0xf,
+	add_ns16550_device(-2, IMX_CS3_BASE + QUART_OFFSET, 0xf,
 			 IORESOURCE_MEM_16BIT, &quad_uart_serial_plat);
 #endif
 	return 0;
diff --git a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
index 426445f..f047688 100644
--- a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
+++ b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
@@ -159,13 +159,13 @@ static int eukrea_cpuimx35_devices_init(void)
 
 #ifdef CONFIG_USB
 	imx35_usb_init();
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE + 0x400, NULL);
 #endif
 #ifdef CONFIG_USB_GADGET
 	/* Workaround ENGcm09152 */
 	tmp = readl(IMX_OTG_BASE + 0x608);
 	writel(tmp | (1 << 23), IMX_OTG_BASE + 0x608);
-	add_generic_device("fsl-udc", -1, NULL, IMX_OTG_BASE, 0x200,
+	add_generic_device("fsl-udc", -2, NULL, IMX_OTG_BASE, 0x200,
 			   IORESOURCE_MEM, &usb_pdata);
 #endif
 	armlinux_set_bootparams((void *)0x80000100);
diff --git a/arch/arm/boards/freescale-mx25-3-stack/3stack.c b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
index 979115d..957e35a 100644
--- a/arch/arm/boards/freescale-mx25-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
@@ -215,7 +215,7 @@ static int imx25_devices_init(void)
 	 * the CPLD has to be initialized.
 	 */
 	imx25_usb_init();
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE + 0x400, NULL);
 #endif
 
 	imx25_iim_register_fec_ethaddr();
diff --git a/arch/arm/boards/freescale-mx35-3-stack/3stack.c b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
index ab70265..6df644e 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
@@ -156,7 +156,7 @@ static int f3s_devices_init(void)
 	 * This platform supports NOR and NAND
 	 */
 	imx35_add_nand(&nand_info);
-	add_cfi_flash_device(-1, IMX_CS0_BASE, 64 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, IMX_CS0_BASE, 64 * 1024 * 1024, 0);
 
 	switch ((reg >> 25) & 0x3) {
 	case 0x01:		/* NAND is the source */
@@ -179,7 +179,7 @@ static int f3s_devices_init(void)
 	imx35_add_i2c0(NULL);
 
 	imx35_add_fec(&fec_info);
-	add_generic_device("smc911x", -1, NULL,	IMX_CS5_BASE, IMX_CS5_RANGE,
+	add_generic_device("smc911x", -2, NULL,	IMX_CS5_BASE, IMX_CS5_RANGE,
 			IORESOURCE_MEM, NULL);
 
 	imx35_add_mmc0(NULL);
diff --git a/arch/arm/boards/guf-neso/board.c b/arch/arm/boards/guf-neso/board.c
index 446b333..743d6b3 100644
--- a/arch/arm/boards/guf-neso/board.c
+++ b/arch/arm/boards/guf-neso/board.c
@@ -279,7 +279,7 @@ static int neso_devices_init(void)
 
 #ifdef CONFIG_USB
 	neso_usbh_init();
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE + 0x400, NULL);
 #endif
 
 	imx27_add_fec(&fec_info);
diff --git a/arch/arm/boards/imx21ads/imx21ads.c b/arch/arm/boards/imx21ads/imx21ads.c
index d58831e..e41a1cb 100644
--- a/arch/arm/boards/imx21ads/imx21ads.c
+++ b/arch/arm/boards/imx21ads/imx21ads.c
@@ -164,9 +164,9 @@ static int mx21ads_devices_init(void)
 	for (i = 0; i < ARRAY_SIZE(mode); i++)
 		imx_gpio_mode(mode[i]);
 
-	add_cfi_flash_device(-1, 0xC8000000, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, 0xC8000000, 32 * 1024 * 1024, 0);
 	imx21_add_nand(&nand_info);
-	add_generic_device("cs8900", -1, NULL,	IMX_CS1_BASE, 0x1000,
+	add_generic_device("cs8900", -2, NULL,	IMX_CS1_BASE, 0x1000,
 			IORESOURCE_MEM, NULL);
 	imx21_add_fb(&imx_fb_data);
 
diff --git a/arch/arm/boards/imx27ads/imx27ads.c b/arch/arm/boards/imx27ads/imx27ads.c
index da4260f..ccd4b02 100644
--- a/arch/arm/boards/imx27ads/imx27ads.c
+++ b/arch/arm/boards/imx27ads/imx27ads.c
@@ -114,7 +114,7 @@ static int mx27ads_devices_init(void)
 	for (i = 0; i < ARRAY_SIZE(mode); i++)
 		imx_gpio_mode(mode[i]);
 
-	add_cfi_flash_device(-1, 0xC0000000, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, 0xC0000000, 32 * 1024 * 1024, 0);
 
 	imx27_add_fec(&fec_info);
 	devfs_add_partition("nor0", 0x00000, 0x20000, PARTITION_FIXED, "self0");
diff --git a/arch/arm/boards/mini2440/mini2440.c b/arch/arm/boards/mini2440/mini2440.c
index fd1f2f2..c69827c 100644
--- a/arch/arm/boards/mini2440/mini2440.c
+++ b/arch/arm/boards/mini2440/mini2440.c
@@ -294,7 +294,7 @@ static int mini2440_devices_init(void)
 	reg |= 0x10000;
 	writel(reg, MISCCR);
 
-	add_generic_device("s3c24x0_nand", -1, NULL, S3C24X0_NAND_BASE, 0,
+	add_generic_device("s3c24x0_nand", -2, NULL, S3C24X0_NAND_BASE, 0,
 			   IORESOURCE_MEM, &nand_info);
 
 	add_dm9000_device(0, CS4_BASE + 0x300, CS4_BASE + 0x304,
@@ -339,7 +339,7 @@ static int mini2440_console_init(void)
 	s3c_gpio_mode(GPH2_TXD0);
 	s3c_gpio_mode(GPH3_RXD0);
 
-	add_generic_device("s3c24x0_serial", -1, NULL, UART1_BASE, UART1_SIZE,
+	add_generic_device("s3c24x0_serial", -2, NULL, UART1_BASE, UART1_SIZE,
 			   IORESOURCE_MEM, NULL);
 	return 0;
 }
diff --git a/arch/arm/boards/netx/netx.c b/arch/arm/boards/netx/netx.c
index 92d2911..cd8abd2 100644
--- a/arch/arm/boards/netx/netx.c
+++ b/arch/arm/boards/netx/netx.c
@@ -47,10 +47,10 @@ static int netx_mem_init(void)
 mem_initcall(netx_mem_init);
 
 static int netx_devices_init(void) {
-	add_cfi_flash_device(-1, 0xC0000000, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, 0xC0000000, 32 * 1024 * 1024, 0);
 
-	add_generic_device("netx-eth", -1, NULL, 0, 0, IORESOURCE_MEM, &eth0_data);
-	add_generic_device("netx-eth", -1, NULL, 0, 0, IORESOURCE_MEM, &eth1_data);
+	add_generic_device("netx-eth", -2, NULL, 0, 0, IORESOURCE_MEM, &eth0_data);
+	add_generic_device("netx-eth", -2, NULL, 0, 0, IORESOURCE_MEM, &eth1_data);
 
 	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
 
@@ -75,7 +75,7 @@ static int netx_console_init(void)
 	*(volatile unsigned long *)(0x00100808) = 2;
 	*(volatile unsigned long *)(0x0010080c) = 2;
 
-	add_generic_device("netx_serial", -1, NULL, NETX_PA_UART0, 0x40,
+	add_generic_device("netx_serial", -2, NULL, NETX_PA_UART0, 0x40,
 			   IORESOURCE_MEM, NULL);
 	return 0;
 }
diff --git a/arch/arm/boards/nhk8815/setup.c b/arch/arm/boards/nhk8815/setup.c
index dcf7166..15c16a0 100644
--- a/arch/arm/boards/nhk8815/setup.c
+++ b/arch/arm/boards/nhk8815/setup.c
@@ -69,7 +69,7 @@ static struct resource nhk8815_nand_resources[] = {
 };
 
 static struct device_d nhk8815_nand_device = {
-	.id		= -1,
+	.id		= -2,
 	.name		= "nomadik_nand",
 	.num_resources	= ARRAY_SIZE(nhk8815_nand_resources),
 	.resource	= nhk8815_nand_resources,
@@ -95,7 +95,7 @@ static int nhk8815_devices_init(void)
 	writel(0x0000305b, FSMC_BCR(1));
 	writel(0x00033f33, FSMC_BTR(1));
 
-	add_generic_device("smc91c111", -1, NULL, 0x34000300, 16,
+	add_generic_device("smc91c111", -2, NULL, 0x34000300, 16,
 			   IORESOURCE_MEM, NULL);
 
 	register_device(&nhk8815_nand_device);
diff --git a/arch/arm/boards/omap/board-beagle.c b/arch/arm/boards/omap/board-beagle.c
index 49af40c..c9a7d2e 100644
--- a/arch/arm/boards/omap/board-beagle.c
+++ b/arch/arm/boards/omap/board-beagle.c
@@ -248,7 +248,7 @@ static struct NS16550_plat serial_plat = {
 static int beagle_console_init(void)
 {
 	/* Register the serial port */
-	add_ns16550_device(-1, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
+	add_ns16550_device(-2, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
 			   &serial_plat);
 
 	return 0;
@@ -289,12 +289,12 @@ mem_initcall(beagle_mem_init);
 static int beagle_devices_init(void)
 {
 	i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
-	add_generic_device("i2c-omap", -1, NULL, 0x4809C000, SZ_4K,
+	add_generic_device("i2c-omap", -2, NULL, 0x4809C000, SZ_4K,
 			   IORESOURCE_MEM, NULL);
 
 #ifdef CONFIG_USB_EHCI_OMAP
 	if (ehci_omap_init(&omap_ehci_pdata) >= 0)
-		add_usb_ehci_device(-1, 0x48064700 + 0x100,
+		add_usb_ehci_device(-2, 0x48064700 + 0x100,
 				    0x48064700 + 0x110, &ehci_pdata);
 #endif /* CONFIG_USB_EHCI_OMAP */
 #ifdef CONFIG_GPMC
@@ -303,7 +303,7 @@ static int beagle_devices_init(void)
 #endif
 	gpmc_generic_nand_devices_init(0, 16, OMAP_ECC_HAMMING_CODE_HW_ROMCODE);
 
-	add_generic_device("omap-hsmmc", -1, NULL, OMAP_I2C1_BASE, 0,
+	add_generic_device("omap-hsmmc", -2, NULL, OMAP_I2C1_BASE, 0,
 			   IORESOURCE_MEM, NULL);
 
 	armlinux_set_bootparams((void *)0x80000100);
diff --git a/arch/arm/boards/omap/board-omap3evm.c b/arch/arm/boards/omap/board-omap3evm.c
index a2532d5..e894ad4 100644
--- a/arch/arm/boards/omap/board-omap3evm.c
+++ b/arch/arm/boards/omap/board-omap3evm.c
@@ -222,7 +222,7 @@ static struct NS16550_plat serial_plat = {
  */
 static int omap3evm_init_console(void)
 {
-	add_ns16550_device(-1,
+	add_ns16550_device(-2,
 #if defined(CONFIG_OMAP3EVM_UART1)
 			OMAP_UART1_BASE,
 #elif defined(CONFIG_OMAP3EVM_UART3)
diff --git a/arch/arm/boards/omap/board-sdp343x.c b/arch/arm/boards/omap/board-sdp343x.c
index 82fc16d..9d94f09 100644
--- a/arch/arm/boards/omap/board-sdp343x.c
+++ b/arch/arm/boards/omap/board-sdp343x.c
@@ -615,7 +615,7 @@ static struct NS16550_plat serial_plat = {
 static int sdp3430_console_init(void)
 {
 	/* Register the serial port */
-	add_ns16550_device(-1, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
+	add_ns16550_device(-2, OMAP_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
 			   &serial_plat);
 
 	return 0;
diff --git a/arch/arm/boards/panda/board.c b/arch/arm/boards/panda/board.c
index 1303c47..616fa7d 100644
--- a/arch/arm/boards/panda/board.c
+++ b/arch/arm/boards/panda/board.c
@@ -37,7 +37,7 @@ static struct NS16550_plat serial_plat = {
 static int panda_console_init(void)
 {
 	/* Register the serial port */
-	add_ns16550_device(-1, OMAP44XX_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
+	add_ns16550_device(-2, OMAP44XX_UART3_BASE, 1024, IORESOURCE_MEM_8BIT,
 			   &serial_plat);
 
 	return 0;
@@ -87,7 +87,7 @@ static void panda_ehci_init(void)
 	/* enable power to hub */
 	gpio_set_value(GPIO_HUB_POWER, 1);
 
-	add_usb_ehci_device(-1, 0x4a064c00,
+	add_usb_ehci_device(-2, 0x4a064c00,
 			    0x4a064c00 + 0x10, &ehci_pdata);
 }
 #else
@@ -132,7 +132,7 @@ static int panda_devices_init(void)
 		sr32(OMAP44XX_SCRM_ALTCLKSRC, 2, 2, 0x3);
 	}
 
-	add_generic_device("omap-hsmmc", -1, NULL, 0x4809C100, SZ_4K,
+	add_generic_device("omap-hsmmc", -2, NULL, 0x4809C100, SZ_4K,
 			   IORESOURCE_MEM, NULL);
 	panda_ehci_init();
 
diff --git a/arch/arm/boards/pcm037/pcm037.c b/arch/arm/boards/pcm037/pcm037.c
index 85f004f..6d6ed3c 100644
--- a/arch/arm/boards/pcm037/pcm037.c
+++ b/arch/arm/boards/pcm037/pcm037.c
@@ -187,7 +187,7 @@ static int imx31_devices_init(void)
 	 * Up to 32MiB NOR type flash, connected to
 	 * CS line 0, data width is 16 bit
 	 */
-	add_cfi_flash_device(-1, IMX_CS0_BASE, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, IMX_CS0_BASE, 32 * 1024 * 1024, 0);
 
 	/*
 	 * Create partitions that should be
@@ -211,13 +211,13 @@ static int imx31_devices_init(void)
 	 * connected to CS line 1 and interrupt line
 	 * GPIO3, data width is 16 bit
 	 */
-	add_generic_device("smc911x", -1, NULL,	IMX_CS1_BASE, IMX_CS1_RANGE,
+	add_generic_device("smc911x", -2, NULL,	IMX_CS1_BASE, IMX_CS1_RANGE,
 			IORESOURCE_MEM, NULL);
 
 #ifdef CONFIG_USB
 	pcm037_usb_init();
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE, NULL);
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE + 0x400, NULL);
 #endif
 
 	armlinux_set_bootparams((void *)0x80000100);
diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c
index 4db50fe..bc879ab 100644
--- a/arch/arm/boards/pcm038/pcm038.c
+++ b/arch/arm/boards/pcm038/pcm038.c
@@ -243,13 +243,13 @@ static int pcm038_devices_init(void)
 	spi_register_board_info(pcm038_spi_board_info, ARRAY_SIZE(pcm038_spi_board_info));
 	imx27_add_spi0(&pcm038_spi_0_data);
 
-	add_cfi_flash_device(-1, 0xC0000000, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, 0xC0000000, 32 * 1024 * 1024, 0);
 	imx27_add_nand(&nand_info);
 	imx27_add_fb(&pcm038_fb_data);
 
 #ifdef CONFIG_USB
 	pcm038_usbh_init();
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE + 0x400, NULL);
 #endif
 
 	/* Register the fec device after the PLL re-initialisation
diff --git a/arch/arm/boards/pcm043/pcm043.c b/arch/arm/boards/pcm043/pcm043.c
index 966899a..3bf6c3a 100644
--- a/arch/arm/boards/pcm043/pcm043.c
+++ b/arch/arm/boards/pcm043/pcm043.c
@@ -146,7 +146,7 @@ static int imx35_devices_init(void)
 	 * Up to 32MiB NOR type flash, connected to
 	 * CS line 0, data width is 16 bit
 	 */
-	add_cfi_flash_device(-1, IMX_CS0_BASE, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, IMX_CS0_BASE, 32 * 1024 * 1024, 0);
 
 	if ((reg & 0xc00) == 0x800) {   /* reset mode: external boot */
 		switch ( (reg >> 25) & 0x3) {
diff --git a/arch/arm/boards/pcm049/board.c b/arch/arm/boards/pcm049/board.c
index 502e121..5ef0d3c 100644
--- a/arch/arm/boards/pcm049/board.c
+++ b/arch/arm/boards/pcm049/board.c
@@ -48,7 +48,7 @@ static struct NS16550_plat serial_plat = {
 static int pcm049_console_init(void)
 {
 	/* Register the serial port */
-	add_ns16550_device(-1, OMAP44XX_UART3_BASE, 1024, IORESOURCE_MEM_8BIT, &serial_plat);
+	add_ns16550_device(-2, OMAP44XX_UART3_BASE, 1024, IORESOURCE_MEM_8BIT, &serial_plat);
 
 	return 0;
 }
@@ -81,13 +81,13 @@ static void pcm049_network_init(void)
 {
 	gpmc_cs_config(5, &net_cfg);
 
-	add_generic_device("smc911x", -1, NULL, 0x2C000000, 0x4000,
+	add_generic_device("smc911x", -2, NULL, 0x2C000000, 0x4000,
 			   IORESOURCE_MEM, NULL);
 }
 
 static int pcm049_devices_init(void)
 {
-	add_generic_device("omap-hsmmc", -1, NULL, 0x4809C100, SZ_4K,
+	add_generic_device("omap-hsmmc", -2, NULL, 0x4809C100, SZ_4K,
 			   IORESOURCE_MEM, NULL);
 
 	gpmc_generic_init(0x10);
diff --git a/arch/arm/boards/phycard-i.MX27/pca100.c b/arch/arm/boards/phycard-i.MX27/pca100.c
index f285466..09d7bf8 100644
--- a/arch/arm/boards/phycard-i.MX27/pca100.c
+++ b/arch/arm/boards/phycard-i.MX27/pca100.c
@@ -63,9 +63,9 @@ static void pca100_usb_register(void)
 	mdelay(10);
 
 	isp1504_set_vbus_power((void *)(IMX_OTG_BASE + 0x170), 1);
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE, NULL);
 	isp1504_set_vbus_power((void *)(IMX_OTG_BASE + 0x570), 1);
-	add_generic_usb_ehci_device(-1, IMX_OTG_BASE + 0x400, NULL);
+	add_generic_usb_ehci_device(-2, IMX_OTG_BASE + 0x400, NULL);
 }
 #endif
 
diff --git a/arch/arm/boards/scb9328/scb9328.c b/arch/arm/boards/scb9328/scb9328.c
index e90417f..5653e48 100644
--- a/arch/arm/boards/scb9328/scb9328.c
+++ b/arch/arm/boards/scb9328/scb9328.c
@@ -88,8 +88,8 @@ static int scb9328_devices_init(void)
 	CS5U = 0x00008400;
 	CS5L = 0x00000D03;
 
-	add_cfi_flash_device(-1, 0x10000000, 16 * 1024 * 1024, 0);
-	add_dm9000_device(-1, 0x16000000, 0x16000004,
+	add_cfi_flash_device(-2, 0x10000000, 16 * 1024 * 1024, 0);
+	add_dm9000_device(-2, 0x16000000, 0x16000004,
 			  IORESOURCE_MEM_16BIT, &dm9000_data);
 
 	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
diff --git a/arch/arm/boards/versatile/versatilepb.c b/arch/arm/boards/versatile/versatilepb.c
index 4e09de3..2f42fa9 100644
--- a/arch/arm/boards/versatile/versatilepb.c
+++ b/arch/arm/boards/versatile/versatilepb.c
@@ -50,11 +50,11 @@ mem_initcall(vpb_mem_init);
 
 static int vpb_devices_init(void)
 {
-	add_cfi_flash_device(-1, VERSATILE_FLASH_BASE, VERSATILE_FLASH_SIZE, 0);
+	add_cfi_flash_device(-2, VERSATILE_FLASH_BASE, VERSATILE_FLASH_SIZE, 0);
 	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self");
 	devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
 
-	add_generic_device("smc91c111", -1, NULL, VERSATILE_ETH_BASE, 64 * 1024,
+	add_generic_device("smc91c111", -2, NULL, VERSATILE_ETH_BASE, 64 * 1024,
 			   IORESOURCE_MEM, NULL);
 
 	armlinux_set_architecture(MACH_TYPE_VERSATILE_PB);
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index c7ae45a..f881151 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -84,7 +84,7 @@ void at91_add_device_nand(struct atmel_nand_data *data)
 	if (data->det_pin)
 		at91_set_gpio_input(data->det_pin, 1);
 
-	add_generic_device("atmel_nand", -1, NULL, AT91_CHIPSELECT_3, 0x10,
+	add_generic_device("atmel_nand", -2, NULL, AT91_CHIPSELECT_3, 0x10,
 			   IORESOURCE_MEM, data);
 }
 #else
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index f6e1eb4..5084ba2 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -88,7 +88,7 @@ void at91_add_device_nand(struct atmel_nand_data *data)
 	if (data->det_pin)
 		at91_set_gpio_input(data->det_pin, 1);
 
-	add_generic_device("atmel_nand", -1, NULL, AT91_CHIPSELECT_3, 0x10,
+	add_generic_device("atmel_nand", -2, NULL, AT91_CHIPSELECT_3, 0x10,
 			   IORESOURCE_MEM, data);
 }
 #else
diff --git a/arch/arm/mach-imx/devices.c b/arch/arm/mach-imx/devices.c
index 5b062f5..cccb0c1 100644
--- a/arch/arm/mach-imx/devices.c
+++ b/arch/arm/mach-imx/devices.c
@@ -10,7 +10,7 @@ static inline struct device_d *imx_add_device(char *name, int id, void *base, in
 
 struct device_d *imx_add_fec(void *base, struct fec_platform_data *pdata)
 {
-	return imx_add_device("fec_imx", -1, base, 0x1000, pdata);
+	return imx_add_device("fec_imx", -2, base, 0x1000, pdata);
 }
 
 struct device_d *imx_add_spi(void *base, int id, struct spi_imx_master *pdata)
@@ -30,17 +30,17 @@ struct device_d *imx_add_uart(void *base, int id)
 
 struct device_d *imx_add_nand(void *base, struct imx_nand_platform_data *pdata)
 {
-	return imx_add_device("imx_nand", -1, base, 0x1000, pdata);
+	return imx_add_device("imx_nand", -2, base, 0x1000, pdata);
 }
 
 struct device_d *imx_add_fb(void *base, struct imx_fb_platform_data *pdata)
 {
-	return imx_add_device("imxfb", -1, base, 0x1000, pdata);
+	return imx_add_device("imxfb", -2, base, 0x1000, pdata);
 }
 
 struct device_d *imx_add_ipufb(void *base, struct imx_ipu_fb_platform_data *pdata)
 {
-	return imx_add_device("imx-ipu-fb", -1, base, 0x1000, pdata);
+	return imx_add_device("imx-ipu-fb", -2, base, 0x1000, pdata);
 }
 
 struct device_d *imx_add_mmc(void *base, int id, void *pdata)
diff --git a/arch/arm/mach-omap/devices-gpmc-nand.c b/arch/arm/mach-omap/devices-gpmc-nand.c
index 76ceb20..0f09c80 100644
--- a/arch/arm/mach-omap/devices-gpmc-nand.c
+++ b/arch/arm/mach-omap/devices-gpmc-nand.c
@@ -91,7 +91,7 @@ int gpmc_generic_nand_devices_init(int cs, int width,
 	/* Configure GPMC CS before register */
 	gpmc_cs_config(nand_plat.cs, &nand_cfg);
 
-	add_generic_device("gpmc_nand", -1, NULL, OMAP_GPMC_BASE, 1024 * 4,
+	add_generic_device("gpmc_nand", -2, NULL, OMAP_GPMC_BASE, 1024 * 4,
 			   IORESOURCE_MEM, &nand_plat);
 
 	return 0;
diff --git a/arch/blackfin/boards/ipe337/ipe337.c b/arch/blackfin/boards/ipe337/ipe337.c
index ee642d1..4558957 100644
--- a/arch/blackfin/boards/ipe337/ipe337.c
+++ b/arch/blackfin/boards/ipe337/ipe337.c
@@ -6,7 +6,7 @@
 #include <fs.h>
 
 static int ipe337_devices_init(void) {
-	add_cfi_flash_device(-1, 0x20000000, 32 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, 0x20000000, 32 * 1024 * 1024, 0);
 	add_mem_device("ram0", 0x0, 128 * 1024 * 1024,
 		       IORESOURCE_MEM_WRITEABLE);
 
@@ -16,7 +16,7 @@ static int ipe337_devices_init(void) {
 	mdelay(100);
 	*pFIO0_FLAG_S = (1<<12);
 
-	add_generic_device("smc911x", -1, NULL, 0x24000000, 4096,
+	add_generic_device("smc911x", -2, NULL, 0x24000000, 4096,
 			   IORESOURCE_MEM, NULL);
 
 	devfs_add_partition("nor0", 0x00000, 0x20000, PARTITION_FIXED, "self0");
@@ -31,7 +31,7 @@ device_initcall(ipe337_devices_init);
 
 static int blackfin_console_init(void)
 {
-	add_generic_device("blackfin_serial", -1, NULL, 0, 4096,
+	add_generic_device("blackfin_serial", -2, NULL, 0, 4096,
 			   IORESOURCE_MEM, NULL);
 
 	return 0;
diff --git a/arch/mips/boards/dlink-dir-320/serial.c b/arch/mips/boards/dlink-dir-320/serial.c
index ebe8c06..ea5bb66 100644
--- a/arch/mips/boards/dlink-dir-320/serial.c
+++ b/arch/mips/boards/dlink-dir-320/serial.c
@@ -35,7 +35,7 @@ static struct NS16550_plat serial_plat = {
 static int dir320_console_init(void)
 {
 	/* Register the serial port */
-	add_ns16550_device(-1, DEBUG_LL_UART_ADDR, 8,
+	add_ns16550_device(-2, DEBUG_LL_UART_ADDR, 8,
 			IORESOURCE_MEM_8BIT, &serial_plat);
 
 	return 0;
diff --git a/arch/mips/boards/qemu-malta/serial.c b/arch/mips/boards/qemu-malta/serial.c
index ef6be17..8846af2 100644
--- a/arch/mips/boards/qemu-malta/serial.c
+++ b/arch/mips/boards/qemu-malta/serial.c
@@ -35,7 +35,7 @@ static struct NS16550_plat serial_plat = {
 static int malta_console_init(void)
 {
 	/* Register the serial port */
-	add_ns16550_device(-1, DEBUG_LL_UART_ADDR, 8,
+	add_ns16550_device(-2, DEBUG_LL_UART_ADDR, 8,
 			IORESOURCE_MEM_8BIT, &serial_plat);
 
 	return 0;
diff --git a/arch/nios2/boards/generic/generic.c b/arch/nios2/boards/generic/generic.c
index 0e3852b..84fe5b8 100644
--- a/arch/nios2/boards/generic/generic.c
+++ b/arch/nios2/boards/generic/generic.c
@@ -25,7 +25,7 @@ static struct resource mac_resources[] = {
 };
 
 static struct device_d mac_dev = {
-	.id            = -1,
+	.id            = -2,
 	.name          = "altera_tse",
 	.num_resources = ARRAY_SIZE(mac_resources),
 	.resource      = mac_resources,
@@ -34,7 +34,7 @@ static struct device_d mac_dev = {
 
 static int generic_devices_init(void)
 {
-	add_cfi_flash_device(-1, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
+	add_cfi_flash_device(-2, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
 	add_mem_device("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE,
 		       IORESOURCE_MEM_WRITEABLE);
 	register_device(&mac_dev);
@@ -53,7 +53,7 @@ device_initcall(generic_devices_init);
 
 static int altera_console_init(void)
 {
-	add_generic_device("altera_serial", -1, NULL, NIOS_SOPC_UART_BASE, 0x20,
+	add_generic_device("altera_serial", -2, NULL, NIOS_SOPC_UART_BASE, 0x20,
 			   IORESOURCE_MEM, NULL);
 
 	return 0;
diff --git a/arch/ppc/boards/pcm030/pcm030.c b/arch/ppc/boards/pcm030/pcm030.c
index ba59bfe..7fcfc22 100644
--- a/arch/ppc/boards/pcm030/pcm030.c
+++ b/arch/ppc/boards/pcm030/pcm030.c
@@ -43,10 +43,10 @@ static struct mpc5xxx_fec_platform_data fec_info = {
 
 static int devices_init (void)
 {
-	add_cfi_flash_device(-1, 0xff000000, 16 * 1024 * 1024, 0);
+	add_cfi_flash_device(-2, 0xff000000, 16 * 1024 * 1024, 0);
 	add_mem_device("ram0", 0x0, 64 * 1024 * 1024,
 		       IORESOURCE_MEM_WRITEABLE);
-	add_generic_device("fec_mpc5xxx", -1, NULL, MPC5XXX_FEC, 0,
+	add_generic_device("fec_mpc5xxx", -2, NULL, MPC5XXX_FEC, 0,
 			   IORESOURCE_MEM, &fec_info);
 
 	devfs_add_partition("nor0", 0x00f00000, 0x40000, PARTITION_FIXED, "self0");
@@ -59,9 +59,9 @@ device_initcall(devices_init);
 
 static int console_init(void)
 {
-	add_generic_device("mpc5xxx_serial", -1, NULL, MPC5XXX_PSC3, 4096,
+	add_generic_device("mpc5xxx_serial", -2, NULL, MPC5XXX_PSC3, 4096,
 			   IORESOURCE_MEM, NULL);
-	add_generic_device("mpc5xxx_serial", -1, NULL, MPC5XXX_PSC6, 4096,
+	add_generic_device("mpc5xxx_serial", -2, NULL, MPC5XXX_PSC6, 4096,
 			   IORESOURCE_MEM, NULL);
 	return 0;
 }
diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index f5452af..b3a7cd3 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -102,7 +102,7 @@ device_initcall(hf_init);
 
 int barebox_register_filedev(struct hf_platform_data *hf)
 {
-	return !add_generic_device("hostfile", -1, NULL, hf->base, hf->size,
+	return !add_generic_device("hostfile", -2, NULL, hf->base, hf->size,
 			   IORESOURCE_MEM, hf);
 }
 
diff --git a/arch/x86/boards/x86_generic/generic_pc.c b/arch/x86/boards/x86_generic/generic_pc.c
index 0ddf883..2371b8d 100644
--- a/arch/x86/boards/x86_generic/generic_pc.c
+++ b/arch/x86/boards/x86_generic/generic_pc.c
@@ -51,7 +51,7 @@ static int devices_init(void)
 	/* extended memory only */
 	add_mem_device("ram0", 0x0, bios_get_memsize() << 10,
 		       IORESOURCE_MEM_WRITEABLE);
-	add_generic_device("biosdrive", -1, NULL, 0, 0, IORESOURCE_MEM, NULL);
+	add_generic_device("biosdrive", -2, NULL, 0, 0, IORESOURCE_MEM, NULL);
 
 	if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
 		rc = devfs_add_partition("biosdisk0",
@@ -77,7 +77,7 @@ static struct NS16550_plat serial_plat = {
 static int pc_console_init(void)
 {
 	/* Register the serial port */
-	add_ns16550_device(-1, 0x3f8, 8, 0, &serial_plat);
+	add_ns16550_device(-2, 0x3f8, 8, 0, &serial_plat);
 
 	return 0;
 }
diff --git a/common/console.c b/common/console.c
index 1f6ee93..6c88fba 100644
--- a/common/console.c
+++ b/common/console.c
@@ -129,7 +129,7 @@ int console_register(struct console_device *newcdev)
 	int first = 0;
 	char ch;
 
-	dev->id = -1;
+	dev->id = -2;
 	strcpy(dev->name, "cs");
 	dev->type_data = newcdev;
 	if (newcdev->dev)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 0b80103..dfd81c5 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -103,7 +103,7 @@ int register_device(struct device_d *new_device)
 {
 	struct driver_d *drv;
 
-	if (new_device->id < 0) {
+	if (new_device->id == -2) {
 		new_device->id = get_free_deviceid(new_device->name);
 	} else {
 		if (get_device_by_name_id(new_device->name, new_device->id)) {
@@ -267,6 +267,9 @@ const char *dev_id(const struct device_d *dev)
 {
 	static char buf[MAX_DRIVER_NAME + 16];
 
+	if (dev->id == -1)
+		return dev->name;
+
 	snprintf(buf, sizeof(buf), FORMAT_DRIVER_NAME_ID, dev->name, dev->id);
 
 	return buf;
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 681de0a..ce3c1eb 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1229,7 +1229,7 @@ static int mci_card_probe(struct device_d *mci_dev)
 	p->read = mci_sd_read;
 	p->priv = mci_dev;
 
-	dev = add_generic_device("disk", -1, NULL, 0, mci->capacity, IORESOURCE_MEM, p);
+	dev = add_generic_device("disk", -2, NULL, 0, mci->capacity, IORESOURCE_MEM, p);
 	dev_add_child(&host->dev, dev);
 
 	pr_debug("SD Card successfully added\n");
diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
index 501a4f8..fe02db7 100644
--- a/drivers/net/miidev.c
+++ b/drivers/net/miidev.c
@@ -208,7 +208,7 @@ static struct driver_d miidev_drv = {
 int mii_register(struct mii_device *mdev)
 {
 	mdev->dev.priv = mdev;
-	mdev->dev.id = -1;
+	mdev->dev.id = -2;
 	strcpy(mdev->dev.name, "miidev");
 	if (mdev->parent)
 		dev_add_child(mdev->parent, &mdev->dev);
diff --git a/include/driver.h b/include/driver.h
index e9ac727..0b5a652 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -210,7 +210,7 @@ struct device_d *add_generic_device(const char* devname, int id, const char *res
 static inline struct device_d *add_mem_device(const char *name, resource_size_t start,
 		resource_size_t size, unsigned int flags)
 {
-	return add_generic_device("mem", -1, name, start, size,
+	return add_generic_device("mem", -2, name, start, size,
 				  IORESOURCE_MEM | flags, NULL);
 }
 
diff --git a/net/eth.c b/net/eth.c
index 621cb59..406a4e6 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -198,7 +198,7 @@ int eth_register(struct eth_device *edev)
 	}
 
 	strcpy(edev->dev.name, "eth");
-	edev->dev.id = -1;
+	edev->dev.id = -2;
 
 	if (edev->parent)
 		dev_add_child(edev->parent, &edev->dev);
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 2/4] add bus registration support
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (8 preceding siblings ...)
  2011-08-16  5:36 ` [PATCH 1/4] device: update id support to allow device without id Jean-Christophe PLAGNIOL-VILLARD
@ 2011-08-16  5:36 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-08-18  5:14   ` Sascha Hauer
  2011-08-16  5:36 ` [PATCH 3/4] platform_bus: add registrattion to bus Jean-Christophe PLAGNIOL-VILLARD
  2011-08-16  5:36 ` [PATCH 4/4] switch all device/driver to platform_device/driver_(un)register Jean-Christophe PLAGNIOL-VILLARD
  11 siblings, 1 reply; 19+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-08-16  5:36 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/base/Makefile |    1 +
 drivers/base/bus.c    |   69 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/driver.h      |   17 ++++++++++++
 3 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 drivers/base/bus.c

diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 957ca5a..5f19d4d 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -1,3 +1,4 @@
 obj-y	+= driver.o
+obj-y	+= bus.o
 obj-y	+= platform.o
 obj-y	+= resource.o
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
new file mode 100644
index 0000000..b124ab0
--- /dev/null
+++ b/drivers/base/bus.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <common.h>
+#include <driver.h>
+
+static int bus_match(struct device_d *dev, struct driver_d *drv)
+{
+	return strcmp(dev->name, drv->name) ? -1 : 0;
+}
+
+static int bus_probe(struct device_d *dev)
+{
+	if (dev->driver->probe)
+		return dev->driver->probe(dev);
+	return 0;
+}
+
+static void bus_remove(struct device_d *dev)
+{
+	if (dev->driver->remove)
+		dev->driver->remove(dev);
+}
+
+struct bus_type bus_bus = {
+	.name = "bus",
+	.match = bus_match,
+	.probe = bus_probe,
+	.remove = bus_remove,
+};
+
+void bus_for_each_device(struct bus_type *bus,
+			 void (*fn)(struct device_d *dev))
+{
+	struct device_d *dev;
+
+	for_each_device(dev) {
+		if (dev->bus == bus)
+			fn(dev);
+	}
+}
+
+int register_bus_driver(struct driver_d *drv)
+{
+	drv->bus = &bus_bus;
+	return register_driver(drv);
+}
+
+int register_bus_device(struct device_d *dev)
+{
+	dev->bus = &bus_bus;
+	return register_device(dev);
+}
diff --git a/include/driver.h b/include/driver.h
index 0b5a652..ab7424e 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -269,6 +269,23 @@ extern struct list_head driver_list;
  */
 #define for_each_device(dev) list_for_each_entry(dev, &device_list, list)
 
+
+int register_bus_driver(struct driver_d *drv);
+int register_bus_device(struct device_d *dev);
+
+/* Iterate over all bus device
+ */
+void bus_for_each_device(struct bus_type *bus,
+			 void (*fn)(struct device_d *dev));
+
+extern struct bus_type bus_bus;
+/* Iterate over all bus
+ */
+static inline void bus_for_each(void (*fn)(struct device_d *dev))
+{
+	bus_for_each_device(&bus_bus, fn);
+}
+
 /* Iterate over all drivers
  */
 #define for_each_driver(drv) list_for_each_entry(drv, &driver_list, list)
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 3/4] platform_bus: add registrattion to bus
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (9 preceding siblings ...)
  2011-08-16  5:36 ` [PATCH 2/4] add bus registration support Jean-Christophe PLAGNIOL-VILLARD
@ 2011-08-16  5:36 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-08-16  5:36 ` [PATCH 4/4] switch all device/driver to platform_device/driver_(un)register Jean-Christophe PLAGNIOL-VILLARD
  11 siblings, 0 replies; 19+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-08-16  5:36 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/base/driver.c   |    3 +++
 drivers/base/platform.c |   16 ++++++++--------
 include/driver.h        |    1 +
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index dfd81c5..33eb016 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -120,6 +120,9 @@ int register_device(struct device_d *new_device)
 		new_device->bus = &platform_bus;
 	}
 
+	if (!new_device->parent && new_device->bus == &platform_bus)
+		dev_add_child(&platform_bus_device, new_device);
+
 	list_add_tail(&new_device->list, &device_list);
 	INIT_LIST_HEAD(&new_device->children);
 	INIT_LIST_HEAD(&new_device->cdevs);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index e0dd9ea..60c87d3 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -21,6 +21,7 @@
  */
 #include <common.h>
 #include <driver.h>
+#include <init.h>
 
 static int platform_match(struct device_d *dev, struct driver_d *drv)
 {
@@ -44,15 +45,14 @@ struct bus_type platform_bus = {
 	.remove = platform_remove,
 };
 
-#if 0
-LIST_HEAD(bus_list);
-EXPORT_SYMBOL(bus_list);
+struct device_d platform_bus_device = {
+	.id	= -1,
+	.name	= "platform",
+};
 
-int bus_register(struct bus_type *bus)
+static int platform_bus_init(void)
 {
-	list_add_tail(&bus->list, &bus_list);
-
+	register_bus_device(&platform_bus_device);
 	return 0;
 }
-#endif
-
+postcore_initcall(platform_bus_init);
diff --git a/include/driver.h b/include/driver.h
index ab7424e..c122cf2 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -370,6 +370,7 @@ struct bus_type {
 };
 
 extern struct bus_type platform_bus;
+extern struct device_d platform_bus_device;
 
 struct file_operations {
 	/*! Called in response of reading from this device. Required */
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 4/4] switch all device/driver to platform_device/driver_(un)register
  2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
                   ` (10 preceding siblings ...)
  2011-08-16  5:36 ` [PATCH 3/4] platform_bus: add registrattion to bus Jean-Christophe PLAGNIOL-VILLARD
@ 2011-08-16  5:36 ` Jean-Christophe PLAGNIOL-VILLARD
  11 siblings, 0 replies; 19+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-08-16  5:36 UTC (permalink / raw)
  To: barebox

now (un)register_device/driver are only use by bus implementation

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/nhk8815/setup.c     |    2 +-
 arch/arm/mach-imx/iim.c             |    2 +-
 arch/arm/mach-omap/arch-omap.dox    |    2 +-
 arch/nios2/boards/generic/generic.c |    4 ++--
 arch/sandbox/board/board.c          |    2 +-
 arch/sandbox/board/console.c        |    2 +-
 arch/sandbox/board/hostfile.c       |    2 +-
 commands/mem.c                      |    2 +-
 common/console.c                    |    2 +-
 drivers/ata/bios.c                  |    4 ++--
 drivers/ata/disk_drive.c            |    4 ++--
 drivers/base/driver.c               |   11 ++++-------
 drivers/base/platform.c             |   17 +++++++++++++++++
 drivers/base/resource.c             |    6 +++---
 drivers/eeprom/at25.c               |    2 +-
 drivers/i2c/busses/i2c-imx.c        |    2 +-
 drivers/i2c/busses/i2c-omap.c       |    2 +-
 drivers/i2c/i2c.c                   |    2 +-
 drivers/mci/atmel_mci.c             |    2 +-
 drivers/mci/imx-esdhc.c             |    2 +-
 drivers/mci/imx.c                   |    2 +-
 drivers/mci/mci-core.c              |    4 ++--
 drivers/mci/mxs.c                   |    2 +-
 drivers/mci/omap_hsmmc.c            |    2 +-
 drivers/mci/s3c.c                   |    2 +-
 drivers/mfd/lp3972.c                |    2 +-
 drivers/mfd/mc13783.c               |    2 +-
 drivers/mfd/mc13892.c               |    4 ++--
 drivers/mfd/mc34704.c               |    2 +-
 drivers/mfd/mc9sdz60.c              |    2 +-
 drivers/mfd/twl4030.c               |    2 +-
 drivers/mtd/nand/atmel_nand.c       |    2 +-
 drivers/mtd/nand/nand.c             |    4 ++--
 drivers/mtd/nand/nand_imx.c         |    2 +-
 drivers/mtd/nand/nand_omap_gpmc.c   |    2 +-
 drivers/mtd/nand/nand_s3c2410.c     |    2 +-
 drivers/mtd/nand/nomadik_nand.c     |    2 +-
 drivers/net/altera_tse.c            |    2 +-
 drivers/net/at91_ether.c            |    2 +-
 drivers/net/cs8900.c                |    2 +-
 drivers/net/dm9000.c                |    2 +-
 drivers/net/ep93xx.c                |    2 +-
 drivers/net/fec_imx.c               |    2 +-
 drivers/net/fec_mpc5200.c           |    2 +-
 drivers/net/macb.c                  |    2 +-
 drivers/net/miidev.c                |    6 +++---
 drivers/net/netx_eth.c              |    2 +-
 drivers/net/smc91111.c              |    2 +-
 drivers/net/smc911x.c               |    2 +-
 drivers/net/tap.c                   |    2 +-
 drivers/net/usb/usbnet.c            |    2 +-
 drivers/nor/cfi_flash.c             |    2 +-
 drivers/serial/amba-pl011.c         |    2 +-
 drivers/serial/arm_dcc.c            |    4 ++--
 drivers/serial/atmel.c              |    2 +-
 drivers/serial/linux_console.c      |    2 +-
 drivers/serial/serial_altera.c      |    2 +-
 drivers/serial/serial_altera_jtag.c |    2 +-
 drivers/serial/serial_blackfin.c    |    2 +-
 drivers/serial/serial_imx.c         |    2 +-
 drivers/serial/serial_mpc5xxx.c     |    2 +-
 drivers/serial/serial_netx.c        |    2 +-
 drivers/serial/serial_ns16550.c     |    4 ++--
 drivers/serial/serial_pl010.c       |    2 +-
 drivers/serial/serial_s3c24x0.c     |    2 +-
 drivers/serial/stm-serial.c         |    2 +-
 drivers/spi/imx_spi.c               |    2 +-
 drivers/spi/spi.c                   |    4 ++--
 drivers/usb/core/usb.c              |    6 +++---
 drivers/usb/gadget/composite.c      |    4 ++--
 drivers/usb/gadget/fsl_udc.c        |   10 +++++-----
 drivers/usb/host/ehci-hcd.c         |    2 +-
 drivers/video/fb.c                  |    4 ++--
 drivers/video/imx-ipu-fb.c          |    2 +-
 drivers/video/imx.c                 |    2 +-
 drivers/video/s3c.c                 |    2 +-
 drivers/video/stm.c                 |    2 +-
 fs/fs.c                             |    8 ++++----
 include/driver.h                    |    8 ++++++++
 net/eth.c                           |    2 +-
 80 files changed, 130 insertions(+), 108 deletions(-)

diff --git a/arch/arm/boards/nhk8815/setup.c b/arch/arm/boards/nhk8815/setup.c
index 15c16a0..97efcfb 100644
--- a/arch/arm/boards/nhk8815/setup.c
+++ b/arch/arm/boards/nhk8815/setup.c
@@ -98,7 +98,7 @@ static int nhk8815_devices_init(void)
 	add_generic_device("smc91c111", -2, NULL, 0x34000300, 16,
 			   IORESOURCE_MEM, NULL);
 
-	register_device(&nhk8815_nand_device);
+	platform_device_register(&nhk8815_nand_device);
 
 	armlinux_set_architecture(MACH_TYPE_NOMADIK);
 	armlinux_set_bootparams((void *)(0x00000100));
diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c
index ca89710..3e6b80f 100644
--- a/arch/arm/mach-imx/iim.c
+++ b/arch/arm/mach-imx/iim.c
@@ -295,7 +295,7 @@ static struct driver_d imx_iim_driver = {
 
 static int imx_iim_init(void)
 {
-	register_driver(&imx_iim_driver);
+	platform_driver_register(&imx_iim_driver);
 
 	return 0;
 }
diff --git a/arch/arm/mach-omap/arch-omap.dox b/arch/arm/mach-omap/arch-omap.dox
index 9c90b4f..6b6b3a8 100644
--- a/arch/arm/mach-omap/arch-omap.dox
+++ b/arch/arm/mach-omap/arch-omap.dox
@@ -85,7 +85,7 @@ static struct device_d my_little_device = {
  };
 static int my_board_devices_init(void) {
 	/* Do Blah Blah Blah */
-	return register_device(&my_little_device);
+	return platform_device_register(&my_little_device);
 }
 
 device_initcall(my_board_devices_init);
diff --git a/arch/nios2/boards/generic/generic.c b/arch/nios2/boards/generic/generic.c
index 84fe5b8..7bf0dc8 100644
--- a/arch/nios2/boards/generic/generic.c
+++ b/arch/nios2/boards/generic/generic.c
@@ -37,8 +37,8 @@ static int generic_devices_init(void)
 	add_cfi_flash_device(-2, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
 	add_mem_device("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE,
 		       IORESOURCE_MEM_WRITEABLE);
-	register_device(&mac_dev);
-	/*register_device(&epcs_flash_device);*/
+	platform_device_register(&mac_dev);
+	/*platform_device_register(&epcs_flash_device);*/
 
 	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
 	devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
diff --git a/arch/sandbox/board/board.c b/arch/sandbox/board/board.c
index 7d489fd..e3d2587 100644
--- a/arch/sandbox/board/board.c
+++ b/arch/sandbox/board/board.c
@@ -34,7 +34,7 @@ static struct device_d tap_device = {
 
 static int devices_init(void)
 {
-	register_device(&tap_device);
+	platform_device_register(&tap_device);
 
 	return 0;
 }
diff --git a/arch/sandbox/board/console.c b/arch/sandbox/board/console.c
index 2959e85..474953c 100644
--- a/arch/sandbox/board/console.c
+++ b/arch/sandbox/board/console.c
@@ -47,6 +47,6 @@ int barebox_register_console(char *name, int stdinfd, int stdoutfd)
 	data->stdoutfd = stdoutfd;
 	data->stdinfd  = stdinfd;
 
-	return register_device(dev);
+	return platform_device_register(dev);
 }
 
diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index b3a7cd3..54d4906 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -95,7 +95,7 @@ static struct driver_d hf_drv = {
 
 static int hf_init(void)
 {
-	return register_driver(&hf_drv);
+	return platform_driver_register(&hf_drv);
 }
 
 device_initcall(hf_init);
diff --git a/commands/mem.c b/commands/mem.c
index 88af55c..e0e0e6e 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -619,7 +619,7 @@ static int mem_init(void)
 	}
 
 	add_mem_device("mem", 0, ~0, IORESOURCE_MEM_WRITEABLE);
-	register_driver(&mem_drv);
+	platform_driver_register(&mem_drv);
 
 	return 0;
 }
diff --git a/common/console.c b/common/console.c
index 6c88fba..ffd886e 100644
--- a/common/console.c
+++ b/common/console.c
@@ -134,7 +134,7 @@ int console_register(struct console_device *newcdev)
 	dev->type_data = newcdev;
 	if (newcdev->dev)
 		dev_add_child(newcdev->dev, dev);
-	register_device(dev);
+	platform_device_register(dev);
 
 	if (newcdev->setbrg) {
 		dev_add_param(dev, "baudrate", console_baudrate_set, NULL, 0);
diff --git a/drivers/ata/bios.c b/drivers/ata/bios.c
index 6e2377c..4aac33b 100644
--- a/drivers/ata/bios.c
+++ b/drivers/ata/bios.c
@@ -260,7 +260,7 @@ static int biosdisk_probe(struct device_d *dev)
 		drive_dev->resource[0].start = 0;
 		drive_dev->platform_data = p;
 
-		register_device(drive_dev);
+		platform_device_register(drive_dev);
 	}
 
 	return 0;
@@ -283,7 +283,7 @@ static int biosdisk_init(void)
 		return -EIO;
 	}
 
-	register_driver(&biosdisk_driver);
+	platform_driver_register(&biosdisk_driver);
 	return 0;
 }
 
diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c
index 14b5e66..6123ca2 100644
--- a/drivers/ata/disk_drive.c
+++ b/drivers/ata/disk_drive.c
@@ -233,9 +233,9 @@ static struct driver_d disk_driver = {
 static int disk_init(void)
 {
 #ifdef CONFIG_ATA_BIOS
-	register_driver(&biosdisk_driver);
+	platform_driver_register(&biosdisk_driver);
 #endif
-	register_driver(&disk_driver);
+	platform_driver_register(&disk_driver);
 	return 0;
 }
 
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 33eb016..b0d614b 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -116,13 +116,10 @@ int register_device(struct device_d *new_device)
 	debug ("register_device: %s\n", dev_name(new_device));
 
 	if (!new_device->bus) {
-//		dev_err(new_device, "no bus type associated. Needs fixup\n");
-		new_device->bus = &platform_bus;
+		dev_err(new_device, "no bus type associated. Needs fixup\n");
+		return -EIO;
 	}
 
-	if (!new_device->parent && new_device->bus == &platform_bus)
-		dev_add_child(&platform_bus_device, new_device);
-
 	list_add_tail(&new_device->list, &device_list);
 	INIT_LIST_HEAD(&new_device->children);
 	INIT_LIST_HEAD(&new_device->cdevs);
@@ -199,8 +196,8 @@ int register_driver(struct driver_d *drv)
 	debug("register_driver: %s\n", drv->name);
 
 	if (!drv->bus) {
-//		pr_err("driver %s has no bus type associated. Needs fixup\n", drv->name);
-		drv->bus = &platform_bus;
+		pr_err("driver %s has no bus type associated. Needs fixup\n", drv->name);
+		return -EIO;
 	}
 
 	list_add_tail(&drv->list, &driver_list);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 60c87d3..32f25d0 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -50,6 +50,23 @@ struct device_d platform_bus_device = {
 	.name	= "platform",
 };
 
+int platform_driver_register(struct driver_d *drv)
+{
+	drv->bus = &platform_bus;
+
+	return register_driver(drv);
+}
+
+int platform_device_register(struct device_d *dev)
+{
+	dev->bus = &platform_bus;
+
+	if (!dev->parent)
+		dev_add_child(&platform_bus_device, dev);
+
+	return register_device(dev);
+}
+
 static int platform_bus_init(void)
 {
 	register_bus_device(&platform_bus_device);
diff --git a/drivers/base/resource.c b/drivers/base/resource.c
index 175beb9..e8a47e6 100644
--- a/drivers/base/resource.c
+++ b/drivers/base/resource.c
@@ -52,7 +52,7 @@ struct device_d *add_generic_device(const char* devname, int id, const char *res
 	dev->resource[0].size = size;
 	dev->resource[0].flags = flags;
 
-	register_device(dev);
+	platform_device_register(dev);
 
 	return dev;
 }
@@ -91,7 +91,7 @@ struct device_d *add_dm9000_device(int id, resource_size_t base,
 	dev->resource[1].size = size;
 	dev->resource[1].flags = IORESOURCE_MEM | flags;
 
-	register_device(dev);
+	platform_device_register(dev);
 
 	return dev;
 }
@@ -112,7 +112,7 @@ struct device_d *add_usb_ehci_device(int id, resource_size_t hccr,
 	dev->resource[1].start = hcor;
 	dev->resource[1].flags = IORESOURCE_MEM;
 
-	register_device(dev);
+	platform_device_register(dev);
 
 	return dev;
 }
diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c
index 8a979d5..f8e3a18 100644
--- a/drivers/eeprom/at25.c
+++ b/drivers/eeprom/at25.c
@@ -312,7 +312,7 @@ static struct driver_d at25_driver = {
 
 static int at25_init(void)
 {
-	register_driver(&at25_driver);
+	platform_driver_register(&at25_driver);
 	return 0;
 }
 
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 2d075f7..2ae3050 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -502,6 +502,6 @@ static struct driver_d i2c_imx_driver = {
 
 static int __init i2c_adap_imx_init(void)
 {
-	return register_driver(&i2c_imx_driver);
+	return platform_driver_register(&i2c_imx_driver);
 }
 device_initcall(i2c_adap_imx_init);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 95c4fdf..b84a2f8 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -793,7 +793,7 @@ static struct driver_d omap_i2c_driver = {
 /* I2C may be needed to bring up other drivers */
 static int __init omap_i2c_init_driver(void)
 {
-	return register_driver(&omap_i2c_driver);
+	return platform_driver_register(&omap_i2c_driver);
 }
 device_initcall(omap_i2c_init_driver);
 
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 5df0d30..489e38c 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -253,7 +253,7 @@ struct i2c_client *i2c_new_device(struct i2c_adapter *adapter,
 	client->adapter = adapter;
 	client->addr = chip->addr;
 
-	status = register_device(&client->dev);
+	status = platform_device_register(&client->dev);
 
 #if 0
 	/* drivers may modify this initial i/o setup */
diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c
index 47e3924..a213a12 100644
--- a/drivers/mci/atmel_mci.c
+++ b/drivers/mci/atmel_mci.c
@@ -488,7 +488,7 @@ static struct driver_d atmel_mci_driver = {
 
 static int atmel_mci_init_driver(void)
 {
-	register_driver(&atmel_mci_driver);
+	platform_driver_register(&atmel_mci_driver);
 	return 0;
 }
 
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 358f0dc..d38144a 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -506,7 +506,7 @@ static struct driver_d fsl_esdhc_driver = {
 
 static int fsl_esdhc_init_driver(void)
 {
-        register_driver(&fsl_esdhc_driver);
+        platform_driver_register(&fsl_esdhc_driver);
         return 0;
 }
 
diff --git a/drivers/mci/imx.c b/drivers/mci/imx.c
index 905c251..6705e4c 100644
--- a/drivers/mci/imx.c
+++ b/drivers/mci/imx.c
@@ -513,7 +513,7 @@ static struct driver_d mxcmci_driver = {
 
 static int mxcmci_init_driver(void)
 {
-        register_driver(&mxcmci_driver);
+        platform_driver_register(&mxcmci_driver);
         return 0;
 }
 
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index ce3c1eb..9ee9e8e 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1349,7 +1349,7 @@ static struct driver_d mci_driver = {
 static int mci_init(void)
 {
 	sector_buf = xmemalign(32, 512);
-	return register_driver(&mci_driver);
+	return platform_driver_register(&mci_driver);
 }
 
 device_initcall(mci_init);
@@ -1367,5 +1367,5 @@ int mci_register(struct mci_host *host)
 	mci_dev->platform_data = (void*)host;
 	dev_add_child(host->hw_dev, mci_dev);
 
-	return register_device(mci_dev);
+	return platform_device_register(mci_dev);
 }
diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index 70b8be9..f45f635 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -766,7 +766,7 @@ static struct driver_d mxs_mci_driver = {
 
 static int mxs_mci_init_driver(void)
 {
-        register_driver(&mxs_mci_driver);
+        platform_driver_register(&mxs_mci_driver);
         return 0;
 }
 
diff --git a/drivers/mci/omap_hsmmc.c b/drivers/mci/omap_hsmmc.c
index 5fdf445..1ca0d64 100644
--- a/drivers/mci/omap_hsmmc.c
+++ b/drivers/mci/omap_hsmmc.c
@@ -578,7 +578,7 @@ static struct driver_d omap_mmc_driver = {
 
 static int omap_mmc_init_driver(void)
 {
-        register_driver(&omap_mmc_driver);
+        platform_driver_register(&omap_mmc_driver);
         return 0;
 }
 
diff --git a/drivers/mci/s3c.c b/drivers/mci/s3c.c
index c621445..7b3e0a1 100644
--- a/drivers/mci/s3c.c
+++ b/drivers/mci/s3c.c
@@ -823,7 +823,7 @@ static struct driver_d s3c_mci_driver = {
 
 static int s3c_mci_init_driver(void)
 {
-        register_driver(&s3c_mci_driver);
+        platform_driver_register(&s3c_mci_driver);
         return 0;
 }
 
diff --git a/drivers/mfd/lp3972.c b/drivers/mfd/lp3972.c
index 9826699..ca7ba57 100644
--- a/drivers/mfd/lp3972.c
+++ b/drivers/mfd/lp3972.c
@@ -103,7 +103,7 @@ static struct driver_d lp_driver = {
 
 static int lp_init(void)
 {
-	register_driver(&lp_driver);
+	platform_driver_register(&lp_driver);
 	return 0;
 }
 
diff --git a/drivers/mfd/mc13783.c b/drivers/mfd/mc13783.c
index 19e2780..7bd4145 100644
--- a/drivers/mfd/mc13783.c
+++ b/drivers/mfd/mc13783.c
@@ -229,7 +229,7 @@ static struct driver_d pmic_driver = {
 
 static int pmic_init(void)
 {
-        register_driver(&pmic_driver);
+        platform_driver_register(&pmic_driver);
         return 0;
 }
 
diff --git a/drivers/mfd/mc13892.c b/drivers/mfd/mc13892.c
index b2cc911..3fcba4a 100644
--- a/drivers/mfd/mc13892.c
+++ b/drivers/mfd/mc13892.c
@@ -319,8 +319,8 @@ static struct driver_d mc_spi_driver = {
 
 static int mc_init(void)
 {
-        register_driver(&mc_i2c_driver);
-        register_driver(&mc_spi_driver);
+        platform_driver_register(&mc_i2c_driver);
+        platform_driver_register(&mc_spi_driver);
         return 0;
 }
 
diff --git a/drivers/mfd/mc34704.c b/drivers/mfd/mc34704.c
index a2171b3..37a0280 100644
--- a/drivers/mfd/mc34704.c
+++ b/drivers/mfd/mc34704.c
@@ -134,7 +134,7 @@ static struct driver_d mc34704_driver = {
 
 static int mc34704_init(void)
 {
-	register_driver(&mc34704_driver);
+	platform_driver_register(&mc34704_driver);
         return 0;
 }
 device_initcall(mc34704_init);
diff --git a/drivers/mfd/mc9sdz60.c b/drivers/mfd/mc9sdz60.c
index db208ec..9121c0a 100644
--- a/drivers/mfd/mc9sdz60.c
+++ b/drivers/mfd/mc9sdz60.c
@@ -146,7 +146,7 @@ static struct driver_d mc_driver = {
 
 static int mc_init(void)
 {
-        register_driver(&mc_driver);
+        platform_driver_register(&mc_driver);
         return 0;
 }
 
diff --git a/drivers/mfd/twl4030.c b/drivers/mfd/twl4030.c
index 6a06bd4..2ab714b 100644
--- a/drivers/mfd/twl4030.c
+++ b/drivers/mfd/twl4030.c
@@ -179,7 +179,7 @@ static struct driver_d twl_driver = {
 
 static int twl_init(void)
 {
-        register_driver(&twl_driver);
+        platform_driver_register(&twl_driver);
         return 0;
 }
 
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index f79be9a..06b1ba4 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -506,7 +506,7 @@ static struct driver_d atmel_nand_driver = {
 
 static int __init atmel_nand_init(void)
 {
-	return register_driver(&atmel_nand_driver);
+	return platform_driver_register(&atmel_nand_driver);
 }
 
 device_initcall(atmel_nand_init);
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index 9423ac8..ae74324 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -254,7 +254,7 @@ int add_mtd_device(struct mtd_info *mtd)
 	char str[16];
 
 	strcpy(mtd->class_dev.name, "nand");
-	register_device(&mtd->class_dev);
+	platform_device_register(&mtd->class_dev);
 
 	mtd->cdev.ops = &nand_ops;
 	mtd->cdev.size = mtd->size;
@@ -275,7 +275,7 @@ int add_mtd_device(struct mtd_info *mtd)
 
 int del_mtd_device (struct mtd_info *mtd)
 {
-	unregister_device(&mtd->class_dev);
+	platform_device_unregister(&mtd->class_dev);
 	nand_exit_oob_cdev(mtd);
 	free(mtd->param_size.value);
 	free(mtd->cdev.name);
diff --git a/drivers/mtd/nand/nand_imx.c b/drivers/mtd/nand/nand_imx.c
index e471c8a..bcb8a24 100644
--- a/drivers/mtd/nand/nand_imx.c
+++ b/drivers/mtd/nand/nand_imx.c
@@ -1185,7 +1185,7 @@ static struct driver_d imx_nand_driver = {
  */
 static int __init imx_nand_init(void)
 {
-	return register_driver(&imx_nand_driver);
+	return platform_driver_register(&imx_nand_driver);
 }
 
 device_initcall(imx_nand_init);
diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index 083aa57..b5d35fd 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -842,7 +842,7 @@ static struct driver_d gpmc_nand_driver = {
 
 static int gpmc_nand_init(void)
 {
-	return register_driver(&gpmc_nand_driver);
+	return platform_driver_register(&gpmc_nand_driver);
 }
 
 device_initcall(gpmc_nand_init);
diff --git a/drivers/mtd/nand/nand_s3c2410.c b/drivers/mtd/nand/nand_s3c2410.c
index 0ce20d4..bdb8858 100644
--- a/drivers/mtd/nand/nand_s3c2410.c
+++ b/drivers/mtd/nand/nand_s3c2410.c
@@ -644,7 +644,7 @@ BAREBOX_CMD_END
  */
 static int __init s3c24x0_nand_init(void)
 {
-	return register_driver(&s3c24x0_nand_driver);
+	return platform_driver_register(&s3c24x0_nand_driver);
 }
 
 device_initcall(s3c24x0_nand_init);
diff --git a/drivers/mtd/nand/nomadik_nand.c b/drivers/mtd/nand/nomadik_nand.c
index 3073011..e9ff8b6 100644
--- a/drivers/mtd/nand/nomadik_nand.c
+++ b/drivers/mtd/nand/nomadik_nand.c
@@ -237,7 +237,7 @@ static struct driver_d nomadik_nand_driver = {
 static int __init nand_nomadik_init(void)
 {
 	pr_info("Nomadik NAND driver\n");
-	return register_driver(&nomadik_nand_driver);
+	return platform_driver_register(&nomadik_nand_driver);
 }
 
 device_initcall(nand_nomadik_init);
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index 7e456c7..2b9eea8 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -570,7 +570,7 @@ static struct driver_d altera_tse_driver = {
 
 static int tse_init(void)
 {
-	register_driver(&altera_tse_driver);
+	platform_driver_register(&altera_tse_driver);
 	return 0;
 }
 
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index 8d0b43b..1d477f9 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -337,7 +337,7 @@ static struct driver_d at91_eth_driver = {
 
 static int at91_eth_init(void)
 {
-        register_driver(&at91_eth_driver);
+        platform_driver_register(&at91_eth_driver);
         return 0;
 }
 
diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index 33afc5e..c1766eb 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -472,7 +472,7 @@ static struct driver_d cs8900_driver = {
 
 static int cs8900_init(void)
 {
-	register_driver(&cs8900_driver);
+	platform_driver_register(&cs8900_driver);
 	return 0;
 }
 
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index e9ec61b..feefd63 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -556,7 +556,7 @@ static struct driver_d dm9000_driver = {
 
 static int dm9000_init(void)
 {
-        register_driver(&dm9000_driver);
+        platform_driver_register(&dm9000_driver);
         return 0;
 }
 
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
index 954ec78..c901090 100644
--- a/drivers/net/ep93xx.c
+++ b/drivers/net/ep93xx.c
@@ -662,7 +662,7 @@ static struct driver_d ep93xx_eth_driver = {
 
 static int ep93xx_eth_init(void)
 {
-	register_driver(&ep93xx_eth_driver);
+	platform_driver_register(&ep93xx_eth_driver);
 	return 0;
 }
 
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 3b0f266..b307502 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -672,7 +672,7 @@ static struct driver_d fec_driver = {
 
 static int fec_register(void)
 {
-        register_driver(&fec_driver);
+        platform_driver_register(&fec_driver);
         return 0;
 }
 
diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c
index 403aad5..aa77dba 100644
--- a/drivers/net/fec_mpc5200.c
+++ b/drivers/net/fec_mpc5200.c
@@ -704,7 +704,7 @@ static struct driver_d mpc5xxx_driver = {
 
 static int mpc5xxx_fec_register(void)
 {
-        register_driver(&mpc5xxx_driver);
+        platform_driver_register(&mpc5xxx_driver);
         return 0;
 }
 
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 898cf3d..77a3cd1 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -486,7 +486,7 @@ static struct driver_d macb_driver = {
 static int macb_driver_init(void)
 {
 	debug("%s\n", __func__);
-        register_driver(&macb_driver);
+        platform_driver_register(&macb_driver);
         return 0;
 }
 
diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
index fe02db7..d616c10 100644
--- a/drivers/net/miidev.c
+++ b/drivers/net/miidev.c
@@ -213,17 +213,17 @@ int mii_register(struct mii_device *mdev)
 	if (mdev->parent)
 		dev_add_child(mdev->parent, &mdev->dev);
 
-	return register_device(&mdev->dev);
+	return platform_device_register(&mdev->dev);
 }
 
 void mii_unregister(struct mii_device *mdev)
 {
-	unregister_device(&mdev->dev);
+	platform_device_unregister(&mdev->dev);
 }
 
 static int miidev_init(void)
 {
-	register_driver(&miidev_drv);
+	platform_driver_register(&miidev_drv);
 	return 0;
 }
 
diff --git a/drivers/net/netx_eth.c b/drivers/net/netx_eth.c
index 5503bc9..e136c81 100644
--- a/drivers/net/netx_eth.c
+++ b/drivers/net/netx_eth.c
@@ -280,7 +280,7 @@ static struct driver_d netx_eth_driver = {
 
 static int netx_eth_init(void)
 {
-        register_driver(&netx_eth_driver);
+        platform_driver_register(&netx_eth_driver);
         return 0;
 }
 
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 2313aae..d478e9c 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -1336,7 +1336,7 @@ static struct driver_d smc91c111_driver = {
 
 static int smc91c111_init(void)
 {
-        register_driver(&smc91c111_driver);
+        platform_driver_register(&smc91c111_driver);
         return 0;
 }
 
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index fba61c4..6acba9c 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -751,7 +751,7 @@ static struct driver_d smc911x_driver = {
 
 static int smc911x_init(void)
 {
-        register_driver(&smc911x_driver);
+        platform_driver_register(&smc911x_driver);
         return 0;
 }
 
diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index a30a9c8..38c3ae7 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -115,7 +115,7 @@ static struct driver_d tap_driver = {
 
 static int tap_init(void)
 {
-        register_driver(&tap_driver);
+        platform_driver_register(&tap_driver);
         return 0;
 }
 
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 5ffd7a6..da740ce 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -236,7 +236,7 @@ void usbnet_disconnect(struct usb_device *usbdev)
 	struct driver_info *info;
 
 	eth_unregister(edev);
-	unregister_device(&edev->dev);
+	platform_device_unregister(&edev->dev);
 
 	info = undev->driver_info;
 	if (info->unbind)
diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
index 461b0e6..009e626 100644
--- a/drivers/nor/cfi_flash.c
+++ b/drivers/nor/cfi_flash.c
@@ -1017,7 +1017,7 @@ static struct driver_d cfi_driver = {
 
 static int cfi_init(void)
 {
-        return register_driver(&cfi_driver);
+        return platform_driver_register(&cfi_driver);
 }
 
 device_initcall(cfi_init);
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 2b6d5d3..c5252dd 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -190,7 +190,7 @@ static struct driver_d pl011_driver = {
 
 static int pl011_init(void)
 {
-	register_driver(&pl011_driver);
+	platform_driver_register(&pl011_driver);
 	return 0;
 }
 
diff --git a/drivers/serial/arm_dcc.c b/drivers/serial/arm_dcc.c
index e1066ab..100468d 100644
--- a/drivers/serial/arm_dcc.c
+++ b/drivers/serial/arm_dcc.c
@@ -161,8 +161,8 @@ static struct device_d arm_dcc_device = {
 
 static int arm_dcc_init(void)
 {
-	register_device(&arm_dcc_device);
-	register_driver(&arm_dcc_driver);
+	platform_device_register(&arm_dcc_device);
+	platform_driver_register(&arm_dcc_driver);
 	return 0;
 }
 
diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c
index 2d4b842..120a985 100644
--- a/drivers/serial/atmel.c
+++ b/drivers/serial/atmel.c
@@ -425,7 +425,7 @@ static struct driver_d atmel_serial_driver = {
 
 static int atmel_serial_init(void)
 {
-	register_driver(&atmel_serial_driver);
+	platform_driver_register(&atmel_serial_driver);
 	return 0;
 }
 
diff --git a/drivers/serial/linux_console.c b/drivers/serial/linux_console.c
index c792b50..d9b7639 100644
--- a/drivers/serial/linux_console.c
+++ b/drivers/serial/linux_console.c
@@ -85,7 +85,7 @@ static struct driver_d linux_console_driver = {
 
 static int console_init(void)
 {
-	return register_driver(&linux_console_driver);
+	return platform_driver_register(&linux_console_driver);
 }
 
 console_initcall(console_init);
diff --git a/drivers/serial/serial_altera.c b/drivers/serial/serial_altera.c
index 1148564..2fc9b8c 100644
--- a/drivers/serial/serial_altera.c
+++ b/drivers/serial/serial_altera.c
@@ -109,7 +109,7 @@ static struct driver_d altera_serial_driver = {
 
 static int altera_serial_init(void)
 {
-	return register_driver(&altera_serial_driver);
+	return platform_driver_register(&altera_serial_driver);
 }
 
 console_initcall(altera_serial_init);
diff --git a/drivers/serial/serial_altera_jtag.c b/drivers/serial/serial_altera_jtag.c
index 2e34c89..26d5423 100644
--- a/drivers/serial/serial_altera_jtag.c
+++ b/drivers/serial/serial_altera_jtag.c
@@ -114,7 +114,7 @@ static struct driver_d altera_serial_jtag_driver = {
 
 static int altera_serial_jtag_init(void)
 {
-	return register_driver(&altera_serial_jtag_driver);
+	return platform_driver_register(&altera_serial_jtag_driver);
 }
 
 console_initcall(altera_serial_jtag_init);
diff --git a/drivers/serial/serial_blackfin.c b/drivers/serial/serial_blackfin.c
index 59b2fbb..01dc1a1 100644
--- a/drivers/serial/serial_blackfin.c
+++ b/drivers/serial/serial_blackfin.c
@@ -138,7 +138,7 @@ static struct driver_d blackfin_serial_driver = {
 
 static int blackfin_serial_init(void)
 {
-	register_driver(&blackfin_serial_driver);
+	platform_driver_register(&blackfin_serial_driver);
 	return 0;
 }
 
diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index e3edac9..5415007 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -363,7 +363,7 @@ static struct driver_d imx_serial_driver = {
 
 static int imx_serial_init(void)
 {
-	register_driver(&imx_serial_driver);
+	platform_driver_register(&imx_serial_driver);
 	return 0;
 }
 
diff --git a/drivers/serial/serial_mpc5xxx.c b/drivers/serial/serial_mpc5xxx.c
index fb580cf..5e15345 100644
--- a/drivers/serial/serial_mpc5xxx.c
+++ b/drivers/serial/serial_mpc5xxx.c
@@ -175,7 +175,7 @@ static struct driver_d mpc5xxx_serial_driver = {
 
 static int mpc5xxx_serial_register(void)
 {
-	register_driver(&mpc5xxx_serial_driver);
+	platform_driver_register(&mpc5xxx_serial_driver);
 	return 0;
 }
 
diff --git a/drivers/serial/serial_netx.c b/drivers/serial/serial_netx.c
index fbbc4ef..ca72de7 100644
--- a/drivers/serial/serial_netx.c
+++ b/drivers/serial/serial_netx.c
@@ -164,7 +164,7 @@ static struct driver_d netx_serial_driver = {
 
 static int netx_serial_init(void)
 {
-	register_driver(&netx_serial_driver);
+	platform_driver_register(&netx_serial_driver);
 	return 0;
 }
 
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 36d39cd..5252518 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -270,11 +270,11 @@ static struct driver_d ns16550_serial_driver = {
 /**
  * @brief driver initialization function
  *
- * @return result of register_driver
+ * @return result of platform_driver_register
  */
 static int ns16550_serial_init(void)
 {
-	return register_driver(&ns16550_serial_driver);
+	return platform_driver_register(&ns16550_serial_driver);
 }
 
 console_initcall(ns16550_serial_init);
diff --git a/drivers/serial/serial_pl010.c b/drivers/serial/serial_pl010.c
index 9f7b7d3..6dc2bd3 100644
--- a/drivers/serial/serial_pl010.c
+++ b/drivers/serial/serial_pl010.c
@@ -165,7 +165,7 @@ static struct driver_d pl010_driver = {
 
 static int pl010_init(void)
 {
-	register_driver(&pl010_driver);
+	platform_driver_register(&pl010_driver);
 
 	return 0;
 }
diff --git a/drivers/serial/serial_s3c24x0.c b/drivers/serial/serial_s3c24x0.c
index 21bca12..cf45f76 100644
--- a/drivers/serial/serial_s3c24x0.c
+++ b/drivers/serial/serial_s3c24x0.c
@@ -163,7 +163,7 @@ static struct driver_d s3c24x0_serial_driver = {
 
 static int s3c24x0_serial_init(void)
 {
-	register_driver(&s3c24x0_serial_driver);
+	platform_driver_register(&s3c24x0_serial_driver);
 	return 0;
 }
 
diff --git a/drivers/serial/stm-serial.c b/drivers/serial/stm-serial.c
index 4264345..e992ea1 100644
--- a/drivers/serial/stm-serial.c
+++ b/drivers/serial/stm-serial.c
@@ -190,7 +190,7 @@ static struct driver_d stm_serial_driver = {
 
 static int stm_serial_init(void)
 {
-	register_driver(&stm_serial_driver);
+	platform_driver_register(&stm_serial_driver);
 	return 0;
 }
 
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index 0e2ea7e..3eb6455 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -356,7 +356,7 @@ static struct driver_d imx_spi_driver = {
 
 static int imx_spi_init(void)
 {
-	register_driver(&imx_spi_driver);
+	platform_driver_register(&imx_spi_driver);
 	return 0;
 }
 
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index b561f9d..d77162c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -80,7 +80,7 @@ struct spi_device *spi_new_device(struct spi_master *master,
 	strcpy(proxy->dev.name, chip->name);
 	proxy->dev.type_data = proxy;
 	dev_add_child(master->dev, &proxy->dev);
-	status = register_device(&proxy->dev);
+	status = platform_device_register(&proxy->dev);
 
 	/* drivers may modify this initial i/o setup */
 	status = master->setup(proxy);
@@ -93,7 +93,7 @@ struct spi_device *spi_new_device(struct spi_master *master,
 	return proxy;
 
 fail:
-	unregister_device(&proxy->dev);
+	platform_device_unregister(&proxy->dev);
 	free(proxy);
 	return NULL;
 }
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index b01a797..271ee9f 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -427,7 +427,7 @@ static int usb_new_device(struct usb_device *dev)
 
 	print_usb_device(dev);
 
-	register_device(&dev->dev);
+	platform_device_register(&dev->dev);
 	list_add_tail(&dev->list, &usb_device_list);
 
 	return 0;
@@ -457,7 +457,7 @@ void usb_rescan(void)
 
 	list_for_each_entry_safe(dev, tmp, &usb_device_list, list) {
 		list_del(&dev->list);
-		unregister_device(&dev->dev);
+		platform_device_unregister(&dev->dev);
 		if (dev->hub)
 			free(dev->hub);
 		free(dev);
@@ -1273,7 +1273,7 @@ static int usb_hub_probe(struct usb_device *dev, int ifnum)
 int usb_driver_register(struct usb_driver *drv)
 {
 	drv->driver.bus = &usb_bus_type;
-	return register_driver(&drv->driver);
+	return platform_driver_register(&drv->driver);
 }
 
 /* returns 0 if no match, 1 if match */
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index fd70e62..b21e87e 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1004,7 +1004,7 @@ int usb_composite_register(struct usb_composite_driver *driver)
 	composite_driver.function =  (char *) driver->name;
 	composite = driver;
 
-	return usb_gadget_register_driver(&composite_driver);
+	return usb_gadget_platform_driver_register(&composite_driver);
 }
 
 /**
@@ -1018,5 +1018,5 @@ void usb_composite_unregister(struct usb_composite_driver *driver)
 {
 	if (composite != driver)
 		return;
-	usb_gadget_unregister_driver(&composite_driver);
+	usb_gadget_unplatform_driver_register(&composite_driver);
 }
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index 1e4d4b0..2a512b8 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -1977,7 +1977,7 @@ int usb_gadget_poll(void)
  * Hook to gadget drivers
  * Called by initialization code of gadget drivers
 *----------------------------------------------------------------*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_platform_driver_register(struct usb_gadget_driver *driver)
 {
 	int retval = -ENODEV;
 
@@ -2016,10 +2016,10 @@ out:
 		       retval);
 	return retval;
 }
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_platform_driver_register);
 
 /* Disconnect from gadget driver */
-int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
+int usb_gadget_unplatform_driver_register(struct usb_gadget_driver *driver)
 {
 	struct fsl_ep *loop_ep;
 
@@ -2053,7 +2053,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 
 	return 0;
 }
-EXPORT_SYMBOL(usb_gadget_unregister_driver);
+EXPORT_SYMBOL(usb_gadget_unplatform_driver_register);
 
 static int struct_udc_setup(struct fsl_udc *udc,
 		struct device_d *dev)
@@ -2305,7 +2305,7 @@ static struct driver_d fsl_udc_driver = {
 
 static int fsl_udc_init(void)
 {
-	register_driver(&fsl_udc_driver);
+	platform_driver_register(&fsl_udc_driver);
 	return 0;
 }
 
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 60fc181..5e027d2 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -950,7 +950,7 @@ static struct driver_d ehci_driver = {
 
 static int ehcil_init(void)
 {
-	register_driver(&ehci_driver);
+	platform_driver_register(&ehci_driver);
 	return 0;
 }
 
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 0be465f..6ce10d1 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -125,7 +125,7 @@ int register_framebuffer(struct fb_info *info)
 
 	sprintf(dev->name, "fb");
 
-	register_device(&info->dev);
+	platform_device_register(&info->dev);
 	dev_add_param(dev, "enable", fb_enable_set, NULL, 0);
 	dev_set_param(dev, "enable", "0");
 
@@ -173,7 +173,7 @@ static struct driver_d fb_driver = {
 
 static int fb_init_driver(void)
 {
-	register_driver(&fb_driver);
+	platform_driver_register(&fb_driver);
 	return 0;
 }
 device_initcall(fb_init_driver);
diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c
index 5ae8c4b..c4f1227 100644
--- a/drivers/video/imx-ipu-fb.c
+++ b/drivers/video/imx-ipu-fb.c
@@ -903,7 +903,7 @@ static struct driver_d imx3fb_driver = {
 
 static int imx3fb_init(void)
 {
-	return register_driver(&imx3fb_driver);
+	return platform_driver_register(&imx3fb_driver);
 }
 
 device_initcall(imx3fb_init);
diff --git a/drivers/video/imx.c b/drivers/video/imx.c
index c19e83e..6c8bd73 100644
--- a/drivers/video/imx.c
+++ b/drivers/video/imx.c
@@ -594,7 +594,7 @@ static struct driver_d imxfb_driver = {
 
 static int imxfb_init(void)
 {
-	return register_driver(&imxfb_driver);
+	return platform_driver_register(&imxfb_driver);
 }
 
 device_initcall(imxfb_init);
diff --git a/drivers/video/s3c.c b/drivers/video/s3c.c
index d079fde..7eb7533 100644
--- a/drivers/video/s3c.c
+++ b/drivers/video/s3c.c
@@ -415,7 +415,7 @@ static struct driver_d s3cfb_driver = {
 
 static int s3cfb_init(void)
 {
-	return register_driver(&s3cfb_driver);
+	return platform_driver_register(&s3cfb_driver);
 }
 
 device_initcall(s3cfb_init);
diff --git a/drivers/video/stm.c b/drivers/video/stm.c
index 78acad7..b9205bc 100644
--- a/drivers/video/stm.c
+++ b/drivers/video/stm.c
@@ -519,7 +519,7 @@ static struct driver_d stmfb_driver = {
 
 static int stmfb_init(void)
 {
-	return register_driver(&stmfb_driver);
+	return platform_driver_register(&stmfb_driver);
 }
 
 device_initcall(stmfb_init);
diff --git a/fs/fs.c b/fs/fs.c
index 7d65ec8..b4900a2 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -716,7 +716,7 @@ static LIST_HEAD(fs_driver_list);
 int register_fs_driver(struct fs_driver_d *fsdrv)
 {
 	list_add_tail(&fsdrv->list, &fs_driver_list);
-	register_driver(&fsdrv->drv);
+	platform_driver_register(&fsdrv->drv);
 	return 0;
 }
 EXPORT_SYMBOL(register_fs_driver);
@@ -787,7 +787,7 @@ int mount(const char *device, const char *fsname, const char *_path)
 	fsdev->dev.type_data = fsdev;
 	fsdev->dev.id = get_free_deviceid(fsdev->dev.name);
 
-	if ((ret = register_device(&fsdev->dev))) {
+	if ((ret = platform_device_register(&fsdev->dev))) {
 		errno = ret;
 		goto out1;
 	}
@@ -824,7 +824,7 @@ int mount(const char *device, const char *fsname, const char *_path)
 	return 0;
 
 out2:
-	unregister_device(&fsdev->dev);
+	platform_device_unregister(&fsdev->dev);
 out1:
 	if (fsdev->backingstore)
 		free(fsdev->backingstore);
@@ -859,7 +859,7 @@ int umount(const char *pathname)
 	else
 		last->next = entry->next;
 
-	unregister_device(entry->dev);
+	platform_device_unregister(entry->dev);
 	fsdev = entry->dev->type_data;
 	free(fsdev->backingstore);
 	free(fsdev);
diff --git a/include/driver.h b/include/driver.h
index c122cf2..c3da162 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -143,6 +143,14 @@ int register_device(struct device_d *);
  */
 int unregister_device(struct device_d *);
 
+int platform_driver_register(struct driver_d *);
+int platform_device_register(struct device_d *);
+
+static inline int platform_device_unregister(struct device_d *dev)
+{
+	return unregister_device(dev);
+}
+
 /* Organize devices in a tree. These functions do _not_ register or
  * unregister a device. Only registered devices are allowed here.
  */
diff --git a/net/eth.c b/net/eth.c
index 406a4e6..0527c91 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -203,7 +203,7 @@ int eth_register(struct eth_device *edev)
 	if (edev->parent)
 		dev_add_child(edev->parent, &edev->dev);
 
-	register_device(&edev->dev);
+	platform_device_register(&edev->dev);
 
 	dev->type_data = edev;
 	dev_add_param(dev, "ipaddr", eth_set_ipaddr, NULL, 0);
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 5/7] mci: parent fixups
  2011-08-15  8:46 ` [PATCH 5/7] mci: parent fixups Sascha Hauer
@ 2011-08-16 15:39   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 19+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-08-16 15:39 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 10:46 Mon 15 Aug     , Sascha Hauer wrote:
> Make the mci host a child of the hardware device and the disk
> a child of the mci host.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/mci/atmel_mci.c  |    1 +
>  drivers/mci/imx-esdhc.c  |    1 +
>  drivers/mci/imx.c        |    1 +
>  drivers/mci/mci-core.c   |    5 ++++-
>  drivers/mci/omap_hsmmc.c |    1 +
>  5 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c
> index b4489dd..47e3924 100644
> --- a/drivers/mci/atmel_mci.c
> +++ b/drivers/mci/atmel_mci.c
> @@ -449,6 +449,7 @@ static int mci_probe(struct device_d *hw_dev)
>  	host->mci.send_cmd = mci_request;
>  	host->mci.set_ios = mci_set_ios;
>  	host->mci.init = mci_reset;
> +	host->mci.hw_dev = dev;
it's hw_dev here

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/4] add bus registration support
  2011-08-16  5:36 ` [PATCH 2/4] add bus registration support Jean-Christophe PLAGNIOL-VILLARD
@ 2011-08-18  5:14   ` Sascha Hauer
  0 siblings, 0 replies; 19+ messages in thread
From: Sascha Hauer @ 2011-08-18  5:14 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Tue, Aug 16, 2011 at 07:36:05AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  drivers/base/Makefile |    1 +
>  drivers/base/bus.c    |   69 +++++++++++++++++++++++++++++++++++++++++++++++++
>  include/driver.h      |   17 ++++++++++++
>  3 files changed, 87 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/base/bus.c
> 
> diff --git a/drivers/base/Makefile b/drivers/base/Makefile
> index 957ca5a..5f19d4d 100644
> --- a/drivers/base/Makefile
> +++ b/drivers/base/Makefile
> @@ -1,3 +1,4 @@
>  obj-y	+= driver.o
> +obj-y	+= bus.o
>  obj-y	+= platform.o
>  obj-y	+= resource.o
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> new file mode 100644
> index 0000000..b124ab0
> --- /dev/null
> +++ b/drivers/base/bus.c
> @@ -0,0 +1,69 @@
> +/*
> + * Copyright (c) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + */
> +#include <common.h>
> +#include <driver.h>
> +
> +static int bus_match(struct device_d *dev, struct driver_d *drv)
> +{
> +	return strcmp(dev->name, drv->name) ? -1 : 0;
> +}
> +
> +static int bus_probe(struct device_d *dev)
> +{
> +	if (dev->driver->probe)
> +		return dev->driver->probe(dev);
> +	return 0;
> +}
> +
> +static void bus_remove(struct device_d *dev)
> +{
> +	if (dev->driver->remove)
> +		dev->driver->remove(dev);
> +}
> +
> +struct bus_type bus_bus = {
> +	.name = "bus",
> +	.match = bus_match,
> +	.probe = bus_probe,
> +	.remove = bus_remove,
> +};
> +
> +void bus_for_each_device(struct bus_type *bus,
> +			 void (*fn)(struct device_d *dev))
> +{
> +	struct device_d *dev;
> +
> +	for_each_device(dev) {
> +		if (dev->bus == bus)
> +			fn(dev);
> +	}
> +}
> +
> +int register_bus_driver(struct driver_d *drv)
> +{
> +	drv->bus = &bus_bus;
> +	return register_driver(drv);
> +}
> +
> +int register_bus_device(struct device_d *dev)
> +{
> +	dev->bus = &bus_bus;
> +	return register_device(dev);
> +}

This is an absolutely artificial abstraction we do not need. You can
register a device which is really a bus, a usb hub would fall into
this category. But a usb hub is a device of its own which happens
to register other devices. Even the name "struct bus_type bus_bus" shows
that there is something wrong here.

> diff --git a/include/driver.h b/include/driver.h
> index 0b5a652..ab7424e 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -269,6 +269,23 @@ extern struct list_head driver_list;
>   */
>  #define for_each_device(dev) list_for_each_entry(dev, &device_list, list)
>  
> +
> +int register_bus_driver(struct driver_d *drv);
> +int register_bus_device(struct device_d *dev);
> +
> +/* Iterate over all bus device
> + */
> +void bus_for_each_device(struct bus_type *bus,
> +			 void (*fn)(struct device_d *dev));

If you need this it can simply be implemented with a list which collects
all devices on a bus.

> +
> +extern struct bus_type bus_bus;
> +/* Iterate over all bus
> + */
> +static inline void bus_for_each(void (*fn)(struct device_d *dev))
> +{
> +	bus_for_each_device(&bus_bus, fn);
> +}

This function (which would better be named for_each_bus) can also be
implemented with a list when a bus gets registered. The bus_register
function which adds a bus to a list of busses is even already present
in the tree in drivers/base/platform.c

Sascha

-- 
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] 19+ messages in thread

* Re: [PATCH 1/4] device: update id support to allow device without id
  2011-08-16  5:36 ` [PATCH 1/4] device: update id support to allow device without id Jean-Christophe PLAGNIOL-VILLARD
@ 2011-08-18  5:26   ` Sascha Hauer
  2011-08-18  6:27     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 19+ messages in thread
From: Sascha Hauer @ 2011-08-18  5:26 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Tue, Aug 16, 2011 at 07:36:04AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> as in linux use -1 for this
> 
> as example on bus we may have only one device so no need to have
> devname<number>
> 
> for automatic id use -2 now
> udpate all the device that use -1 to -2
> 
> device that really want -1 will have to update later
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c
> index 44ac44b..0d26da9 100644
> --- a/arch/arm/boards/a9m2410/a9m2410.c
> +++ b/arch/arm/boards/a9m2410/a9m2410.c
> @@ -131,14 +131,14 @@ static int a9m2410_devices_init(void)
>  	writel(reg, MISCCR);
>  
>  	/* ----------- the devices the boot loader should work with -------- */
> -	add_generic_device("s3c24x0_nand", -1, NULL, S3C24X0_NAND_BASE, 0,
> +	add_generic_device("s3c24x0_nand", -2, NULL, S3C24X0_NAND_BASE, 0,
>  			   IORESOURCE_MEM, &nand_info);

-1 has a special meaning without being a define, but we should not
introduce another arbitrary numbered special meaning.

But I don't think we want this anyway. In a later patch you convert
all drivers/devices to platform_*_register without having a
platform_device. If we want to go this way we should go it all the
way and have a struct platform_device which embeds a struct device_d.
The 'id' field would then be a part of the platform_device rather
than the device itself.
The 'id' field is only present because we have no better way of
numbering the instances of devices on a platform bus. With PCI/USB
devices this numbering would come from the position on the bus.

Sascha

-- 
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] 19+ messages in thread

* Re: [PATCH 1/4] device: update id support to allow device without id
  2011-08-18  5:26   ` Sascha Hauer
@ 2011-08-18  6:27     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 19+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-08-18  6:27 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 07:26 Thu 18 Aug     , Sascha Hauer wrote:
> On Tue, Aug 16, 2011 at 07:36:04AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > as in linux use -1 for this
> > 
> > as example on bus we may have only one device so no need to have
> > devname<number>
> > 
> > for automatic id use -2 now
> > udpate all the device that use -1 to -2
> > 
> > device that really want -1 will have to update later
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> > diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c
> > index 44ac44b..0d26da9 100644
> > --- a/arch/arm/boards/a9m2410/a9m2410.c
> > +++ b/arch/arm/boards/a9m2410/a9m2410.c
> > @@ -131,14 +131,14 @@ static int a9m2410_devices_init(void)
> >  	writel(reg, MISCCR);
> >  
> >  	/* ----------- the devices the boot loader should work with -------- */
> > -	add_generic_device("s3c24x0_nand", -1, NULL, S3C24X0_NAND_BASE, 0,
> > +	add_generic_device("s3c24x0_nand", -2, NULL, S3C24X0_NAND_BASE, 0,
> >  			   IORESOURCE_MEM, &nand_info);
> 
> -1 has a special meaning without being a define, but we should not
> introduce another arbitrary numbered special meaning.
we can add a proper define

> 
> But I don't think we want this anyway. In a later patch you convert
> all drivers/devices to platform_*_register without having a
> platform_device. If we want to go this way we should go it all the
> way and have a struct platform_device which embeds a struct device_d.
> The 'id' field would then be a part of the platform_device rather
> than the device itself.
> The 'id' field is only present because we have no better way of
> numbering the instances of devices on a platform bus. With PCI/USB
> devices this numbering would come from the position on the bus.
I chosse to do it in two step for platfrom_device

I first switch everyone to the function and then introduce the new struct
I've not yet finish completly the new struct but it's on its way

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-08-18  6:46 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-15  8:46 [PATCH] parent fixups Sascha Hauer
2011-08-15  8:46 ` [PATCH 1/7] mci: embed mci_dev into mci_host instead of allocating it seperately Sascha Hauer
2011-08-15  8:46 ` [PATCH 2/7] net: make the ethernet device a child of the hardware device Sascha Hauer
2011-08-15  8:46 ` [PATCH 3/7] net mii: add a parent pointer to miidevs and set it to " Sascha Hauer
2011-08-15  8:46 ` [PATCH 4/7] console: make console device a child of " Sascha Hauer
2011-08-15  8:46 ` [PATCH 5/7] mci: parent fixups Sascha Hauer
2011-08-16 15:39   ` Jean-Christophe PLAGNIOL-VILLARD
2011-08-15  8:46 ` [PATCH 6/7] spi: make the spi devices children of the parent bus Sascha Hauer
2011-08-15  8:46 ` [PATCH 7/7] devinfo: beautify output Sascha Hauer
2011-08-15  9:14 ` [PATCH] parent fixups Jean-Christophe PLAGNIOL-VILLARD
2011-08-15 15:50   ` Sascha Hauer
2011-08-16  5:29     ` Jean-Christophe PLAGNIOL-VILLARD
2011-08-16  5:36 ` [PATCH 1/4] device: update id support to allow device without id Jean-Christophe PLAGNIOL-VILLARD
2011-08-18  5:26   ` Sascha Hauer
2011-08-18  6:27     ` Jean-Christophe PLAGNIOL-VILLARD
2011-08-16  5:36 ` [PATCH 2/4] add bus registration support Jean-Christophe PLAGNIOL-VILLARD
2011-08-18  5:14   ` Sascha Hauer
2011-08-16  5:36 ` [PATCH 3/4] platform_bus: add registrattion to bus Jean-Christophe PLAGNIOL-VILLARD
2011-08-16  5:36 ` [PATCH 4/4] switch all device/driver to platform_device/driver_(un)register Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox