MCPcopy Create free account
hub / github.com/F-Stack/f-stack / devclass_delete_driver

Function devclass_delete_driver

freebsd/kern/subr_bus.c:1251–1291  ·  view source on GitHub ↗

* @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 edi

Source from the content-addressed store, hash-verified

1249 * @param driver the driver to unregister
1250 */
1251int
1252devclass_delete_driver(devclass_t busclass, driver_t *driver)
1253{
1254 devclass_t dc = devclass_find(driver->name);
1255 driverlink_t dl;
1256 int error;
1257
1258 PDEBUG(("%s from devclass %s", driver->name, DEVCLANAME(busclass)));
1259
1260 if (!dc)
1261 return (0);
1262
1263 /*
1264 * Find the link structure in the bus' list of drivers.
1265 */
1266 TAILQ_FOREACH(dl, &busclass->drivers, link) {
1267 if (dl->driver == driver)
1268 break;
1269 }
1270
1271 if (!dl) {
1272 PDEBUG(("%s not found in %s list", driver->name,
1273 busclass->name));
1274 return (ENOENT);
1275 }
1276
1277 error = devclass_driver_deleted(busclass, dc, driver);
1278 if (error != 0)
1279 return (error);
1280
1281 TAILQ_REMOVE(&busclass->drivers, dl, link);
1282 free(dl, M_BUS);
1283
1284 /* XXX: kobj_mtx */
1285 driver->refs--;
1286 if (driver->refs == 0)
1287 kobj_class_free((kobj_class_t) driver);
1288
1289 bus_data_generation_update();
1290 return (0);
1291}
1292
1293/**
1294 * @brief Quiesces a set of device drivers from a device class

Callers 1

driver_module_handlerFunction · 0.85

Calls 5

devclass_findFunction · 0.85
devclass_driver_deletedFunction · 0.85
kobj_class_freeFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected