subr_bus.c (138533) | subr_bus.c (139507) |
---|---|
1/*- 2 * Copyright (c) 1997,1998,2003 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997,1998,2003 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/subr_bus.c 138533 2004-12-08 02:39:56Z njl $"); | 28__FBSDID("$FreeBSD: head/sys/kern/subr_bus.c 139507 2004-12-31 20:47:51Z imp $"); |
29 30#include "opt_bus.h" 31 32#define __RMAN_RESOURCE_VISIBLE 33#include <sys/param.h> 34#include <sys/conf.h> 35#include <sys/filio.h> 36#include <sys/lock.h> --- 906 unchanged lines hidden (view full) --- 943 if (driver->refs == 0) 944 kobj_class_free((kobj_class_t) driver); 945 946 bus_data_generation_update(); 947 return (0); 948} 949 950/** | 29 30#include "opt_bus.h" 31 32#define __RMAN_RESOURCE_VISIBLE 33#include <sys/param.h> 34#include <sys/conf.h> 35#include <sys/filio.h> 36#include <sys/lock.h> --- 906 unchanged lines hidden (view full) --- 943 if (driver->refs == 0) 944 kobj_class_free((kobj_class_t) driver); 945 946 bus_data_generation_update(); 947 return (0); 948} 949 950/** |
951 * @brief Quiesces a set of device drivers from a device class 952 * 953 * Quiesce a device driver from a devclass. This is normally called 954 * automatically by DRIVER_MODULE(). 955 * 956 * If the driver is currently attached to any devices, 957 * devclass_quiesece_driver() will first attempt to quiesce each 958 * device. 959 * 960 * @param dc the devclass to edit 961 * @param driver the driver to unregister 962 */ 963int 964devclass_quiesce_driver(devclass_t busclass, driver_t *driver) 965{ 966 devclass_t dc = devclass_find(driver->name); 967 driverlink_t dl; 968 device_t dev; 969 int i; 970 int error; 971 972 PDEBUG(("%s from devclass %s", driver->name, DEVCLANAME(busclass))); 973 974 if (!dc) 975 return (0); 976 977 /* 978 * Find the link structure in the bus' list of drivers. 979 */ 980 TAILQ_FOREACH(dl, &busclass->drivers, link) { 981 if (dl->driver == driver) 982 break; 983 } 984 985 if (!dl) { 986 PDEBUG(("%s not found in %s list", driver->name, 987 busclass->name)); 988 return (ENOENT); 989 } 990 991 /* 992 * Quiesce all devices. We iterate through all the devices in 993 * the devclass of the driver and quiesce any which are using 994 * the driver and which have a parent in the devclass which we 995 * are quiescing. 996 * 997 * Note that since a driver can be in multiple devclasses, we 998 * should not quiesce devices which are not children of 999 * devices in the affected devclass. 1000 */ 1001 for (i = 0; i < dc->maxunit; i++) { 1002 if (dc->devices[i]) { 1003 dev = dc->devices[i]; 1004 if (dev->driver == driver && dev->parent && 1005 dev->parent->devclass == busclass) { 1006 if ((error = device_quiesce(dev)) != 0) 1007 return (error); 1008 } 1009 } 1010 } 1011 1012 return (0); 1013} 1014 1015/** |
|
951 * @internal 952 */ 953static driverlink_t 954devclass_find_driver_internal(devclass_t dc, const char *classname) 955{ 956 driverlink_t dl; 957 958 PDEBUG(("%s in devclass %s", classname, DEVCLANAME(dc))); --- 1350 unchanged lines hidden (view full) --- 2309 device_set_driver(dev, NULL); 2310 device_set_desc(dev, NULL); 2311 device_sysctl_fini(dev); 2312 2313 return (0); 2314} 2315 2316/** | 1016 * @internal 1017 */ 1018static driverlink_t 1019devclass_find_driver_internal(devclass_t dc, const char *classname) 1020{ 1021 driverlink_t dl; 1022 1023 PDEBUG(("%s in devclass %s", classname, DEVCLANAME(dc))); --- 1350 unchanged lines hidden (view full) --- 2374 device_set_driver(dev, NULL); 2375 device_set_desc(dev, NULL); 2376 device_sysctl_fini(dev); 2377 2378 return (0); 2379} 2380 2381/** |
2382 * @brief Tells a driver to quiesce itself. 2383 * 2384 * This function is a wrapper around the DEVICE_QUIESCE() driver 2385 * method. If the call to DEVICE_QUIESCE() succeeds. 2386 * 2387 * @param dev the device to quiesce 2388 * 2389 * @retval 0 success 2390 * @retval ENXIO no driver was found 2391 * @retval ENOMEM memory allocation failure 2392 * @retval non-zero some other unix error code 2393 */ 2394int 2395device_quiesce(device_t dev) 2396{ 2397 2398 PDEBUG(("%s", DEVICENAME(dev))); 2399 if (dev->state == DS_BUSY) 2400 return (EBUSY); 2401 if (dev->state != DS_ATTACHED) 2402 return (0); 2403 2404 return (DEVICE_QUIESCE(dev)); 2405} 2406 2407/** |
|
2317 * @brief Notify a device of system shutdown 2318 * 2319 * This function calls the DEVICE_SHUTDOWN() driver method if the 2320 * device currently has an attached driver. 2321 * 2322 * @returns the value returned by DEVICE_SHUTDOWN() 2323 */ 2324int --- 1234 unchanged lines hidden (view full) --- 3559 DRIVERNAME(dmd->dmd_driver), 3560 dmd->dmd_busname)); 3561 error = devclass_delete_driver(bus_devclass, 3562 dmd->dmd_driver); 3563 3564 if (!error && dmd->dmd_chainevh) 3565 error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg); 3566 break; | 2408 * @brief Notify a device of system shutdown 2409 * 2410 * This function calls the DEVICE_SHUTDOWN() driver method if the 2411 * device currently has an attached driver. 2412 * 2413 * @returns the value returned by DEVICE_SHUTDOWN() 2414 */ 2415int --- 1234 unchanged lines hidden (view full) --- 3650 DRIVERNAME(dmd->dmd_driver), 3651 dmd->dmd_busname)); 3652 error = devclass_delete_driver(bus_devclass, 3653 dmd->dmd_driver); 3654 3655 if (!error && dmd->dmd_chainevh) 3656 error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg); 3657 break; |
3658 case MOD_QUIESCE: 3659 PDEBUG(("Quiesce module: driver %s from bus %s", 3660 DRIVERNAME(dmd->dmd_driver), 3661 dmd->dmd_busname)); 3662 error = devclass_quiesce_driver(bus_devclass, 3663 dmd->dmd_driver); 3664 3665 if (!error && dmd->dmd_chainevh) 3666 error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg); 3667 break; |
|
3567 default: 3568 error = EOPNOTSUPP; 3569 break; 3570 } 3571 3572 return (error); 3573} 3574 --- 344 unchanged lines hidden --- | 3668 default: 3669 error = EOPNOTSUPP; 3670 break; 3671 } 3672 3673 return (error); 3674} 3675 --- 344 unchanged lines hidden --- |