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

Function device_find_child

freebsd/kern/subr_bus.c:2015–2037  ·  view source on GitHub ↗

* @brief Find a device given a unit number * * This is similar to devclass_get_devices() but only searches for * devices which have @p dev as a parent. * * @param dev the parent device to search * @param unit the unit number to search for. If the unit is -1, * return the first child of @p dev which has name * @p classname (that is, the one with the lowest unit.) * * @returns the

Source from the content-addressed store, hash-verified

2013 * NULL if there is no such device
2014 */
2015device_t
2016device_find_child(device_t dev, const char *classname, int unit)
2017{
2018 devclass_t dc;
2019 device_t child;
2020
2021 dc = devclass_find(classname);
2022 if (!dc)
2023 return (NULL);
2024
2025 if (unit != -1) {
2026 child = devclass_get_device(dc, unit);
2027 if (child && child->parent == dev)
2028 return (child);
2029 } else {
2030 for (unit = 0; unit < devclass_get_maxunit(dc); unit++) {
2031 child = devclass_get_device(dc, unit);
2032 if (child && child->parent == dev)
2033 return (child);
2034 }
2035 }
2036 return (NULL);
2037}
2038
2039/**
2040 * @internal

Callers 15

ossl_identifyFunction · 0.85
blake2_identifyFunction · 0.85
aesni_identifyFunction · 0.85
armv8_crypto_identifyFunction · 0.85
padlock_identifyFunction · 0.85
ivhd_identifyFunction · 0.85
am335x_scm_identifyFunction · 0.85
bcm2835_cpufreq_identifyFunction · 0.85

Calls 3

devclass_findFunction · 0.85
devclass_get_deviceFunction · 0.85
devclass_get_maxunitFunction · 0.85

Tested by

no test coverage detected