Index: sys/dev/wscons/wsdisplay.c =================================================================== RCS file: /cvsroot/src/sys/dev/wscons/wsdisplay.c,v retrieving revision 1.166 diff -p -u -r1.166 wsdisplay.c --- sys/dev/wscons/wsdisplay.c 1 Mar 2023 08:42:33 -0000 1.166 +++ sys/dev/wscons/wsdisplay.c 21 Apr 2024 10:07:42 -0000 @@ -182,13 +182,15 @@ static void wsdisplay_emul_attach(device static int wsdisplay_emul_detach(device_t, int); static int wsdisplay_noemul_match(device_t, cfdata_t, void *); static void wsdisplay_noemul_attach(device_t, device_t, void *); +static int wsdisplay_noemul_detach(device_t, int); static bool wsdisplay_suspend(device_t, const pmf_qual_t *); CFATTACH_DECL_NEW(wsdisplay_emul, sizeof (struct wsdisplay_softc), wsdisplay_emul_match, wsdisplay_emul_attach, wsdisplay_emul_detach, NULL); CFATTACH_DECL_NEW(wsdisplay_noemul, sizeof (struct wsdisplay_softc), - wsdisplay_noemul_match, wsdisplay_noemul_attach, NULL, NULL); + wsdisplay_noemul_match, wsdisplay_noemul_attach, wsdisplay_noemul_detach, + NULL); dev_type_open(wsdisplayopen); dev_type_close(wsdisplayclose); @@ -233,6 +235,7 @@ static void wsdisplay_common_attach(stru int console, int kbdmux, const struct wsscreen_list *, const struct wsdisplay_accessops *accessops, void *accesscookie); +static int wsdisplay_common_detach(struct wsdisplay_softc *sc, int how); #ifdef WSDISPLAY_COMPAT_RAWKBD int wsdisplay_update_rawkbd(struct wsdisplay_softc *, @@ -657,6 +660,14 @@ wsdisplay_emul_attach(device_t parent, d } } +int +wsdisplay_emul_detach(device_t dev, int how) +{ + struct wsdisplay_softc *sc = device_private(dev); + + return wsdisplay_common_detach(sc, how); +} + /* Print function (for parent devices). */ int wsemuldisplaydevprint(void *aux, const char *pnp) @@ -675,25 +686,6 @@ wsemuldisplaydevprint(void *aux, const c } int -wsdisplay_emul_detach(device_t dev, int how) -{ - struct wsdisplay_softc *sc = device_private(dev); - int flag, i, res; - - flag = (how & DETACH_FORCE ? WSDISPLAY_DELSCR_FORCE : 0); - for (i = 0; i < WSDISPLAY_MAXSCREEN; i++) - if (sc->sc_scr[i]) { - res = wsdisplay_delscreen(sc, i, flag); - if (res) - return res; - } - - cv_destroy(&sc->sc_flagscv); - mutex_destroy(&sc->sc_flagsmtx); - return 0; -} - -int wsdisplay_noemul_match(device_t parent, cfdata_t match, void *aux) { #if 0 /* -Wunused */ @@ -717,6 +709,14 @@ wsdisplay_noemul_attach(device_t parent, ap->accessops, ap->accesscookie); } +int +wsdisplay_noemul_detach(device_t dev, int how) +{ + struct wsdisplay_softc *sc = device_private(dev); + + return wsdisplay_common_detach(sc, how); +} + static void wsdisplay_swdone_cb(void *arg, int error, int waitok) { @@ -917,6 +917,27 @@ wsdisplay_common_attach(struct wsdisplay "couldn't establish power handler\n"); } +static int +wsdisplay_common_detach(struct wsdisplay_softc *sc, int how) +{ + int flag, i, res; + + pmf_device_deregister(sc->sc_dev); + + flag = (how & DETACH_FORCE ? WSDISPLAY_DELSCR_FORCE : 0); + for (i = 0; i < WSDISPLAY_MAXSCREEN; i++) + if (sc->sc_scr[i]) { + res = wsdisplay_delscreen(sc, i, flag); + if (res) + return res; + } + + cv_destroy(&sc->sc_flagscv); + mutex_destroy(&sc->sc_flagsmtx); + + return 0; +} + void wsdisplay_cnattach(const struct wsscreen_descr *type, void *cookie, int ccol, int crow, long defattr)