Lines Matching +full:parent +full:- +full:child
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
104 devclass_t parent; /* parent in devclass hierarchy */ member
144 TAILQ_ENTRY(_device) link; /**< list of devices in parent */
146 device_t parent; /**< parent of this device */ member
147 device_list_t children; /**< list of child devices */
171 static MALLOC_DEFINE(M_BUS_SC, "bus-sc", "Bus data structures, softc");
181 #define DRIVERNAME(d) ((d)? d->name : "no driver")
182 #define DEVCLANAME(d) ((d)? d->name : "no devclass")
244 value = dc->parent ? dc->parent->name : ""; in devclass_sysctl_handler()
255 if (dc->sysctl_tree != NULL) in devclass_sysctl_init()
257 sysctl_ctx_init(&dc->sysctl_ctx); in devclass_sysctl_init()
258 dc->sysctl_tree = SYSCTL_ADD_NODE(&dc->sysctl_ctx, in devclass_sysctl_init()
259 SYSCTL_STATIC_CHILDREN(_dev), OID_AUTO, dc->name, in devclass_sysctl_init()
261 SYSCTL_ADD_PROC(&dc->sysctl_ctx, SYSCTL_CHILDREN(dc->sysctl_tree), in devclass_sysctl_init()
262 OID_AUTO, "%parent", in devclass_sysctl_init()
265 "parent class"); in devclass_sysctl_init()
295 sbuf_cat(&sb, dev->desc ? dev->desc : ""); in device_sysctl_handler()
298 sbuf_cat(&sb, dev->driver ? dev->driver->name : ""); in device_sysctl_handler()
307 sbuf_cat(&sb, dev->parent ? dev->parent->nameunit : ""); in device_sysctl_handler()
345 devclass_t dc = dev->devclass; in device_sysctl_init()
348 if (dev->sysctl_tree != NULL) in device_sysctl_init()
351 sysctl_ctx_init(&dev->sysctl_ctx); in device_sysctl_init()
352 dev->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&dev->sysctl_ctx, in device_sysctl_init()
353 SYSCTL_CHILDREN(dc->sysctl_tree), OID_AUTO, in device_sysctl_init()
354 dev->nameunit + strlen(dc->name), in device_sysctl_init()
356 SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), in device_sysctl_init()
360 SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), in device_sysctl_init()
365 SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), in device_sysctl_init()
369 "device location relative to parent"); in device_sysctl_init()
370 SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), in device_sysctl_init()
375 SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), in device_sysctl_init()
376 OID_AUTO, "%parent", in device_sysctl_init()
379 "parent device"); in device_sysctl_init()
380 SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), in device_sysctl_init()
386 SYSCTL_ADD_INT(&dev->sysctl_ctx, in device_sysctl_init()
387 SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%domain", in device_sysctl_init()
394 devclass_t dc = dev->devclass; in device_sysctl_update()
396 if (dev->sysctl_tree == NULL) in device_sysctl_update()
398 sysctl_rename_oid(dev->sysctl_tree, dev->nameunit + strlen(dc->name)); in device_sysctl_update()
404 if (dev->sysctl_tree == NULL) in device_sysctl_fini()
406 sysctl_ctx_free(&dev->sysctl_ctx); in device_sysctl_fini()
407 dev->sysctl_tree = NULL; in device_sysctl_fini()
479 if (dl->pass < new->pass) in driver_register_pass()
481 if (dl->pass == new->pass) in driver_register_pass()
520 if (dl->pass <= bus_current_pass) in bus_set_pass()
527 if (dl->pass > pass) in bus_set_pass()
534 bus_current_pass = dl->pass; in bus_set_pass()
559 * otherwise if @p create is non-zero create and return a new device
562 * If @p parentname is non-NULL, the parent of the devclass is set to
566 * @param parentname the parent devclass name or @c NULL
567 * @param create non-zero to create a devclass
580 if (!strcmp(dc->name, classname)) in devclass_find_internal()
588 dc->parent = NULL; in devclass_find_internal()
589 dc->name = (char*) (dc + 1); in devclass_find_internal()
590 strcpy(dc->name, classname); in devclass_find_internal()
591 TAILQ_INIT(&dc->drivers); in devclass_find_internal()
598 * If a parent class is specified, then set that as our parent so in devclass_find_internal()
599 * that this devclass will support drivers for the parent class as in devclass_find_internal()
600 * well. If the parent class has the same name don't do this though in devclass_find_internal()
605 if (parentname && dc && !dc->parent && in devclass_find_internal()
607 dc->parent = devclass_find_internal(parentname, NULL, TRUE); in devclass_find_internal()
608 dc->parent->flags |= DC_HAS_CHILDREN; in devclass_find_internal()
652 * level to save storing children-lists in the devclass structure. If
662 devclass_t parent; in devclass_driver_added() local
668 for (i = 0; i < dc->maxunit; i++) in devclass_driver_added()
669 if (dc->devices[i] && device_is_attached(dc->devices[i])) in devclass_driver_added()
670 BUS_DRIVER_ADDED(dc->devices[i], driver); in devclass_driver_added()
674 * single parent pointer around, we walk the entire list of in devclass_driver_added()
676 * DC_HAS_CHILDREN flag when a child devclass is created on in devclass_driver_added()
677 * the parent, so we only walk the list for those devclasses in devclass_driver_added()
680 if (!(dc->flags & DC_HAS_CHILDREN)) in devclass_driver_added()
682 parent = dc; in devclass_driver_added()
684 if (dc->parent == parent) in devclass_driver_added()
692 BUS_PROBE_NOMATCH(dev->parent, dev); in device_handle_nomatch()
694 dev->flags |= DF_DONENOMATCH; in device_handle_nomatch()
703 * to re-probe any unmatched children.
727 * double-free in devclass_delete_driver. in devclass_add_driver()
738 if (driver->baseclasses) in devclass_add_driver()
739 parentname = driver->baseclasses[0]->name; in devclass_add_driver()
742 child_dc = devclass_find_internal(driver->name, parentname, TRUE); in devclass_add_driver()
746 dl->driver = driver; in devclass_add_driver()
747 TAILQ_INSERT_TAIL(&dc->drivers, dl, link); in devclass_add_driver()
748 driver->refs++; /* XXX: kobj_mtx */ in devclass_add_driver()
749 dl->pass = pass; in devclass_add_driver()
753 dl->flags |= DL_DEFERRED_PROBE; in devclass_add_driver()
772 * level to save storing children-lists in the devclass structure. If
776 * @param busclass the devclass of the parent bus
783 devclass_t parent; in devclass_driver_deleted() local
790 * using the driver and which have a parent in the devclass which in devclass_driver_deleted()
800 for (i = 0; i < dc->maxunit; i++) { in devclass_driver_deleted()
801 if (dc->devices[i]) { in devclass_driver_deleted()
802 dev = dc->devices[i]; in devclass_driver_deleted()
803 if (dev->driver == driver && dev->parent && in devclass_driver_deleted()
804 dev->parent->devclass == busclass) { in devclass_driver_deleted()
808 dev->flags &= ~DF_DONENOMATCH; in devclass_driver_deleted()
809 dev->flags |= DF_NEEDNOMATCH; in devclass_driver_deleted()
819 * single parent pointer around, we walk the entire list of in devclass_driver_deleted()
821 * DC_HAS_CHILDREN flag when a child devclass is created on in devclass_driver_deleted()
822 * the parent, so we only walk the list for those devclasses in devclass_driver_deleted()
825 if (!(busclass->flags & DC_HAS_CHILDREN)) in devclass_driver_deleted()
827 parent = busclass; in devclass_driver_deleted()
829 if (busclass->parent == parent) { in devclass_driver_deleted()
855 devclass_t dc = devclass_find(driver->name); in devclass_delete_driver()
859 PDEBUG(("%s from devclass %s", driver->name, DEVCLANAME(busclass))); in devclass_delete_driver()
867 TAILQ_FOREACH(dl, &busclass->drivers, link) { in devclass_delete_driver()
868 if (dl->driver == driver) in devclass_delete_driver()
873 PDEBUG(("%s not found in %s list", driver->name, in devclass_delete_driver()
874 busclass->name)); in devclass_delete_driver()
882 TAILQ_REMOVE(&busclass->drivers, dl, link); in devclass_delete_driver()
886 driver->refs--; in devclass_delete_driver()
887 if (driver->refs == 0) in devclass_delete_driver()
910 devclass_t dc = devclass_find(driver->name); in devclass_quiesce_driver()
916 PDEBUG(("%s from devclass %s", driver->name, DEVCLANAME(busclass))); in devclass_quiesce_driver()
924 TAILQ_FOREACH(dl, &busclass->drivers, link) { in devclass_quiesce_driver()
925 if (dl->driver == driver) in devclass_quiesce_driver()
930 PDEBUG(("%s not found in %s list", driver->name, in devclass_quiesce_driver()
931 busclass->name)); in devclass_quiesce_driver()
938 * the driver and which have a parent in the devclass which we in devclass_quiesce_driver()
945 for (i = 0; i < dc->maxunit; i++) { in devclass_quiesce_driver()
946 if (dc->devices[i]) { in devclass_quiesce_driver()
947 dev = dc->devices[i]; in devclass_quiesce_driver()
948 if (dev->driver == driver && dev->parent && in devclass_quiesce_driver()
949 dev->parent->devclass == busclass) { in devclass_quiesce_driver()
969 TAILQ_FOREACH(dl, &dc->drivers, link) { in devclass_find_driver_internal()
970 if (!strcmp(dl->driver->name, classname)) in devclass_find_driver_internal()
984 return (dc->name); in devclass_get_name()
999 if (dc == NULL || unit < 0 || unit >= dc->maxunit) in devclass_get_device()
1001 return (dc->devices[unit]); in devclass_get_device()
1054 for (i = 0; i < dc->maxunit; i++) { in devclass_get_devices()
1055 if (dc->devices[i]) { in devclass_get_devices()
1056 list[count] = dc->devices[i]; in devclass_get_devices()
1091 TAILQ_FOREACH(dl, &dc->drivers, link) in devclass_get_drivers()
1098 TAILQ_FOREACH(dl, &dc->drivers, link) { in devclass_get_drivers()
1099 list[count] = dl->driver; in devclass_get_drivers()
1119 for (i = 0; i < dc->maxunit; i++) in devclass_get_count()
1120 if (dc->devices[i]) in devclass_get_count()
1128 * Note that this is one greater than the highest currently-allocated unit. If
1129 * @p dc is NULL, @c -1 is returned to indicate that not even the devclass has
1138 return (-1); in devclass_get_maxunit()
1139 return (dc->maxunit); in devclass_get_maxunit()
1157 while (unit < dc->maxunit && dc->devices[unit] != NULL) in devclass_find_free_unit()
1163 * @brief Set the parent of a devclass
1165 * The parent class is normally initialised automatically by
1169 * @param pdc the new parent devclass
1174 dc->parent = pdc; in devclass_set_parent()
1178 * @brief Get the parent of a devclass
1185 return (dc->parent); in devclass_get_parent()
1191 return (&dc->sysctl_ctx); in devclass_get_sysctl_ctx()
1197 return (dc->sysctl_tree); in devclass_get_sysctl_tree()
1224 /* Ask the parent bus if it wants to wire this device. */ in devclass_alloc_unit()
1226 BUS_HINT_DEVICE_UNIT(device_get_parent(dev), dev, dc->name, in devclass_alloc_unit()
1235 if (unit < dc->maxunit && dc->devices[unit] != NULL) { in devclass_alloc_unit()
1238 dc->name, dc->name, *unitp); in devclass_alloc_unit()
1246 if (unit < dc->maxunit && dc->devices[unit] != NULL) in devclass_alloc_unit()
1250 if (resource_string_value(dc->name, unit, "at", &s) == in devclass_alloc_unit()
1271 if (unit >= dc->maxunit) { in devclass_alloc_unit()
1275 dc->devices = reallocf(dc->devices, in devclass_alloc_unit()
1276 newsize * sizeof(*dc->devices), M_BUS, M_WAITOK); in devclass_alloc_unit()
1277 memset(dc->devices + dc->maxunit, 0, in devclass_alloc_unit()
1278 sizeof(device_t) * (newsize - dc->maxunit)); in devclass_alloc_unit()
1279 dc->maxunit = newsize; in devclass_alloc_unit()
1311 buflen = snprintf(NULL, 0, "%s%d$", dc->name, INT_MAX); in devclass_add_device()
1314 dev->nameunit = malloc(buflen, M_BUS, M_WAITOK|M_ZERO); in devclass_add_device()
1316 if ((error = devclass_alloc_unit(dc, dev, &dev->unit)) != 0) { in devclass_add_device()
1317 free(dev->nameunit, M_BUS); in devclass_add_device()
1318 dev->nameunit = NULL; in devclass_add_device()
1321 dc->devices[dev->unit] = dev; in devclass_add_device()
1322 dev->devclass = dc; in devclass_add_device()
1323 snprintf(dev->nameunit, buflen, "%s%d", dc->name, dev->unit); in devclass_add_device()
1348 if (dev->devclass != dc || dc->devices[dev->unit] != dev) in devclass_delete_device()
1350 dc->devices[dev->unit] = NULL; in devclass_delete_device()
1351 if (dev->flags & DF_WILDCARD) in devclass_delete_device()
1352 dev->unit = DEVICE_UNIT_ANY; in devclass_delete_device()
1353 dev->devclass = NULL; in devclass_delete_device()
1354 free(dev->nameunit, M_BUS); in devclass_delete_device()
1355 dev->nameunit = NULL; in devclass_delete_device()
1362 * @brief Make a new device and add it as a child of @p parent
1364 * @param parent the parent of the new device
1373 make_device(device_t parent, const char *name, int unit) in make_device() argument
1378 PDEBUG(("%s at %s as unit %d", name, DEVICENAME(parent), unit)); in make_device()
1392 dev->parent = parent; in make_device()
1393 TAILQ_INIT(&dev->children); in make_device()
1395 dev->driver = NULL; in make_device()
1396 dev->devclass = NULL; in make_device()
1397 dev->unit = unit; in make_device()
1398 dev->nameunit = NULL; in make_device()
1399 dev->desc = NULL; in make_device()
1400 dev->busy = 0; in make_device()
1401 dev->devflags = 0; in make_device()
1402 dev->flags = DF_ENABLED; in make_device()
1403 dev->order = 0; in make_device()
1405 dev->flags |= DF_WILDCARD; in make_device()
1407 dev->flags |= DF_FIXEDCLASS; in make_device()
1413 if (parent != NULL && device_has_quiet_children(parent)) in make_device()
1414 dev->flags |= DF_QUIET | DF_QUIET_CHILDREN; in make_device()
1415 dev->ivars = NULL; in make_device()
1416 dev->softc = NULL; in make_device()
1417 LIST_INIT(&dev->props); in make_device()
1419 dev->state = DS_NOTPRESENT; in make_device()
1432 device_print_child(device_t dev, device_t child) in device_print_child() argument
1436 if (device_is_alive(child)) in device_print_child()
1437 retval += BUS_PRINT_CHILD(dev, child); in device_print_child()
1439 retval += device_printf(child, " not found\n"); in device_print_child()
1447 * This creates a new device and adds it as a child of an existing
1448 * parent device. The new device will be added after the last existing
1449 * child with order zero.
1451 * @param dev the device which will be the parent of the
1452 * new child device
1469 * This creates a new device and adds it as a child of an existing
1470 * parent device. The new device will be added after the last existing
1471 * child with the same order.
1473 * @param dev the device which will be the parent of the
1474 * new child device
1476 * children of @p dev - devices created using
1489 device_t child; in device_add_child_ordered() local
1495 ("child device with wildcard name and specific unit number")); in device_add_child_ordered()
1497 child = make_device(dev, name, unit); in device_add_child_ordered()
1498 if (child == NULL) in device_add_child_ordered()
1499 return (child); in device_add_child_ordered()
1500 child->order = order; in device_add_child_ordered()
1502 TAILQ_FOREACH(place, &dev->children, link) { in device_add_child_ordered()
1503 if (place->order > order) in device_add_child_ordered()
1510 * greater than the new child. in device_add_child_ordered()
1512 TAILQ_INSERT_BEFORE(place, child, link); in device_add_child_ordered()
1515 * The new child's order is greater or equal to the order of in device_add_child_ordered()
1516 * any existing device. Add the child to the tail of the list. in device_add_child_ordered()
1518 TAILQ_INSERT_TAIL(&dev->children, child, link); in device_add_child_ordered()
1522 return (child); in device_add_child_ordered()
1532 * @param dev the parent device
1533 * @param child the device to delete
1536 * @retval non-zero a unit error code describing the error
1539 device_delete_child(device_t dev, device_t child) in device_delete_child() argument
1544 PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev))); in device_delete_child()
1547 * Detach child. Ideally this cleans up any grandchild in device_delete_child()
1550 if ((error = device_detach(child)) != 0) in device_delete_child()
1554 while ((grandchild = TAILQ_FIRST(&child->children)) != NULL) { in device_delete_child()
1555 error = device_delete_child(child, grandchild); in device_delete_child()
1561 if (child->devclass) in device_delete_child()
1562 devclass_delete_device(child->devclass, child); in device_delete_child()
1563 if (child->parent) in device_delete_child()
1564 BUS_CHILD_DELETED(dev, child); in device_delete_child()
1565 TAILQ_REMOVE(&dev->children, child, link); in device_delete_child()
1566 TAILQ_REMOVE(&bus_data_devices, child, devlink); in device_delete_child()
1567 kobj_delete((kobj_t) child, M_BUS); in device_delete_child()
1578 * finds. If a child device cannot be deleted, this function will
1581 * @param dev the parent device
1584 * @retval non-zero a device would not detach
1589 device_t child; in device_delete_children() local
1596 while ((child = TAILQ_FIRST(&dev->children)) != NULL) { in device_delete_children()
1597 error = device_delete_child(dev, child); in device_delete_children()
1599 PDEBUG(("Failed deleting %s", DEVICENAME(child))); in device_delete_children()
1610 * devices which have @p dev as a parent.
1612 * @param dev the parent device to search
1614 * @c DEVICE_UNIT_ANY, return the first child of @p dev
1625 device_t child; in device_find_child() local
1632 child = devclass_get_device(dc, unit); in device_find_child()
1633 if (child && child->parent == dev) in device_find_child()
1634 return (child); in device_find_child()
1637 child = devclass_get_device(dc, unit); in device_find_child()
1638 if (child && child->parent == dev) in device_find_child()
1639 return (child); in device_find_child()
1651 if (dev->devclass) in first_matching_driver()
1652 return (devclass_find_driver_internal(dc, dev->devclass->name)); in first_matching_driver()
1653 return (TAILQ_FIRST(&dc->drivers)); in first_matching_driver()
1662 if (dev->devclass) { in next_matching_driver()
1665 if (!strcmp(dev->devclass->name, dl->driver->name)) in next_matching_driver()
1676 device_probe_child(device_t dev, device_t child) in device_probe_child() argument
1683 int hasclass = (child->devclass != NULL); in device_probe_child()
1687 dc = dev->devclass; in device_probe_child()
1689 panic("device_probe_child: parent device has no devclass"); in device_probe_child()
1694 if (child->state == DS_ALIVE) in device_probe_child()
1697 for (; dc; dc = dc->parent) { in device_probe_child()
1698 for (dl = first_matching_driver(dc, child); in device_probe_child()
1700 dl = next_matching_driver(dc, child, dl)) { in device_probe_child()
1702 if (dl->pass > bus_current_pass) in device_probe_child()
1705 PDEBUG(("Trying %s", DRIVERNAME(dl->driver))); in device_probe_child()
1706 result = device_set_driver(child, dl->driver); in device_probe_child()
1712 if (device_set_devclass(child, in device_probe_child()
1713 dl->driver->name) != 0) { in device_probe_child()
1715 device_get_name(child); in device_probe_child()
1721 dl->driver->name, in device_probe_child()
1723 (void)device_set_driver(child, NULL); in device_probe_child()
1729 resource_int_value(dl->driver->name, child->unit, in device_probe_child()
1730 "flags", &child->devflags); in device_probe_child()
1732 result = DEVICE_PROBE(child); in device_probe_child()
1745 child->devflags = 0; in device_probe_child()
1747 (void)device_set_devclass(child, NULL); in device_probe_child()
1753 device_verbose(child); in device_probe_child()
1761 !(child->flags & DF_FIXEDCLASS)) { in device_probe_child()
1770 (void)device_set_driver(child, NULL); in device_probe_child()
1794 result = device_set_driver(child, best->driver); in device_probe_child()
1797 if (!child->devclass) { in device_probe_child()
1798 result = device_set_devclass(child, best->driver->name); in device_probe_child()
1800 (void)device_set_driver(child, NULL); in device_probe_child()
1804 resource_int_value(best->driver->name, child->unit, in device_probe_child()
1805 "flags", &child->devflags); in device_probe_child()
1811 result = DEVICE_PROBE(child); in device_probe_child()
1814 (void)device_set_devclass(child, NULL); in device_probe_child()
1815 (void)device_set_driver(child, NULL); in device_probe_child()
1820 child->state = DS_ALIVE; in device_probe_child()
1826 * @brief Return the parent of a device
1831 return (dev->parent); in device_get_parent()
1854 device_t child; in device_get_children() local
1858 TAILQ_FOREACH(child, &dev->children, link) { in device_get_children()
1876 TAILQ_FOREACH(child, &dev->children, link) { in device_get_children()
1877 list[count] = child; in device_get_children()
1892 * @rerval true the device has at least one child
1898 return (!TAILQ_EMPTY(&dev->children)); in device_has_children()
1908 return (dev->driver); in device_get_driver()
1918 return (dev->devclass); in device_get_devclass()
1928 if (dev != NULL && dev->devclass) in device_get_name()
1929 return (devclass_get_name(dev->devclass)); in device_get_name()
1941 return (dev->nameunit); in device_get_nameunit()
1950 return (dev->unit); in device_get_unit()
1959 return (dev->desc); in device_get_desc()
1968 return (dev->devflags); in device_get_flags()
1974 return (&dev->sysctl_ctx); in device_get_sysctl_ctx()
1980 return (dev->sysctl_tree); in device_get_sysctl_tree()
2083 if (dev->desc && (dev->flags & DF_DESCMALLOCED)) { in device_set_desc_internal()
2084 free(dev->desc, M_BUS); in device_set_desc_internal()
2085 dev->flags &= ~DF_DESCMALLOCED; in device_set_desc_internal()
2086 dev->desc = NULL; in device_set_desc_internal()
2090 dev->flags |= DF_DESCMALLOCED; in device_set_desc_internal()
2091 dev->desc = __DECONST(char *, desc); in device_set_desc_internal()
2112 * A printf-like version of device_set_desc().
2147 dev->devflags = flags; in device_set_flags()
2159 return (dev->softc); in device_get_softc()
2171 if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) in device_set_softc()
2172 free(dev->softc, M_BUS_SC); in device_set_softc()
2173 dev->softc = softc; in device_set_softc()
2174 if (dev->softc) in device_set_softc()
2175 dev->flags |= DF_EXTERNALSOFTC; in device_set_softc()
2177 dev->flags &= ~DF_EXTERNALSOFTC; in device_set_softc()
2203 if (dev->softc) in device_claim_softc()
2204 dev->flags |= DF_EXTERNALSOFTC; in device_claim_softc()
2206 dev->flags &= ~DF_EXTERNALSOFTC; in device_claim_softc()
2212 * The ivars field is used by the parent device to store per-device
2220 return (dev->ivars); in device_get_ivars()
2230 dev->ivars = ivars; in device_set_ivars()
2239 return (dev->state); in device_get_state()
2248 dev->flags |= DF_ENABLED; in device_enable()
2257 dev->flags &= ~DF_ENABLED; in device_disable()
2269 * goes 0->1. in device_busy()
2271 if (refcount_acquire(&dev->busy) == 0 && dev->parent != NULL) in device_busy()
2272 device_busy(dev->parent); in device_busy()
2285 if (refcount_release(&dev->busy) && dev->parent != NULL) in device_unbusy()
2286 device_unbusy(dev->parent); in device_unbusy()
2295 dev->flags |= DF_QUIET; in device_quiet()
2304 dev->flags |= DF_QUIET_CHILDREN; in device_quiet_children()
2313 dev->flags &= ~DF_QUIET; in device_verbose()
2329 return (-1); in device_get_property()
2333 return (-1); in device_get_property()
2336 return (-1); in device_get_property()
2349 * @brief Return non-zero if the DF_QUIET_CHIDLREN flag is set on the device
2354 return ((dev->flags & DF_QUIET_CHILDREN) != 0); in device_has_quiet_children()
2358 * @brief Return non-zero if the DF_QUIET flag is set on the device
2363 return ((dev->flags & DF_QUIET) != 0); in device_is_quiet()
2367 * @brief Return non-zero if the DF_ENABLED flag is set on the device
2372 return ((dev->flags & DF_ENABLED) != 0); in device_is_enabled()
2376 * @brief Return non-zero if the device was successfully probed
2381 return (dev->state >= DS_ALIVE); in device_is_alive()
2385 * @brief Return non-zero if the device currently has a driver
2391 return (dev->state >= DS_ATTACHED); in device_is_attached()
2395 * @brief Return non-zero if the device is currently suspended.
2400 return ((dev->flags & DF_SUSPENDED) != 0); in device_is_suspended()
2414 if (dev->devclass) in device_set_devclass()
2415 devclass_delete_device(dev->devclass, dev); in device_set_devclass()
2419 if (dev->devclass) { in device_set_devclass()
2449 dev->flags |= DF_FIXEDCLASS; in device_set_devclass_fixed()
2460 return ((dev->flags & DF_FIXEDCLASS) != 0); in device_is_devclass_fixed()
2476 if (dev->state >= DS_ATTACHED) in device_set_driver()
2479 if (dev->driver == driver) in device_set_driver()
2482 if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) { in device_set_driver()
2483 free(dev->softc, M_BUS_SC); in device_set_driver()
2484 dev->softc = NULL; in device_set_driver()
2488 dev->driver = driver; in device_set_driver()
2491 if (!(dev->flags & DF_EXTERNALSOFTC) && driver->size > 0) { in device_set_driver()
2496 dev->softc = malloc_domainset(driver->size, M_BUS_SC, in device_set_driver()
2519 * the parent device's devclass. If the device was originally created
2523 * parent devclass, the search continues in the parent of that
2531 * @retval non-zero some other unix error code
2532 * @retval -1 Device already attached
2541 if (dev->state >= DS_ALIVE) in device_probe()
2542 return (-1); in device_probe()
2544 if (!(dev->flags & DF_ENABLED)) { in device_probe()
2549 return (-1); in device_probe()
2551 if ((error = device_probe_child(dev->parent, dev)) != 0) { in device_probe()
2553 !(dev->flags & DF_DONENOMATCH)) { in device_probe()
2574 if (error == -1) in device_probe_and_attach()
2588 * and queues a notification event for user-based device management
2599 * @retval non-zero some other unix error code
2608 if (resource_disabled(dev->driver->name, dev->unit)) { in device_attach()
2615 dev->state = DS_NOTPRESENT; in device_attach()
2627 device_print_child(dev->parent, dev); in device_attach()
2629 dev->state = DS_ATTACHING; in device_attach()
2632 dev->driver->name, dev->unit, error); in device_attach()
2633 BUS_CHILD_DETACHED(dev->parent, dev); in device_attach()
2650 if (!(dev->flags & DF_FIXEDCLASS)) in device_attach()
2651 devclass_delete_device(dev->devclass, dev); in device_attach()
2654 KASSERT(dev->busy == 0, ("attach failed but busy")); in device_attach()
2655 dev->state = DS_NOTPRESENT; in device_attach()
2661 dev->flags |= DF_ATTACHED_ONCE; in device_attach()
2666 attachentropy = (uint16_t)(get_cyclecount() - attachtime); in device_attach()
2669 dev->state = DS_ATTACHED; in device_attach()
2670 dev->flags &= ~DF_DONENOMATCH; in device_attach()
2680 * BUS_CHILD_DETACHED() for the parent of @p dev, queues a
2681 * notification event for user-based device management services and
2684 * @param dev the device to un-initialise
2689 * @retval non-zero some other unix error code
2699 if (dev->busy > 0) in device_detach()
2701 if (dev->state == DS_ATTACHING) { in device_detach()
2705 if (dev->state != DS_ATTACHED) in device_detach()
2719 if (dev->parent) in device_detach()
2720 BUS_CHILD_DETACHED(dev->parent, dev); in device_detach()
2722 if (!(dev->flags & DF_FIXEDCLASS)) in device_detach()
2723 devclass_delete_device(dev->devclass, dev); in device_detach()
2726 dev->state = DS_NOTPRESENT; in device_detach()
2744 * @retval non-zero some other unix error code
2750 if (dev->busy > 0) in device_quiesce()
2752 if (dev->state != DS_ATTACHED) in device_quiesce()
2769 if (dev->state < DS_ATTACHED) in device_shutdown()
2778 * device (e.g. to wire a device to a pre-configured unit number).
2786 if (unit == dev->unit) in device_set_unit()
2789 if (unit < dc->maxunit && dc->devices[unit]) in device_set_unit()
2794 dev->unit = unit; in device_set_unit()
2821 args->size = sz; in resource_init_map_request_impl()
2822 args->memattr = VM_MEMATTR_DEVICE; in resource_init_map_request_impl()
2849 MPASS(out->size == sizeof(struct resource_map_request)); in resource_validate_map_request()
2852 bcopy(in, out, imin(in->size, out->size)); in resource_validate_map_request()
2853 start = rman_get_start(r) + out->offset; in resource_validate_map_request()
2854 if (out->length == 0) in resource_validate_map_request()
2857 length = out->length; in resource_validate_map_request()
2858 end = start + length - 1; in resource_validate_map_request()
2893 if (rle->res) in resource_list_free()
2911 * @param count XXX end-start+1
2939 * @param count XXX end-start+1
2952 rle->type = type; in resource_list_add()
2953 rle->rid = rid; in resource_list_add()
2954 rle->res = NULL; in resource_list_add()
2955 rle->flags = 0; in resource_list_add()
2958 if (rle->res) in resource_list_add()
2961 rle->start = start; in resource_list_add()
2962 rle->end = end; in resource_list_add()
2963 rle->count = count; in resource_list_add()
2977 * @returns Non-zero if the entry is busy, zero otherwise.
2985 if (rle == NULL || rle->res == NULL) in resource_list_busy()
2987 if ((rle->flags & (RLE_RESERVED | RLE_ALLOCATED)) == RLE_RESERVED) { in resource_list_busy()
2988 KASSERT(!(rman_get_flags(rle->res) & RF_ACTIVE), in resource_list_busy()
3006 * @returns Non-zero if the entry is reserved, zero otherwise.
3014 if (rle != NULL && rle->flags & RLE_RESERVED) in resource_list_reserved()
3035 if (rle->type == type && rle->rid == rid) in resource_list_find()
3054 if (rle->res != NULL) in resource_list_delete()
3067 * adding a new child to the bus. The resource is allocated from the
3068 * parent bus when it is reserved. The resource list entry is marked
3077 * the parent bus by calling resource_list_unreserve().
3080 * @param bus the parent device of @p child
3081 * @param child the device for which the resource is being reserved
3084 * @param start hint at the start of the resource range - pass
3086 * @param end hint at the end of the resource range - pass
3088 * @param count hint at the size of range required - pass @c 1
3091 * allocation - see @c RF_XXX flags in
3098 resource_list_reserve(struct resource_list *rl, device_t bus, device_t child, in resource_list_reserve() argument
3102 int passthrough = (device_get_parent(child) != bus); in resource_list_reserve()
3112 r = resource_list_alloc(rl, bus, child, type, rid, start, end, count, in resource_list_reserve()
3116 rle->flags |= RLE_RESERVED; in resource_list_reserve()
3125 * and passing the allocation up to the parent of @p bus. This assumes
3126 * that the first entry of @c device_get_ivars(child) is a struct
3128 * child is a remote descendant of bus by passing the allocation up to
3129 * the parent of bus.
3131 * Typically, a bus driver would store a list of child resources
3132 * somewhere in the child device's ivars (see device_get_ivars()) and
3137 * @param bus the parent device of @p child
3138 * @param child the device which is requesting an allocation
3141 * @param start hint at the start of the resource range - pass
3143 * @param end hint at the end of the resource range - pass
3145 * @param count hint at the size of range required - pass @c 1
3148 * allocation - see @c RF_XXX flags in
3155 resource_list_alloc(struct resource_list *rl, device_t bus, device_t child, in resource_list_alloc() argument
3159 int passthrough = (device_get_parent(child) != bus); in resource_list_alloc()
3163 return (BUS_ALLOC_RESOURCE(device_get_parent(bus), child, in resource_list_alloc()
3172 if (rle->res) { in resource_list_alloc()
3173 if (rle->flags & RLE_RESERVED) { in resource_list_alloc()
3174 if (rle->flags & RLE_ALLOCATED) in resource_list_alloc()
3177 bus_activate_resource(child, type, *rid, in resource_list_alloc()
3178 rle->res) != 0) in resource_list_alloc()
3180 rle->flags |= RLE_ALLOCATED; in resource_list_alloc()
3181 return (rle->res); in resource_list_alloc()
3184 "resource entry %#x type %d for child %s is busy\n", *rid, in resource_list_alloc()
3185 type, device_get_nameunit(child)); in resource_list_alloc()
3190 start = rle->start; in resource_list_alloc()
3191 count = ulmax(count, rle->count); in resource_list_alloc()
3192 end = ulmax(rle->end, start + count - 1); in resource_list_alloc()
3195 rle->res = BUS_ALLOC_RESOURCE(device_get_parent(bus), child, in resource_list_alloc()
3201 if (rle->res) { in resource_list_alloc()
3202 rle->start = rman_get_start(rle->res); in resource_list_alloc()
3203 rle->end = rman_get_end(rle->res); in resource_list_alloc()
3204 rle->count = count; in resource_list_alloc()
3207 return (rle->res); in resource_list_alloc()
3217 * @param bus the parent device of @p child
3218 * @param child the device which is requesting a release
3222 * @retval non-zero a standard unix error code indicating what
3226 resource_list_release(struct resource_list *rl, device_t bus, device_t child, in resource_list_release() argument
3230 int passthrough = (device_get_parent(child) != bus); in resource_list_release()
3234 return (BUS_RELEASE_RESOURCE(device_get_parent(bus), child, in resource_list_release()
3242 if (!rle->res) in resource_list_release()
3244 if (rle->flags & RLE_RESERVED) { in resource_list_release()
3245 if (rle->flags & RLE_ALLOCATED) { in resource_list_release()
3247 error = bus_deactivate_resource(child, res); in resource_list_release()
3251 rle->flags &= ~RLE_ALLOCATED; in resource_list_release()
3257 error = BUS_RELEASE_RESOURCE(device_get_parent(bus), child, res); in resource_list_release()
3261 rle->res = NULL; in resource_list_release()
3273 * @param bus the parent device of @p child
3274 * @param child the device whose active resources are being released
3282 device_t child, int type) in resource_list_release_active() argument
3289 if (rle->type != type) in resource_list_release_active()
3291 if (rle->res == NULL) in resource_list_release_active()
3293 if ((rle->flags & (RLE_RESERVED | RLE_ALLOCATED)) == in resource_list_release_active()
3297 error = resource_list_release(rl, bus, child, rle->res); in resource_list_release_active()
3311 * @param bus the parent device of @p child
3312 * @param child the device whose reserved resource is being released
3318 * @retval non-zero a standard unix error code indicating what
3322 resource_list_unreserve(struct resource_list *rl, device_t bus, device_t child, in resource_list_unreserve() argument
3326 int passthrough = (device_get_parent(child) != bus); in resource_list_unreserve()
3336 if (!(rle->flags & RLE_RESERVED)) in resource_list_unreserve()
3338 if (rle->flags & RLE_ALLOCATED) in resource_list_unreserve()
3340 rle->flags &= ~RLE_RESERVED; in resource_list_unreserve()
3341 return (resource_list_release(rl, bus, child, rle->res)); in resource_list_unreserve()
3370 if (rle->type == type) { in resource_list_print_type()
3376 retval += printf(format, rle->start); in resource_list_print_type()
3377 if (rle->count > 1) { in resource_list_print_type()
3378 retval += printf("-"); in resource_list_print_type()
3379 retval += printf(format, rle->start + in resource_list_print_type()
3380 rle->count - 1); in resource_list_print_type()
3400 if (rle->res) in resource_list_purge()
3401 bus_release_resource(rman_get_device(rle->res), in resource_list_purge()
3402 rle->type, rle->rid, rle->res); in resource_list_purge()
3430 * @brief Ask drivers to add child devices of the given device.
3432 * This function allows drivers for child devices of a bus to identify
3433 * child devices and add them as children of the given device. NB:
3436 * @param dev the parent device
3441 devclass_t dc = dev->devclass; in bus_identify_children()
3444 TAILQ_FOREACH(dl, &dc->drivers, link) { in bus_identify_children()
3448 * never be true. For early-pass drivers they will in bus_identify_children()
3452 * on early-pass buses during BUS_NEW_PASS(). in bus_identify_children()
3454 if (dl->pass > bus_current_pass) in bus_identify_children()
3456 DEVICE_IDENTIFY(dl->driver, dev); in bus_identify_children()
3478 * child of the given device using device_probe_and_attach(). If an
3479 * individual child fails to attach this function continues attaching
3482 * @param dev the parent device
3487 device_t child; in bus_attach_children() local
3489 TAILQ_FOREACH(child, &dev->children, link) { in bus_attach_children()
3490 device_probe_and_attach(child); in bus_attach_children()
3513 * child fails to detach, this function stops and returns an error.
3515 * @param dev the parent device
3518 * @retval non-zero a device would not detach
3536 * child of the given device using device_detach(). If an individual
3537 * child fails to detach this function stops and returns an error.
3538 * NB: Children that were successfully detached are not re-attached if
3541 * @param dev the parent device
3544 * @retval non-zero a device would not detach
3549 device_t child; in bus_detach_children() local
3556 TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) { in bus_detach_children()
3557 if ((error = device_detach(child)) != 0) in bus_detach_children()
3574 device_t child; in bus_generic_shutdown() local
3580 TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) { in bus_generic_shutdown()
3581 device_shutdown(child); in bus_generic_shutdown()
3588 * @brief Default function for suspending a child device.
3593 bus_generic_suspend_child(device_t dev, device_t child) in bus_generic_suspend_child() argument
3597 error = DEVICE_SUSPEND(child); in bus_generic_suspend_child()
3600 child->flags |= DF_SUSPENDED; in bus_generic_suspend_child()
3603 device_get_nameunit(child), error); in bus_generic_suspend_child()
3610 * @brief Default function for resuming a child device.
3615 bus_generic_resume_child(device_t dev, device_t child) in bus_generic_resume_child() argument
3617 DEVICE_RESUME(child); in bus_generic_resume_child()
3618 child->flags &= ~DF_SUSPENDED; in bus_generic_resume_child()
3636 device_t child; in bus_generic_suspend() local
3641 * Other buses, such as acpi, carefully order their child devices to in bus_generic_suspend()
3645 TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) { in bus_generic_suspend()
3646 error = BUS_SUSPEND_CHILD(dev, child); in bus_generic_suspend()
3648 child = TAILQ_NEXT(child, link); in bus_generic_suspend()
3649 if (child != NULL) { in bus_generic_suspend()
3650 TAILQ_FOREACH_FROM(child, &dev->children, link) in bus_generic_suspend()
3651 BUS_RESUME_CHILD(dev, child); in bus_generic_suspend()
3668 device_t child; in bus_generic_resume() local
3670 TAILQ_FOREACH(child, &dev->children, link) { in bus_generic_resume()
3671 BUS_RESUME_CHILD(dev, child); in bus_generic_resume()
3681 * re-attaching or resuming the children after the bus itself was
3682 * reset, and after restoring bus-unique state of children.
3690 device_t child; in bus_helper_reset_post() local
3694 TAILQ_FOREACH(child, &dev->children,link) { in bus_helper_reset_post()
3695 BUS_RESET_POST(dev, child); in bus_helper_reset_post()
3697 device_probe_and_attach(child) : in bus_helper_reset_post()
3698 BUS_RESUME_CHILD(dev, child); in bus_helper_reset_post()
3706 bus_helper_reset_prepare_rollback(device_t dev, device_t child, int flags) in bus_helper_reset_prepare_rollback() argument
3708 child = TAILQ_NEXT(child, link); in bus_helper_reset_prepare_rollback()
3709 if (child == NULL) in bus_helper_reset_prepare_rollback()
3711 TAILQ_FOREACH_FROM(child, &dev->children,link) { in bus_helper_reset_prepare_rollback()
3712 BUS_RESET_POST(dev, child); in bus_helper_reset_prepare_rollback()
3714 device_probe_and_attach(child); in bus_helper_reset_prepare_rollback()
3716 BUS_RESUME_CHILD(dev, child); in bus_helper_reset_prepare_rollback()
3725 * reset, and then save bus-unique state of children that must
3734 device_t child; in bus_helper_reset_prepare() local
3737 if (dev->state != DS_ATTACHED) in bus_helper_reset_prepare()
3740 TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) { in bus_helper_reset_prepare()
3742 error = device_get_state(child) == DS_ATTACHED ? in bus_helper_reset_prepare()
3743 device_detach(child) : 0; in bus_helper_reset_prepare()
3745 error = BUS_SUSPEND_CHILD(dev, child); in bus_helper_reset_prepare()
3748 error = BUS_RESET_PREPARE(dev, child); in bus_helper_reset_prepare()
3751 device_probe_and_attach(child); in bus_helper_reset_prepare()
3753 BUS_RESUME_CHILD(dev, child); in bus_helper_reset_prepare()
3757 bus_helper_reset_prepare_rollback(dev, child, flags); in bus_helper_reset_prepare()
3768 * @p child, including its name, unit and description (if any - see
3774 bus_print_child_header(device_t dev, device_t child) in bus_print_child_header() argument
3778 if (device_get_desc(child)) { in bus_print_child_header()
3779 retval += device_printf(child, "<%s>", device_get_desc(child)); in bus_print_child_header()
3781 retval += printf("%s", device_get_nameunit(child)); in bus_print_child_header()
3791 * @p child, which consists of the string @c " on " followed by the
3797 bus_print_child_footer(device_t dev, device_t child) in bus_print_child_footer() argument
3810 bus_print_child_domain(device_t dev, device_t child) in bus_print_child_domain() argument
3815 if (BUS_GET_DOMAIN(dev, child, &domain) != 0) in bus_print_child_domain()
3818 return (printf(" numa-domain %d", domain)); in bus_print_child_domain()
3830 bus_generic_print_child(device_t dev, device_t child) in bus_generic_print_child() argument
3834 retval += bus_print_child_header(dev, child); in bus_generic_print_child()
3835 retval += bus_print_child_domain(dev, child); in bus_generic_print_child()
3836 retval += bus_print_child_footer(dev, child); in bus_generic_print_child()
3847 bus_generic_read_ivar(device_t dev, device_t child, int index, in bus_generic_read_ivar() argument
3859 bus_generic_write_ivar(device_t dev, device_t child, int index, in bus_generic_write_ivar() argument
3868 * This simply calls the BUS_GET_PROPERTY of the parent of dev,
3869 * until a non-default implementation is found.
3872 bus_generic_get_property(device_t dev, device_t child, const char *propname, in bus_generic_get_property() argument
3876 return (BUS_GET_PROPERTY(device_get_parent(dev), child, in bus_generic_get_property()
3879 return (-1); in bus_generic_get_property()
3887 * and then calls device_probe_and_attach() for each unattached child.
3892 device_t child; in bus_generic_driver_added() local
3895 TAILQ_FOREACH(child, &dev->children, link) { in bus_generic_driver_added()
3896 if (child->state == DS_NOTPRESENT) in bus_generic_driver_added()
3897 device_probe_and_attach(child); in bus_generic_driver_added()
3916 device_t child; in bus_generic_new_pass() local
3918 dc = dev->devclass; in bus_generic_new_pass()
3919 TAILQ_FOREACH(dl, &dc->drivers, link) { in bus_generic_new_pass()
3920 if (dl->pass == bus_current_pass) in bus_generic_new_pass()
3921 DEVICE_IDENTIFY(dl->driver, dev); in bus_generic_new_pass()
3923 TAILQ_FOREACH(child, &dev->children, link) { in bus_generic_new_pass()
3924 if (child->state >= DS_ATTACHED) in bus_generic_new_pass()
3925 BUS_NEW_PASS(child); in bus_generic_new_pass()
3926 else if (child->state == DS_NOTPRESENT) in bus_generic_new_pass()
3927 device_probe_and_attach(child); in bus_generic_new_pass()
3935 * BUS_SETUP_INTR() method of the parent of @p dev.
3938 bus_generic_setup_intr(device_t dev, device_t child, struct resource *irq, in bus_generic_setup_intr() argument
3943 if (dev->parent) in bus_generic_setup_intr()
3944 return (BUS_SETUP_INTR(dev->parent, child, irq, flags, in bus_generic_setup_intr()
3953 * BUS_TEARDOWN_INTR() method of the parent of @p dev.
3956 bus_generic_teardown_intr(device_t dev, device_t child, struct resource *irq, in bus_generic_teardown_intr() argument
3960 if (dev->parent) in bus_generic_teardown_intr()
3961 return (BUS_TEARDOWN_INTR(dev->parent, child, irq, cookie)); in bus_generic_teardown_intr()
3969 * BUS_SUSPEND_INTR() method of the parent of @p dev.
3972 bus_generic_suspend_intr(device_t dev, device_t child, struct resource *irq) in bus_generic_suspend_intr() argument
3975 if (dev->parent) in bus_generic_suspend_intr()
3976 return (BUS_SUSPEND_INTR(dev->parent, child, irq)); in bus_generic_suspend_intr()
3984 * BUS_RESUME_INTR() method of the parent of @p dev.
3987 bus_generic_resume_intr(device_t dev, device_t child, struct resource *irq) in bus_generic_resume_intr() argument
3990 if (dev->parent) in bus_generic_resume_intr()
3991 return (BUS_RESUME_INTR(dev->parent, child, irq)); in bus_generic_resume_intr()
3999 * BUS_ADJUST_RESOURCE() method of the parent of @p dev.
4002 bus_generic_adjust_resource(device_t dev, device_t child, struct resource *r, in bus_generic_adjust_resource() argument
4006 if (dev->parent) in bus_generic_adjust_resource()
4007 return (BUS_ADJUST_RESOURCE(dev->parent, child, r, start, end)); in bus_generic_adjust_resource()
4015 * BUS_TRANSLATE_RESOURCE() method of the parent of @p dev. If there is no
4016 * parent, no translation happens.
4022 if (dev->parent) in bus_generic_translate_resource()
4023 return (BUS_TRANSLATE_RESOURCE(dev->parent, type, start, in bus_generic_translate_resource()
4033 * BUS_ALLOC_RESOURCE() method of the parent of @p dev.
4036 bus_generic_alloc_resource(device_t dev, device_t child, int type, int *rid, in bus_generic_alloc_resource() argument
4040 if (dev->parent) in bus_generic_alloc_resource()
4041 return (BUS_ALLOC_RESOURCE(dev->parent, child, type, rid, in bus_generic_alloc_resource()
4050 * BUS_RELEASE_RESOURCE() method of the parent of @p dev.
4053 bus_generic_release_resource(device_t dev, device_t child, struct resource *r) in bus_generic_release_resource() argument
4056 if (dev->parent) in bus_generic_release_resource()
4057 return (BUS_RELEASE_RESOURCE(dev->parent, child, r)); in bus_generic_release_resource()
4065 * BUS_ACTIVATE_RESOURCE() method of the parent of @p dev.
4068 bus_generic_activate_resource(device_t dev, device_t child, struct resource *r) in bus_generic_activate_resource() argument
4071 if (dev->parent) in bus_generic_activate_resource()
4072 return (BUS_ACTIVATE_RESOURCE(dev->parent, child, r)); in bus_generic_activate_resource()
4080 * BUS_DEACTIVATE_RESOURCE() method of the parent of @p dev.
4083 bus_generic_deactivate_resource(device_t dev, device_t child, in bus_generic_deactivate_resource() argument
4087 if (dev->parent) in bus_generic_deactivate_resource()
4088 return (BUS_DEACTIVATE_RESOURCE(dev->parent, child, r)); in bus_generic_deactivate_resource()
4096 * BUS_MAP_RESOURCE() method of the parent of @p dev.
4099 bus_generic_map_resource(device_t dev, device_t child, struct resource *r, in bus_generic_map_resource() argument
4103 if (dev->parent) in bus_generic_map_resource()
4104 return (BUS_MAP_RESOURCE(dev->parent, child, r, args, map)); in bus_generic_map_resource()
4112 * BUS_UNMAP_RESOURCE() method of the parent of @p dev.
4115 bus_generic_unmap_resource(device_t dev, device_t child, struct resource *r, in bus_generic_unmap_resource() argument
4119 if (dev->parent) in bus_generic_unmap_resource()
4120 return (BUS_UNMAP_RESOURCE(dev->parent, child, r, map)); in bus_generic_unmap_resource()
4128 * BUS_BIND_INTR() method of the parent of @p dev.
4131 bus_generic_bind_intr(device_t dev, device_t child, struct resource *irq, in bus_generic_bind_intr() argument
4135 if (dev->parent) in bus_generic_bind_intr()
4136 return (BUS_BIND_INTR(dev->parent, child, irq, cpu)); in bus_generic_bind_intr()
4144 * BUS_CONFIG_INTR() method of the parent of @p dev.
4151 if (dev->parent) in bus_generic_config_intr()
4152 return (BUS_CONFIG_INTR(dev->parent, irq, trig, pol)); in bus_generic_config_intr()
4160 * BUS_DESCRIBE_INTR() method of the parent of @p dev.
4163 bus_generic_describe_intr(device_t dev, device_t child, struct resource *irq, in bus_generic_describe_intr() argument
4167 if (dev->parent) in bus_generic_describe_intr()
4168 return (BUS_DESCRIBE_INTR(dev->parent, child, irq, cookie, in bus_generic_describe_intr()
4177 * BUS_GET_CPUS() method of the parent of @p dev.
4180 bus_generic_get_cpus(device_t dev, device_t child, enum cpu_sets op, in bus_generic_get_cpus() argument
4184 if (dev->parent != NULL) in bus_generic_get_cpus()
4185 return (BUS_GET_CPUS(dev->parent, child, op, setsize, cpuset)); in bus_generic_get_cpus()
4193 * BUS_GET_DMA_TAG() method of the parent of @p dev.
4196 bus_generic_get_dma_tag(device_t dev, device_t child) in bus_generic_get_dma_tag() argument
4199 if (dev->parent != NULL) in bus_generic_get_dma_tag()
4200 return (BUS_GET_DMA_TAG(dev->parent, child)); in bus_generic_get_dma_tag()
4208 * BUS_GET_BUS_TAG() method of the parent of @p dev.
4211 bus_generic_get_bus_tag(device_t dev, device_t child) in bus_generic_get_bus_tag() argument
4214 if (dev->parent != NULL) in bus_generic_get_bus_tag()
4215 return (BUS_GET_BUS_TAG(dev->parent, child)); in bus_generic_get_bus_tag()
4228 bus_generic_rl_get_resource(device_t dev, device_t child, int type, int rid, in bus_generic_rl_get_resource() argument
4234 rl = BUS_GET_RESOURCE_LIST(dev, child); in bus_generic_rl_get_resource()
4243 *startp = rle->start; in bus_generic_rl_get_resource()
4245 *countp = rle->count; in bus_generic_rl_get_resource()
4259 bus_generic_rl_set_resource(device_t dev, device_t child, int type, int rid, in bus_generic_rl_set_resource() argument
4264 rl = BUS_GET_RESOURCE_LIST(dev, child); in bus_generic_rl_set_resource()
4268 resource_list_add(rl, type, rid, start, (start + count - 1), count); in bus_generic_rl_set_resource()
4282 bus_generic_rl_delete_resource(device_t dev, device_t child, int type, int rid) in bus_generic_rl_delete_resource() argument
4286 rl = BUS_GET_RESOURCE_LIST(dev, child); in bus_generic_rl_delete_resource()
4303 bus_generic_rl_release_resource(device_t dev, device_t child, in bus_generic_rl_release_resource() argument
4308 if (device_get_parent(child) != dev) in bus_generic_rl_release_resource()
4309 return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, r)); in bus_generic_rl_release_resource()
4311 rl = BUS_GET_RESOURCE_LIST(dev, child); in bus_generic_rl_release_resource()
4315 return (resource_list_release(rl, dev, child, r)); in bus_generic_rl_release_resource()
4326 bus_generic_rl_alloc_resource(device_t dev, device_t child, int type, in bus_generic_rl_alloc_resource() argument
4331 if (device_get_parent(child) != dev) in bus_generic_rl_alloc_resource()
4332 return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, in bus_generic_rl_alloc_resource()
4335 rl = BUS_GET_RESOURCE_LIST(dev, child); in bus_generic_rl_alloc_resource()
4339 return (resource_list_alloc(rl, dev, child, type, rid, in bus_generic_rl_alloc_resource()
4351 bus_generic_rman_alloc_resource(device_t dev, device_t child, int type, in bus_generic_rman_alloc_resource() argument
4362 child); in bus_generic_rman_alloc_resource()
4369 if (bus_activate_resource(child, type, *rid, r) != 0) { in bus_generic_rman_alloc_resource()
4386 bus_generic_rman_adjust_resource(device_t dev, device_t child, in bus_generic_rman_adjust_resource() argument
4406 bus_generic_rman_release_resource(device_t dev, device_t child, in bus_generic_rman_release_resource() argument
4421 error = bus_deactivate_resource(child, r); in bus_generic_rman_release_resource()
4435 bus_generic_rman_activate_resource(device_t dev, device_t child, in bus_generic_rman_activate_resource() argument
4459 error = BUS_MAP_RESOURCE(dev, child, r, NULL, &map); in bus_generic_rman_activate_resource()
4468 error = intr_activate_irq(child, r); in bus_generic_rman_activate_resource()
4484 bus_generic_rman_deactivate_resource(device_t dev, device_t child, in bus_generic_rman_deactivate_resource() argument
4509 BUS_UNMAP_RESOURCE(dev, child, r, &map); in bus_generic_rman_deactivate_resource()
4514 intr_deactivate_irq(child, r); in bus_generic_rman_deactivate_resource()
4525 * BUS_CHILD_PRESENT() method of the parent of @p dev.
4528 bus_generic_child_present(device_t dev, device_t child) in bus_generic_child_present() argument
4537 * BUS_GET_DOMAIN() method of the parent of @p dev. If @p dev
4538 * does not have a parent, the function fails with ENOENT.
4541 bus_generic_get_domain(device_t dev, device_t child, int *domain) in bus_generic_get_domain() argument
4543 if (dev->parent) in bus_generic_get_domain()
4544 return (BUS_GET_DOMAIN(dev->parent, dev, domain)); in bus_generic_get_domain()
4553 * a parent and (b) Knows how to supply a FreeBSD locator.
4556 * @param child leaf node to print information about
4561 bus_generic_get_device_path(device_t bus, device_t child, const char *locator, in bus_generic_get_device_path() argument
4565 device_t parent; in bus_generic_get_device_path() local
4572 * node. That's why we recurse with parent, bus rather than the typical in bus_generic_get_device_path()
4573 * parent, child: each spot in the tree is independent of what our child in bus_generic_get_device_path()
4576 parent = device_get_parent(bus); in bus_generic_get_device_path()
4577 if (parent != NULL && strcmp(locator, BUS_LOCATOR_ACPI) != 0) { in bus_generic_get_device_path()
4578 rv = BUS_GET_DEVICE_PATH(parent, bus, locator, sb); in bus_generic_get_device_path()
4582 sbuf_printf(sb, "/%s", device_get_nameunit(child)); in bus_generic_get_device_path()
4608 * resource-management functions. All these really do is hide the
4609 * indirection through the parent's method table, making for slightly
4610 * less-wordy code. In the future, it might make sense for this code
4620 for (i = 0; rs[i].type != -1; i++) in bus_alloc_resources()
4622 for (i = 0; rs[i].type != -1; i++) { in bus_alloc_resources()
4639 for (i = 0; rs[i].type != -1; i++) in bus_release_resources()
4651 * parent of @p dev.
4659 if (dev->parent == NULL)
4661 res = BUS_ALLOC_RESOURCE(dev->parent, dev, type, rid, start, end,
4670 * parent of @p dev.
4676 if (dev->parent == NULL) in bus_adjust_resource()
4678 return (BUS_ADJUST_RESOURCE(dev->parent, dev, r, start, end)); in bus_adjust_resource()
4692 * parent of @p dev.
4698 if (dev->parent == NULL) in bus_translate_resource()
4700 return (BUS_TRANSLATE_RESOURCE(dev->parent, type, start, newstart)); in bus_translate_resource()
4707 * parent of @p dev.
4712 if (dev->parent == NULL) in bus_activate_resource()
4714 return (BUS_ACTIVATE_RESOURCE(dev->parent, dev, r)); in bus_activate_resource()
4727 * parent of @p dev.
4732 if (dev->parent == NULL) in bus_deactivate_resource()
4734 return (BUS_DEACTIVATE_RESOURCE(dev->parent, dev, r)); in bus_deactivate_resource()
4747 * parent of @p dev.
4753 if (dev->parent == NULL) in bus_map_resource()
4755 return (BUS_MAP_RESOURCE(dev->parent, dev, r, args, map)); in bus_map_resource()
4769 * parent of @p dev.
4774 if (dev->parent == NULL) in bus_unmap_resource()
4776 return (BUS_UNMAP_RESOURCE(dev->parent, dev, r, map)); in bus_unmap_resource()
4790 * parent of @p dev.
4797 if (dev->parent == NULL) in bus_release_resource()
4799 rv = BUS_RELEASE_RESOURCE(dev->parent, dev, r); in bus_release_resource()
4813 * parent of @p dev.
4821 if (dev->parent == NULL) in bus_setup_intr()
4823 error = BUS_SETUP_INTR(dev->parent, dev, r, flags, filter, handler, in bus_setup_intr()
4828 device_printf(dev, "[GIANT-LOCKED]\n"); in bus_setup_intr()
4836 * parent of @p dev.
4841 if (dev->parent == NULL) in bus_teardown_intr()
4843 return (BUS_TEARDOWN_INTR(dev->parent, dev, r, cookie)); in bus_teardown_intr()
4850 * parent of @p dev.
4855 if (dev->parent == NULL) in bus_suspend_intr()
4857 return (BUS_SUSPEND_INTR(dev->parent, dev, r)); in bus_suspend_intr()
4864 * parent of @p dev.
4869 if (dev->parent == NULL) in bus_resume_intr()
4871 return (BUS_RESUME_INTR(dev->parent, dev, r)); in bus_resume_intr()
4878 * parent of @p dev.
4883 if (dev->parent == NULL) in bus_bind_intr()
4885 return (BUS_BIND_INTR(dev->parent, dev, r, cpu)); in bus_bind_intr()
4893 * the parent of @p dev.
4902 if (dev->parent == NULL) in bus_describe_intr()
4907 return (BUS_DESCRIBE_INTR(dev->parent, dev, irq, cookie, descr)); in bus_describe_intr()
4914 * parent of @p dev.
4928 * parent of @p dev.
4942 * parent of @p dev and returns the start value.
4962 * parent of @p dev and returns the count value.
4982 * parent of @p dev.
4994 * parent of @p dev.
4997 bus_child_present(device_t child) in bus_child_present() argument
4999 return (BUS_CHILD_PRESENT(device_get_parent(child), child)); in bus_child_present()
5005 * This function simply calls the BUS_CHILD_PNPINFO() method of the parent of @p
5009 bus_child_pnpinfo(device_t child, struct sbuf *sb) in bus_child_pnpinfo() argument
5011 device_t parent; in bus_child_pnpinfo() local
5013 parent = device_get_parent(child); in bus_child_pnpinfo()
5014 if (parent == NULL) in bus_child_pnpinfo()
5016 return (BUS_CHILD_PNPINFO(parent, child, sb)); in bus_child_pnpinfo()
5026 bus_generic_child_pnpinfo(device_t dev, device_t child, struct sbuf *sb) in bus_generic_child_pnpinfo() argument
5034 * This function simply calls the BUS_CHILD_LOCATION() method of the parent of
5038 bus_child_location(device_t child, struct sbuf *sb) in bus_child_location() argument
5040 device_t parent; in bus_child_location() local
5042 parent = device_get_parent(child); in bus_child_location()
5043 if (parent == NULL) in bus_child_location()
5045 return (BUS_CHILD_LOCATION(parent, child, sb)); in bus_child_location()
5055 bus_generic_child_location(device_t dev, device_t child, struct sbuf *sb) in bus_generic_child_location() argument
5064 * parent of @p dev.
5069 device_t parent; in bus_get_cpus() local
5071 parent = device_get_parent(dev); in bus_get_cpus()
5072 if (parent == NULL) in bus_get_cpus()
5074 return (BUS_GET_CPUS(parent, dev, op, setsize, cpuset)); in bus_get_cpus()
5081 * parent of @p dev.
5086 device_t parent; in bus_get_dma_tag() local
5088 parent = device_get_parent(dev); in bus_get_dma_tag()
5089 if (parent == NULL) in bus_get_dma_tag()
5091 return (BUS_GET_DMA_TAG(parent, dev)); in bus_get_dma_tag()
5098 * parent of @p dev.
5103 device_t parent; in bus_get_bus_tag() local
5105 parent = device_get_parent(dev); in bus_get_bus_tag()
5106 if (parent == NULL) in bus_get_bus_tag()
5108 return (BUS_GET_BUS_TAG(parent, dev)); in bus_get_bus_tag()
5115 * parent of @p dev.
5137 root_print_child(device_t dev, device_t child) in root_print_child() argument
5141 retval += bus_print_child_header(dev, child); in root_print_child()
5148 root_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, in root_setup_intr() argument
5160 * this call long before it gets here. We return -1 so that drivers that
5161 * really care can check vs -1 or some ERRNO returned higher in the food
5165 root_child_present(device_t dev, device_t child) in root_child_present() argument
5167 return (-1); in root_child_present()
5171 root_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize, in root_get_cpus() argument
5220 root_bus->desc = "System root bus"; in root_bus_module_handler()
5222 root_bus->driver = &root_driver; in root_bus_module_handler()
5223 root_bus->state = DS_ATTACHED; in root_bus_module_handler()
5249 * device_probe_and_attach() for each child of the @c root0 device.
5277 bus_devclass = devclass_find_internal(dmd->dmd_busname, NULL, TRUE); in driver_module_handler()
5282 if (dmd->dmd_chainevh) in driver_module_handler()
5283 error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg); in driver_module_handler()
5285 pass = dmd->dmd_pass; in driver_module_handler()
5286 driver = dmd->dmd_driver; in driver_module_handler()
5288 DRIVERNAME(driver), dmd->dmd_busname, pass)); in driver_module_handler()
5290 dmd->dmd_devclass); in driver_module_handler()
5295 DRIVERNAME(dmd->dmd_driver), in driver_module_handler()
5296 dmd->dmd_busname)); in driver_module_handler()
5298 dmd->dmd_driver); in driver_module_handler()
5300 if (!error && dmd->dmd_chainevh) in driver_module_handler()
5301 error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg); in driver_module_handler()
5305 DRIVERNAME(dmd->dmd_driver), in driver_module_handler()
5306 dmd->dmd_busname)); in driver_module_handler()
5308 dmd->dmd_driver); in driver_module_handler()
5310 if (!error && dmd->dmd_chainevh) in driver_module_handler()
5311 error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg); in driver_module_handler()
5368 dev->unit, dev->desc, in print_device_short()
5369 (dev->parent? "":"no "), in print_device_short()
5370 (TAILQ_EMPTY(&dev->children)? "no ":""), in print_device_short()
5371 (dev->flags&DF_ENABLED? "enabled,":"disabled,"), in print_device_short()
5372 (dev->flags&DF_FIXEDCLASS? "fixed,":""), in print_device_short()
5373 (dev->flags&DF_WILDCARD? "wildcard,":""), in print_device_short()
5374 (dev->flags&DF_DESCMALLOCED? "descmalloced,":""), in print_device_short()
5375 (dev->flags&DF_SUSPENDED? "suspended,":""), in print_device_short()
5376 (dev->ivars? "":"no "), in print_device_short()
5377 (dev->softc? "":"no "), in print_device_short()
5378 dev->busy)); in print_device_short()
5389 indentprintf(("Parent:\n")); in print_device()
5390 print_device_short(dev->parent, indent+1); in print_device()
5392 print_driver_short(dev->driver, indent+1); in print_device()
5394 print_devclass_short(dev->devclass, indent+1); in print_device()
5401 device_t child; in print_device_tree_short() local
5408 TAILQ_FOREACH(child, &dev->children, link) { in print_device_tree_short()
5409 print_device_tree_short(child, indent+1); in print_device_tree_short()
5417 device_t child; in print_device_tree() local
5424 TAILQ_FOREACH(child, &dev->children, link) { in print_device_tree()
5425 print_device_tree(child, indent+1); in print_device_tree()
5436 driver->name, driver->size)); in print_driver_short()
5454 print_driver(driver->driver, indent); in print_driver_list()
5464 indentprintf(("devclass %s: max units = %d\n", dc->name, dc->maxunit)); in print_devclass_short()
5477 print_driver_list(dc->drivers, indent+1); in print_devclass()
5480 for (i = 0; i < dc->maxunit; i++) in print_devclass()
5481 if (dc->devices[i]) in print_devclass()
5482 print_device(dc->devices[i], indent+1); in print_devclass()
5510 * User-space access to the device tree.
5535 "bus-related data");
5560 if (index-- == 0) in sysctl_devices()
5570 udev->dv_handle = (uintptr_t)dev; in sysctl_devices()
5571 udev->dv_parent = (uintptr_t)dev->parent; in sysctl_devices()
5572 udev->dv_devflags = dev->devflags; in sysctl_devices()
5573 udev->dv_flags = dev->flags; in sysctl_devices()
5574 udev->dv_state = dev->state; in sysctl_devices()
5575 sbuf_new(&sb, udev->dv_fields, sizeof(udev->dv_fields), SBUF_FIXEDLEN); in sysctl_devices()
5576 if (dev->nameunit != NULL) in sysctl_devices()
5577 sbuf_cat(&sb, dev->nameunit); in sysctl_devices()
5579 if (dev->desc != NULL) in sysctl_devices()
5580 sbuf_cat(&sb, dev->desc); in sysctl_devices()
5582 if (dev->driver != NULL) in sysctl_devices()
5583 sbuf_cat(&sb, dev->driver->name); in sysctl_devices()
5631 if (dev->nameunit != NULL && strcmp(dev->nameunit, name) == 0) in device_lookup_by_name()
5650 if (memchr(req->dr_name, '\0', sizeof(req->dr_name)) == NULL) in find_device()
5657 dev = device_lookup_by_name(req->dr_name); in find_device()
5665 EVENTHANDLER_DIRECT_INVOKE(dev_lookup, req->dr_name, &dev); in find_device()
5677 for (dc = bus->devclass; dc != NULL; dc = dc->parent) { in driver_exists()
5687 device_t child; in device_gen_nomatch() local
5689 if (dev->flags & DF_NEEDNOMATCH && in device_gen_nomatch()
5690 dev->state == DS_NOTPRESENT) { in device_gen_nomatch()
5693 dev->flags &= ~DF_NEEDNOMATCH; in device_gen_nomatch()
5694 TAILQ_FOREACH(child, &dev->children, link) { in device_gen_nomatch()
5695 device_gen_nomatch(child); in device_gen_nomatch()
5713 TAILQ_FOREACH(dl, &dc->drivers, link) { in device_do_deferred_actions()
5714 if (dl->flags & DL_DEFERRED_PROBE) { in device_do_deferred_actions()
5715 devclass_driver_added(dc, dl->driver); in device_do_deferred_actions()
5716 dl->flags &= ~DL_DEFERRED_PROBE; in device_do_deferred_actions()
5722 * We also defer no-match events during a freeze. Walk the tree and in device_do_deferred_actions()
5723 * generate all the pent-up events that are still relevant. in device_do_deferred_actions()
5732 device_t parent; in device_get_path() local
5736 parent = device_get_parent(dev); in device_get_path()
5737 if (parent == NULL) { in device_get_path()
5740 error = BUS_GET_DEVICE_PATH(parent, dev, locator, sb); in device_get_path()
5809 if (!(req->dr_flags & DEVF_FORCE_DETACH)) { in devctl2_ioctl()
5828 if (dev->devclass != NULL) { in devctl2_ioctl()
5833 if (resource_disabled(dev->devclass->name, dev->unit)) in devctl2_ioctl()
5834 resource_unset_value(dev->devclass->name, in devctl2_ioctl()
5835 dev->unit, "disabled"); in devctl2_ioctl()
5838 if (!(dev->flags & DF_FIXEDCLASS)) in devctl2_ioctl()
5839 devclass_delete_device(dev->devclass, dev); in devctl2_ioctl()
5849 if (!(req->dr_flags & DEVF_FORCE_DETACH)) { in devctl2_ioctl()
5859 old = dev->flags; in devctl2_ioctl()
5860 dev->flags |= DF_FIXEDCLASS; in devctl2_ioctl()
5863 dev->flags &= ~DF_FIXEDCLASS; in devctl2_ioctl()
5893 error = copyinstr(req->dr_data, driver, sizeof(driver), NULL); in devctl2_ioctl()
5900 if (dev->devclass != NULL && in devctl2_ioctl()
5901 strcmp(driver, dev->devclass->name) == 0) in devctl2_ioctl()
5909 if (dev->parent == NULL) { in devctl2_ioctl()
5913 if (!driver_exists(dev->parent, driver)) { in devctl2_ioctl()
5925 if (req->dr_flags & DEVF_SET_DRIVER_DETACH) in devctl2_ioctl()
5933 /* Clear any previously-fixed device class and unit. */ in devctl2_ioctl()
5934 if (dev->flags & DF_FIXEDCLASS) in devctl2_ioctl()
5935 devclass_delete_device(dev->devclass, dev); in devctl2_ioctl()
5936 dev->flags |= DF_WILDCARD; in devctl2_ioctl()
5937 dev->unit = DEVICE_UNIT_ANY; in devctl2_ioctl()
5943 dev->flags |= DF_FIXEDCLASS; in devctl2_ioctl()
5948 if (!(dev->flags & DF_FIXEDCLASS)) { in devctl2_ioctl()
5953 if (req->dr_flags & DEVF_CLEAR_DRIVER_DETACH) in devctl2_ioctl()
5961 dev->flags &= ~DF_FIXEDCLASS; in devctl2_ioctl()
5962 dev->flags |= DF_WILDCARD; in devctl2_ioctl()
5963 devclass_delete_device(dev->devclass, dev); in devctl2_ioctl()
5974 device_t parent; in devctl2_ioctl() local
5976 parent = device_get_parent(dev); in devctl2_ioctl()
5977 if (parent == NULL) { in devctl2_ioctl()
5981 if (!(req->dr_flags & DEVF_FORCE_DELETE)) { in devctl2_ioctl()
5988 error = device_delete_child(parent, dev); in devctl2_ioctl()
6006 if ((req->dr_flags & ~(DEVF_RESET_DETACH)) != 0) { in devctl2_ioctl()
6015 req->dr_flags); in devctl2_ioctl()
6022 error = copyinstr(req->dr_buffer.buffer, locator, in devctl2_ioctl()
6031 if (req->dr_buffer.length < len) { in devctl2_ioctl()
6035 req->dr_buffer.buffer, len); in devctl2_ioctl()
6037 req->dr_buffer.length = len; in devctl2_ioctl()
6084 TAILQ_INIT(&dcp->dlc_list); in dev_wired_cache_init()
6094 TAILQ_FOREACH_SAFE(dln, &dcp->dlc_list, dln_link, tdln) { in dev_wired_cache_fini()
6105 TAILQ_FOREACH(dln, &dcp->dlc_list, dln_link) { in dev_wired_cache_lookup()
6106 if (strcmp(locator, dln->dln_locator) == 0) in dev_wired_cache_lookup()
6122 dln->dln_locator = (char *)(dln + 1); in dev_wired_cache_add()
6123 memcpy(__DECONST(char *, dln->dln_locator), locator, loclen); in dev_wired_cache_add()
6124 dln->dln_path = dln->dln_locator + loclen; in dev_wired_cache_add()
6125 memcpy(__DECONST(char *, dln->dln_path), path, pathlen); in dev_wired_cache_add()
6126 TAILQ_INSERT_HEAD(&dcp->dlc_list, dln, dln_link); in dev_wired_cache_add()
6144 len = cp - at; in dev_wired_cache_match()
6145 if (len > sizeof(locator) - 1) /* Skip too long locator */ in dev_wired_cache_match()
6166 if (error != 0 || res == NULL || res->dln_path == NULL) in dev_wired_cache_match()
6169 return (strcmp(res->dln_path, cp) == 0); in dev_wired_cache_match()
6179 LIST_FOREACH(e, &dev->props, link) { in device_prop_find()
6180 if (strcmp(name, e->name) == 0) in device_prop_find()
6205 e1->name = name; in device_set_prop()
6206 e1->val = val; in device_set_prop()
6207 e1->dtr = dtr; in device_set_prop()
6208 e1->dtr_ctx = dtr_ctx; in device_set_prop()
6209 LIST_INSERT_HEAD(&dev->props, e1, link); in device_set_prop()
6214 if (e->dtr != NULL) in device_set_prop()
6215 e->dtr(dev, name, e->val, e->dtr_ctx); in device_set_prop()
6216 e->val = val; in device_set_prop()
6217 e->dtr = dtr; in device_set_prop()
6218 e->dtr_ctx = dtr_ctx; in device_set_prop()
6219 LIST_INSERT_HEAD(&dev->props, e, link); in device_set_prop()
6233 *valp = e->val; in device_get_prop()
6248 if (e->dtr != NULL) in device_clear_prop()
6249 e->dtr(dev, e->name, e->val, e->dtr_ctx); in device_clear_prop()
6261 while ((e = LIST_FIRST(&dev->props)) != NULL) { in device_destroy_props()
6262 LIST_REMOVE_HEAD(&dev->props, link); in device_destroy_props()
6263 if (e->dtr != NULL) in device_destroy_props()
6264 e->dtr(dev, e->name, e->val, e->dtr_ctx); in device_destroy_props()
6344 db_printf(" driver: %s\n", DRIVERNAME(dev->driver)); in DB_SHOW_COMMAND()
6345 db_printf(" class: %s\n", DEVCLANAME(dev->devclass)); in DB_SHOW_COMMAND()
6347 db_printf(" parent: %p\n", dev->parent); in DB_SHOW_COMMAND()
6348 db_printf(" softc: %p\n", dev->softc); in DB_SHOW_COMMAND()
6349 db_printf(" ivars: %p\n", dev->ivars); in DB_SHOW_COMMAND()