From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] driver: implement device_detect_by_name function
Date: Wed, 26 Jun 2013 09:33:13 +0200 [thread overview]
Message-ID: <1372231996-1042-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1372231996-1042-1-git-send-email-s.hauer@pengutronix.de>
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
next prev parent reply other threads:[~2013-06-26 7:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-26 7:33 [PATCH] detect environment device on some boards Sascha Hauer
2013-06-26 7:33 ` Sascha Hauer [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372231996-1042-2-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox