Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/vmm_dev.c
| Show First 20 Lines • Show All 1,219 Lines • ▼ Show 20 Lines | |||||
| static int | static int | ||||
| devmem_create_cdev(const char *vmname, int segid, char *devname) | devmem_create_cdev(const char *vmname, int segid, char *devname) | ||||
| { | { | ||||
| struct devmem_softc *dsc; | struct devmem_softc *dsc; | ||||
| struct vmmdev_softc *sc; | struct vmmdev_softc *sc; | ||||
| struct cdev *cdev; | struct cdev *cdev; | ||||
| int error; | int error; | ||||
| error = make_dev_p(MAKEDEV_CHECKNAME, &cdev, &devmemsw, NULL, | mtx_lock(&vmmdev_mtx); | ||||
| sc = vmmdev_lookup(vmname); | |||||
| KASSERT(sc != NULL, ("%s: vm %s softc not found", __func__, vmname)); | |||||
| mtx_unlock(&vmmdev_mtx); | |||||
markj: I think it'd be a bit nicer to change devmem_create_cdev() to pass the vmmdev_softc in directly. | |||||
| error = make_dev_p(MAKEDEV_CHECKNAME, &cdev, &devmemsw, sc->ucred, | |||||
| UID_ROOT, GID_WHEEL, 0600, "vmm.io/%s.%s", vmname, devname); | UID_ROOT, GID_WHEEL, 0600, "vmm.io/%s.%s", vmname, devname); | ||||
| if (error) | if (error) | ||||
| return (error); | return (error); | ||||
| dsc = malloc(sizeof(struct devmem_softc), M_VMMDEV, M_WAITOK | M_ZERO); | dsc = malloc(sizeof(struct devmem_softc), M_VMMDEV, M_WAITOK | M_ZERO); | ||||
| mtx_lock(&vmmdev_mtx); | mtx_lock(&vmmdev_mtx); | ||||
| sc = vmmdev_lookup(vmname); | sc = vmmdev_lookup(vmname); | ||||
| Show All 30 Lines | |||||
I think it'd be a bit nicer to change devmem_create_cdev() to pass the vmmdev_softc in directly. This function is static, so its usage is confined to this file and there's no real reason to avoid modifying its signature if it makes the code simpler.