Index: share/man/man9/device_set_rebiddable.9 =================================================================== --- share/man/man9/device_set_rebiddable.9 +++ share/man/man9/device_set_rebiddable.9 @@ -0,0 +1,78 @@ +.\" -*- nroff -*- +.\" +.\" Copyright (c) 2014 Ian Lepore +.\" +.\" All rights reserved. +.\" +.\" This program is free software. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd October 15, 2014 +.Dt DEVICE_SET_REBIDDABLE 9 +.Os +.Sh NAME +.Nm device_set_rebiddable +.Nd indicate willingness to be outbid for a device after initially claiming it +.Sh SYNOPSIS +.In sys/param.h +.In sys/bus.h +.Ft void +.Fn device_set_rebiddable "device_t dev" +.Sh DESCRIPTION +Device probing and attaching happens in a series of passes during +system initialization, and also when a new driver module is loaded. +Within a pass, the +.Xr DEVICE_PROBE 9 +method of each suitable driver for a device is called to bid for +control of the device using numeric return codes. +At the end of a pass, control of the device is given to the winning +bidder by calling that driver's +.Xr DEVICE_ATTACH 9 +method. +Once a driver has been attached to a device, that device is normally +not ever probed again. +.Pp +A driver can indicate its willingness to have a device it claimed +re-probed on later passes or when new drivers are loaded by calling +.Fn device_set_rebiddable . +The +.Xr DEVICE_PROBE 9 +method of the driver currently attached to the device is called again +during the re-bidding process along with the probe methods of all +other suitable drivers. +If another driver wins the bidding during the re-probe, the +.Xr DEVICE_DETACH 9 +method of the current driver is called before attaching the new driver. +.Pp +The +.Xr DEVICE_PROBE 9 +method of a rebiddable driver may be called at any time, including +while the driver is attached to the device. +The probing process must be idempotent and must not perturb the +current state of the device. +.Sh SEE ALSO +.Xr device 9 +.Sh AUTHORS +This manual page was written by +.An Ian Lepore . Index: sys/kern/subr_bus.c =================================================================== --- sys/kern/subr_bus.c +++ sys/kern/subr_bus.c @@ -2192,9 +2192,6 @@ * sure that we have the right description. */ DEVICE_PROBE(child); -#if 0 - child->flags |= DF_REBID; -#endif } else child->flags &= ~DF_REBID; child->state = DS_ALIVE; @@ -2588,6 +2585,15 @@ } /** + * @brief Set the DF_REBID flag for the device + */ +void +device_set_rebiddable(device_t dev) +{ + dev->flags |= DF_REBID; +} + +/** * @brief Set the DF_QUIET flag for the device */ void Index: sys/sys/bus.h =================================================================== --- sys/sys/bus.h +++ sys/sys/bus.h @@ -466,6 +466,7 @@ int device_set_devclass(device_t dev, const char *classname); int device_set_driver(device_t dev, driver_t *driver); void device_set_flags(device_t dev, u_int32_t flags); +void device_set_rebiddable(device_t dev); void device_set_softc(device_t dev, void *softc); void device_free_softc(void *softc); void device_claim_softc(device_t dev);