FreeBSD/sys/kern/subr_bus.c
/**
 * @brief Delete a device driver from a device class
 *
 * Delete a device driver from a devclass. This is normally called
 * automatically by DRIVER_MODULE().
 *
 * If the driver is currently attached to any devices,
 * devclass_delete_driver() will first attempt to detach from each
 * device. If one of the detach calls fails, the driver will not be
 * deleted.
 *
 * @param dc		the devclass to edit
 * @param driver	the driver to unregister
 */
@brief Delete a device driver from a device class
Delete a device driver from a devclass. This is normally called
automatically by DRIVER_MODULE().

If the driver is currently attached to any devices,
devclass_delete_driver() will first attempt to detach from each
device. If one of the detach calls fails, the driver will not be
deleted.

@param dc            the devclass to edit
@param driver        the driver to unregister
@brief Delete a device driver from a device class Delete a device driver from a devclass . This is normally called automatically by DRIVER_MODULE () . If the driver is currently attached to any devices devclass_delete_driver () will first attempt to detach from each device . If one of the detach calls fails the driver will not be deleted . @param dc the devclass to edit @param driver the driver to unregister
int
devclass_delete_driver(devclass_t busclass, driver_t *driver)
{
	devclass_t dc = devclass_find(driver->name);
	driverlink_t dl;
	int error;
	PDEBUG(("%s from devclass %s", driver->name, DEVCLANAME(busclass)));
	if (!dc)
		return (0);
	TAILQ_FOREACH(dl, &busclass->drivers, link) {
		if (dl->driver == driver)
			break;
	}
	if (!dl) {
		PDEBUG(("%s not found in %s list", driver->name,
		    busclass->name));
		return (ENOENT);
	}
	error = devclass_driver_deleted(busclass, dc, driver);
	if (error != 0)
		return (error);
	TAILQ_REMOVE(&busclass->drivers, dl, link);
	free(dl, M_BUS);
	driver->refs--;
	if (driver->refs == 0)
		kobj_class_free((kobj_class_t) driver);
	bus_data_generation_update();
	return (0);
}
int devclass_delete_driver ( devclass_t busclass , driver_t * driver ) { devclass_t dc = devclass_find ( driver -> name ) ; driverlink_t dl ; int error ; PDEBUG ( ( " " , driver -> name , DEVCLANAME ( busclass ) ) ) ; if ( ! dc ) return ( 0 ) ; TAILQ_FOREACH ( dl , & busclass -> drivers , link ) { if ( dl -> driver == driver ) break ; } if ( ! dl ) { PDEBUG ( ( " " , driver -> name , busclass -> name ) ) ; return ( ENOENT ) ; } error = devclass_driver_deleted ( busclass , dc , driver ) ; if ( error != 0 ) return ( error ) ; TAILQ_REMOVE ( & busclass -> drivers , dl , link ) ; free ( dl , M_BUS ) ; driver -> refs -- ; if ( driver -> refs == 0 ) kobj_class_free ( ( kobj_class_t ) driver ) ; bus_data_generation_update ( ) ; return ( 0 ) ; }
@brief Delete a device driver from a device class
 Delete a device driver from a devclass.
@brief Delete a device driver from a device class Delete a device driver from a devclass .
/*
	 * Find the link structure in the bus' list of drivers.
	 */ /* XXX: kobj_mtx */