* /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? */
| 5593 | * Another option would be to call this /dev/bus? |
| 5594 | */ |
| 5595 | static int |
| 5596 | find_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 | |
| 5625 | static bool |
| 5626 | driver_exists(device_t bus, const char *driver) |
no test coverage detected