summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2008-06-20 16:58:15 +0000
committerimp <imp@FreeBSD.org>2008-06-20 16:58:15 +0000
commitbf94b8a5bffc3904edd54af89110562e9fe1a2dc (patch)
tree4633954559142098a8bba2db60e9f815943aeaa2 /sys/kern/subr_bus.c
parentb6db46a0072e174e281590f02a9bf3e41b549338 (diff)
downloadFreeBSD-src-bf94b8a5bffc3904edd54af89110562e9fe1a2dc.zip
FreeBSD-src-bf94b8a5bffc3904edd54af89110562e9fe1a2dc.tar.gz
Split out the probing magic of device_probe_and_attach into
device_probe() so that it can be used by busses that may wish to do additional processing between probe and attach. Reviewed by: dfr@
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 85a7bc7..c623ce2 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -2324,7 +2324,7 @@ device_set_driver(device_t dev, driver_t *driver)
}
/**
- * @brief Probe a device and attach a driver if possible
+ * @brief Probe a device, and return this status.
*
* This function is the core of the device autoconfiguration
* system. Its purpose is to select a suitable driver for a device and
@@ -2348,23 +2348,24 @@ device_set_driver(device_t dev, driver_t *driver)
* @retval ENXIO no driver was found
* @retval ENOMEM memory allocation failure
* @retval non-zero some other unix error code
+ * @retval -1 Device already attached
*/
int
-device_probe_and_attach(device_t dev)
+device_probe(device_t dev)
{
int error;
GIANT_REQUIRED;
if (dev->state >= DS_ALIVE && (dev->flags & DF_REBID) == 0)
- return (0);
+ return (-1);
if (!(dev->flags & DF_ENABLED)) {
if (bootverbose && device_get_name(dev) != NULL) {
device_print_prettyname(dev);
printf("not probed (disabled)\n");
}
- return (0);
+ return (-1);
}
if ((error = device_probe_child(dev->parent, dev)) != 0) {
if (!(dev->flags & DF_DONENOMATCH)) {
@@ -2374,9 +2375,27 @@ device_probe_and_attach(device_t dev)
}
return (error);
}
- error = device_attach(dev);
+ return (0);
+}
- return (error);
+/**
+ * @brief Probe a device and attach a driver if possible
+ *
+ * calls device_probe() and attaches if that was successful.
+ */
+int
+device_probe_and_attach(device_t dev)
+{
+ int error;
+
+ GIANT_REQUIRED;
+
+ error = device_probe(dev);
+ if (error == -1)
+ return (0);
+ else if (error != 0)
+ return (error);
+ return (device_attach(dev));
}
/**
OpenPOWER on IntegriCloud