int wsmouse_mux_open(struct wsevsrc *me, struct wseventvar *evp) { struct wsmouse_softc *sc = (struct wsmouse_softc *)me; if (sc->sc_base.me_evp != NULL) return (EBUSY); return wsmousedoopen(sc, evp); }
int wsmouseopen(dev_t dev, int flags, int mode, struct proc *p) { struct wsmouse_softc *sc; struct wseventvar *evar; int error, unit; unit = minor(dev); if (unit >= wsmouse_cd.cd_ndevs || /* make sure it was attached */ (sc = wsmouse_cd.cd_devs[unit]) == NULL) return (ENXIO); #if NWSMUX > 0 DPRINTF(("wsmouseopen: %s mux=%p p=%p\n", sc->sc_base.me_dv.dv_xname, sc->sc_base.me_parent, p)); #endif if (sc->sc_dying) return (EIO); if ((flags & (FREAD | FWRITE)) == FWRITE) return (0); /* always allow open for write so ioctl() is possible. */ #if NWSMUX > 0 if (sc->sc_base.me_parent != NULL) { /* Grab the mouse out of the greedy hands of the mux. */ DPRINTF(("wsmouseopen: detach\n")); wsmux_detach_sc(&sc->sc_base); } #endif if (sc->sc_base.me_evp != NULL) return (EBUSY); evar = &sc->sc_base.me_evar; wsevent_init(evar); evar->io = p->p_p; error = wsmousedoopen(sc, evar); if (error) { DPRINTF(("wsmouseopen: %s open failed\n", sc->sc_base.me_dv.dv_xname)); sc->sc_base.me_evp = NULL; wsevent_fini(evar); } return (error); }
int wsmouseopen(dev_t dev, int flags, int mode, struct lwp *l) { struct wsmouse_softc *sc; struct wseventvar *evar; int error; sc = device_lookup_private(&wsmouse_cd, minor(dev)); if (sc == NULL) return ENXIO; #if NWSMUX > 0 DPRINTF(("wsmouseopen: %s mux=%p p=%p\n", device_xname(sc->sc_base.me_dv), sc->sc_base.me_parent, l)); #endif if (sc->sc_dying) return (EIO); if ((flags & (FREAD | FWRITE)) == FWRITE) return (0); /* always allow open for write so ioctl() is possible. */ if (sc->sc_base.me_evp != NULL) return (EBUSY); evar = &sc->sc_base.me_evar; wsevent_init(evar, l->l_proc); sc->sc_base.me_evp = evar; error = wsmousedoopen(sc, evar); if (error) { DPRINTF(("wsmouseopen: %s open failed\n", device_xname(sc->sc_base.me_dv))); sc->sc_base.me_evp = NULL; wsevent_fini(evar); } return (error); }