FreeBSD/sys/kern/subr_bus.c
/*
 * /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?
 */
/dev/devctl2 implementation.  The existing /dev/devctl device has
implicit semantics on open, so it could not be reused for this.
/ dev / devctl2 implementation . The existing / dev / devctl device has implicit semantics on open so it could not be reused for this .
static int
find_device(struct devreq *req, device_t *devp)
{
	device_t dev;
	if (memchr(req->dr_name, '\0', sizeof(req->dr_name)) == NULL)
		return (EINVAL);
	dev = device_lookup_by_name(req->dr_name);
	if (dev != NULL) {
		*devp = dev;
		return (0);
	}
	dev = NULL;
	EVENTHANDLER_INVOKE(dev_lookup, req->dr_name, &dev);
	if (dev == NULL)
		return (ENOENT);
	*devp = dev;
	return (0);
}
static int find_device ( struct devreq * req , device_t * devp ) { device_t dev ; if ( memchr ( req -> dr_name , ' \0 ' , sizeof ( req -> dr_name ) ) == NULL ) return ( EINVAL ) ; dev = device_lookup_by_name ( req -> dr_name ) ; if ( dev != NULL ) { * devp = dev ; return ( 0 ) ; } dev = NULL ; EVENTHANDLER_INVOKE ( dev_lookup , req -> dr_name , & dev ) ; if ( dev == NULL ) return ( ENOENT ) ; * devp = dev ; return ( 0 ) ; }
/dev/devctl2 implementation.
/ dev / devctl2 implementation .
/*
	 * First, ensure that the name is nul terminated.
	 */ /*
	 * Second, try to find an attached device whose name matches
	 * 'name'.
	 */ /* Finally, give device enumerators a chance. */