mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] detect environment device on some boards
@ 2013-06-26  7:33 Sascha Hauer
  2013-06-26  7:33 ` [PATCH 1/4] driver: implement device_detect_by_name function Sascha Hauer
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sascha Hauer @ 2013-06-26  7:33 UTC (permalink / raw)
  To: barebox

Using 'detect' on the environment device allows us to disable
CONFIG_MCI_STARTUP. This speeds up the startup since unnecessary
SD/MMC cards are no longer probed.

Sascha

----------------------------------------------------------------
Sascha Hauer (4):
      driver: implement device_detect_by_name function
      ARM: i.MX51 efikasb: detect environment device
      ARM: i.MX51 babbage: detect environment device
      ARM: i.MX: use device_detect_by_name where applicable

 arch/arm/boards/dmo-mx6-realq7/board.c      |  6 +-----
 arch/arm/boards/efika-mx-smartbook/board.c  |  2 ++
 arch/arm/boards/freescale-mx51-pdk/board.c  |  2 ++
 arch/arm/boards/freescale-mx53-loco/board.c |  4 +---
 drivers/base/driver.c                       | 10 ++++++++++
 include/driver.h                            |  1 +
 6 files changed, 17 insertions(+), 8 deletions(-)

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

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

* [PATCH 1/4] driver: implement device_detect_by_name function
  2013-06-26  7:33 [PATCH] detect environment device on some boards Sascha Hauer
@ 2013-06-26  7:33 ` Sascha Hauer
  2013-06-26  7:33 ` [PATCH 2/4] ARM: i.MX51 efikasb: detect environment device Sascha Hauer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2013-06-26  7:33 UTC (permalink / raw)
  To: barebox

It becomes a common pattern for boards to find a device and
call device_detect on it. Add a convenience wrapper for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/base/driver.c | 10 ++++++++++
 include/driver.h      |  1 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 810d001..16b7f06 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -100,6 +100,16 @@ int device_detect(struct device_d *dev)
 	return dev->detect(dev);
 }
 
+int device_detect_by_name(const char *devname)
+{
+	struct device_d *dev = get_device_by_name(devname);
+
+	if (!dev)
+		return -ENODEV;
+
+	return device_detect(dev);
+}
+
 static int match(struct driver_d *drv, struct device_d *dev)
 {
 	int ret;
diff --git a/include/driver.h b/include/driver.h
index 8b3af4d..b18318f 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -159,6 +159,7 @@ int device_probe(struct device_d *dev);
 
 /* detect devices attached to this device (cards, disks,...) */
 int device_detect(struct device_d *dev);
+int device_detect_by_name(const char *devname);
 
 /* Unregister a device. This function can fail, e.g. when the device
  * has children.
-- 
1.8.3.1


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

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

* [PATCH 2/4] ARM: i.MX51 efikasb: detect environment device
  2013-06-26  7:33 [PATCH] detect environment device on some boards Sascha Hauer
  2013-06-26  7:33 ` [PATCH 1/4] driver: implement device_detect_by_name function Sascha Hauer
@ 2013-06-26  7:33 ` Sascha Hauer
  2013-06-26  7:33 ` [PATCH 3/4] ARM: i.MX51 babbage: " Sascha Hauer
  2013-06-26  7:33 ` [PATCH 4/4] ARM: i.MX: use device_detect_by_name where applicable Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2013-06-26  7:33 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/efika-mx-smartbook/board.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boards/efika-mx-smartbook/board.c b/arch/arm/boards/efika-mx-smartbook/board.c
index 11f222e..0e6694b 100644
--- a/arch/arm/boards/efika-mx-smartbook/board.c
+++ b/arch/arm/boards/efika-mx-smartbook/board.c
@@ -252,6 +252,8 @@ static int efikamx_late_init(void)
 
 	switch (bootsource) {
 	case BOOTSOURCE_MMC:
+		device_detect_by_name("mmc1");
+
 		devfs_add_partition("mmc1", 0x00000, 0x80000,
 				DEVFS_PARTITION_FIXED, "self0");
 		devfs_add_partition("mmc1", 0x80000, 0x80000,
-- 
1.8.3.1


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

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

* [PATCH 3/4] ARM: i.MX51 babbage: detect environment device
  2013-06-26  7:33 [PATCH] detect environment device on some boards Sascha Hauer
  2013-06-26  7:33 ` [PATCH 1/4] driver: implement device_detect_by_name function Sascha Hauer
  2013-06-26  7:33 ` [PATCH 2/4] ARM: i.MX51 efikasb: detect environment device Sascha Hauer
@ 2013-06-26  7:33 ` Sascha Hauer
  2013-06-26  7:33 ` [PATCH 4/4] ARM: i.MX: use device_detect_by_name where applicable Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2013-06-26  7:33 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/freescale-mx51-pdk/board.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boards/freescale-mx51-pdk/board.c b/arch/arm/boards/freescale-mx51-pdk/board.c
index 6807796..fc7e175 100644
--- a/arch/arm/boards/freescale-mx51-pdk/board.c
+++ b/arch/arm/boards/freescale-mx51-pdk/board.c
@@ -181,6 +181,8 @@ device_initcall(f3s_devices_init);
 
 static int f3s_part_init(void)
 {
+	device_detect_by_name("mmc0");
+
 	devfs_add_partition("mmc0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0");
 	devfs_add_partition("mmc0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
 
-- 
1.8.3.1


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

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

* [PATCH 4/4] ARM: i.MX: use device_detect_by_name where applicable
  2013-06-26  7:33 [PATCH] detect environment device on some boards Sascha Hauer
                   ` (2 preceding siblings ...)
  2013-06-26  7:33 ` [PATCH 3/4] ARM: i.MX51 babbage: " Sascha Hauer
@ 2013-06-26  7:33 ` Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2013-06-26  7:33 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/dmo-mx6-realq7/board.c      | 6 +-----
 arch/arm/boards/freescale-mx53-loco/board.c | 4 +---
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boards/dmo-mx6-realq7/board.c b/arch/arm/boards/dmo-mx6-realq7/board.c
index b2a27a4..7983b88 100644
--- a/arch/arm/boards/dmo-mx6-realq7/board.c
+++ b/arch/arm/boards/dmo-mx6-realq7/board.c
@@ -117,11 +117,7 @@ static int realq7_env_init(void)
 {
 	switch (bootsource_get()) {
 	case BOOTSOURCE_MMC:
-		if (!IS_ENABLED(CONFIG_MCI_STARTUP)) {
-			struct device_d *dev = get_device_by_name("mmc3");
-			if (dev)
-				device_detect(dev);
-		}
+		device_detect_by_name("mmc3");
 		devfs_add_partition("mmc3", 0, SZ_1M, DEVFS_PARTITION_FIXED, "mmc3.barebox");
 		devfs_add_partition("mmc3", SZ_1M, SZ_1M, DEVFS_PARTITION_FIXED, "mmc3.bareboxenv");
 		default_environment_path = "/dev/mmc3.bareboxenv";
diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
index 2f51128..aaf5db4 100644
--- a/arch/arm/boards/freescale-mx53-loco/board.c
+++ b/arch/arm/boards/freescale-mx53-loco/board.c
@@ -81,12 +81,10 @@ static void loco_fec_reset(void)
 
 static int loco_late_init(void)
 {
-	struct device_d *dev = get_device_by_name("mmc0");
 	struct mc34708 *mc34708;
 	int rev;
 
-	if (dev)
-		device_detect(dev);
+	device_detect_by_name("mmc0");
 
 	devfs_add_partition("mmc0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
 
-- 
1.8.3.1


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

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

end of thread, other threads:[~2013-06-26  7:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-26  7:33 [PATCH] detect environment device on some boards Sascha Hauer
2013-06-26  7:33 ` [PATCH 1/4] driver: implement device_detect_by_name function Sascha Hauer
2013-06-26  7:33 ` [PATCH 2/4] ARM: i.MX51 efikasb: detect environment device Sascha Hauer
2013-06-26  7:33 ` [PATCH 3/4] ARM: i.MX51 babbage: " Sascha Hauer
2013-06-26  7:33 ` [PATCH 4/4] ARM: i.MX: use device_detect_by_name where applicable Sascha Hauer

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