FreeBSD/sys/kern/subr_bus.c
/**
 * @brief Module handler for registering device drivers
 *
 * This module handler is used to automatically register device
 * drivers when modules are loaded. If @p what is MOD_LOAD, it calls
 * devclass_add_driver() for the driver described by the
 * driver_module_data structure pointed to by @p arg
 */
@brief Module handler for registering device drivers
This module handler is used to automatically register device
drivers when modules are loaded. If @p what is MOD_LOAD, it calls
devclass_add_driver() for the driver described by the
driver_module_data structure pointed to by @p arg
@brief Module handler for registering device drivers This module handler is used to automatically register device drivers when modules are loaded . If @p what is MOD_LOAD it calls devclass_add_driver () for the driver described by the driver_module_data structure pointed to by @p arg
int
driver_module_handler(module_t mod, int what, void *arg)
{
	struct driver_module_data *dmd;
	devclass_t bus_devclass;
	kobj_class_t driver;
	int error, pass;
	dmd = (struct driver_module_data *)arg;
	bus_devclass = devclass_find_internal(dmd->dmd_busname, NULL, TRUE);
	error = 0;
	switch (what) {
	case MOD_LOAD:
		if (dmd->dmd_chainevh)
			error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg);
		pass = dmd->dmd_pass;
		driver = dmd->dmd_driver;
		PDEBUG(("Loading module: driver %s on bus %s (pass %d)",
		    DRIVERNAME(driver), dmd->dmd_busname, pass));
		error = devclass_add_driver(bus_devclass, driver, pass,
		    dmd->dmd_devclass);
		break;
	case MOD_UNLOAD:
		PDEBUG(("Unloading module: driver %s from bus %s",
		    DRIVERNAME(dmd->dmd_driver),
		    dmd->dmd_busname));
		error = devclass_delete_driver(bus_devclass,
		    dmd->dmd_driver);
		if (!error && dmd->dmd_chainevh)
			error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg);
		break;
	case MOD_QUIESCE:
		PDEBUG(("Quiesce module: driver %s from bus %s",
		    DRIVERNAME(dmd->dmd_driver),
		    dmd->dmd_busname));
		error = devclass_quiesce_driver(bus_devclass,
		    dmd->dmd_driver);
		if (!error && dmd->dmd_chainevh)
			error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg);
		break;
	default:
		error = EOPNOTSUPP;
		break;
	}
	return (error);
}
int driver_module_handler ( module_t mod , int what , void * arg ) { struct driver_module_data * dmd ; devclass_t bus_devclass ; kobj_class_t driver ; int error , pass ; dmd = ( struct driver_module_data * ) arg ; bus_devclass = devclass_find_internal ( dmd -> dmd_busname , NULL , TRUE ) ; error = 0 ; switch ( what ) { case MOD_LOAD : if ( dmd -> dmd_chainevh ) error = dmd -> dmd_chainevh ( mod , what , dmd -> dmd_chainarg ) ; pass = dmd -> dmd_pass ; driver = dmd -> dmd_driver ; PDEBUG ( ( " " , DRIVERNAME ( driver ) , dmd -> dmd_busname , pass ) ) ; error = devclass_add_driver ( bus_devclass , driver , pass , dmd -> dmd_devclass ) ; break ; case MOD_UNLOAD : PDEBUG ( ( " " , DRIVERNAME ( dmd -> dmd_driver ) , dmd -> dmd_busname ) ) ; error = devclass_delete_driver ( bus_devclass , dmd -> dmd_driver ) ; if ( ! error && dmd -> dmd_chainevh ) error = dmd -> dmd_chainevh ( mod , what , dmd -> dmd_chainarg ) ; break ; case MOD_QUIESCE : PDEBUG ( ( " " , DRIVERNAME ( dmd -> dmd_driver ) , dmd -> dmd_busname ) ) ; error = devclass_quiesce_driver ( bus_devclass , dmd -> dmd_driver ) ; if ( ! error && dmd -> dmd_chainevh ) error = dmd -> dmd_chainevh ( mod , what , dmd -> dmd_chainarg ) ; break ; default : error = EOPNOTSUPP ; break ; } return ( error ) ; }
@brief Module handler for registering device drivers
 This module handler is used to automatically register device
 drivers when modules are loaded.
@brief Module handler for registering device drivers This module handler is used to automatically register device drivers when modules are loaded .