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

Function find_device

freebsd/kern/subr_bus.c:5595–5623  ·  view source on GitHub ↗

* /dev/devctl2 implementation. The existing /dev/devctl device has * implicit semantics on open, so it could not be reused for this. * Another option would be to call this /dev/bus? */

Source from the content-addressed store, hash-verified

5593 * Another option would be to call this /dev/bus?
5594 */
5595static int
5596find_device(struct devreq *req, device_t *devp)
5597{
5598 device_t dev;
5599
5600 /*
5601 * First, ensure that the name is nul terminated.
5602 */
5603 if (memchr(req->dr_name, '\0', sizeof(req->dr_name)) == NULL)
5604 return (EINVAL);
5605
5606 /*
5607 * Second, try to find an attached device whose name matches
5608 * 'name'.
5609 */
5610 dev = device_lookup_by_name(req->dr_name);
5611 if (dev != NULL) {
5612 *devp = dev;
5613 return (0);
5614 }
5615
5616 /* Finally, give device enumerators a chance. */
5617 dev = NULL;
5618 EVENTHANDLER_DIRECT_INVOKE(dev_lookup, req->dr_name, &dev);
5619 if (dev == NULL)
5620 return (ENOENT);
5621 *devp = dev;
5622 return (0);
5623}
5624
5625static bool
5626driver_exists(device_t bus, const char *driver)

Callers 4

devctl2_ioctlFunction · 0.85
rte_pci_dev_iterateFunction · 0.85
cdx_dev_iterateFunction · 0.85
auxiliary_dev_iterateFunction · 0.85

Calls 2

memchrFunction · 0.85
device_lookup_by_nameFunction · 0.85

Tested by

no test coverage detected