The branch main has been updated by dumbbell (ports committer):

URL: 
https://cgit.FreeBSD.org/src/commit/?id=29ab19455484be96150fa5e87bd38aefb85c888a

commit 29ab19455484be96150fa5e87bd38aefb85c888a
Author:     Jean-Sébastien Pédron <dumbb...@freebsd.org>
AuthorDate: 2023-01-14 18:22:56 +0000
Commit:     Jean-Sébastien Pédron <dumbb...@freebsd.org>
CommitDate: 2023-01-25 21:26:57 +0000

    vt(4): Return errors from `vt_{,de}allocate()`
    
    This is useful to the DRM drivers to let them know if a device is
    effectively used by the console.
    
    Reviewed by:    manu
    Approved by:    manu
    Differential Revision:  https://reviews.freebsd.org/D38089
---
 sys/dev/vt/hw/fb/vt_fb.c | 10 ++++++----
 sys/dev/vt/vt.h          |  4 ++--
 sys/dev/vt/vt_core.c     | 16 ++++++++++------
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c
index 093bf35ac6ba..8e0d6c035f9a 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -517,19 +517,21 @@ vt_fb_fini(struct vt_device *vd, void *softc)
 int
 vt_fb_attach(struct fb_info *info)
 {
+       int ret;
 
-       vt_allocate(&vt_fb_driver, info);
+       ret = vt_allocate(&vt_fb_driver, info);
 
-       return (0);
+       return (ret);
 }
 
 int
 vt_fb_detach(struct fb_info *info)
 {
+       int ret;
 
-       vt_deallocate(&vt_fb_driver, info);
+       ret = vt_deallocate(&vt_fb_driver, info);
 
-       return (0);
+       return (ret);
 }
 
 void
diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h
index 977372f04a7d..764d612ed060 100644
--- a/sys/dev/vt/vt.h
+++ b/sys/dev/vt/vt.h
@@ -91,8 +91,8 @@ SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, 
&vt_##_name, 0, _descr)
 
 struct vt_driver;
 
-void vt_allocate(const struct vt_driver *, void *);
-void vt_deallocate(const struct vt_driver *, void *);
+int vt_allocate(const struct vt_driver *, void *);
+int vt_deallocate(const struct vt_driver *, void *);
 
 typedef unsigned int   vt_axis_t;
 
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index 213b11bee8f5..2827cc1c85a8 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -3137,12 +3137,12 @@ vt_resume_handler(void *priv)
        vd->vd_flags &= ~VDF_SUSPENDED;
 }
 
-void
+int
 vt_allocate(const struct vt_driver *drv, void *softc)
 {
 
        if (!vty_enabled(VTY_VT))
-               return;
+               return (EINVAL);
 
        if (main_vd->vd_driver == NULL) {
                main_vd->vd_driver = drv;
@@ -3156,31 +3156,35 @@ vt_allocate(const struct vt_driver *drv, void *softc)
                if (drv->vd_priority <= main_vd->vd_driver->vd_priority) {
                        printf("VT: Driver priority %d too low. Current %d\n ",
                            drv->vd_priority, main_vd->vd_driver->vd_priority);
-                       return;
+                       return (EEXIST);
                }
                printf("VT: Replacing driver \"%s\" with new \"%s\".\n",
                    main_vd->vd_driver->vd_name, drv->vd_name);
        }
 
        vt_replace_backend(drv, softc);
+
+       return (0);
 }
 
-void
+int
 vt_deallocate(const struct vt_driver *drv, void *softc)
 {
 
        if (!vty_enabled(VTY_VT))
-               return;
+               return (EINVAL);
 
        if (main_vd->vd_prev_driver == NULL ||
            main_vd->vd_driver != drv ||
            main_vd->vd_softc != softc)
-               return;
+               return (EPERM);
 
        printf("VT: Switching back from \"%s\" to \"%s\".\n",
            main_vd->vd_driver->vd_name, main_vd->vd_prev_driver->vd_name);
 
        vt_replace_backend(NULL, NULL);
+
+       return (0);
 }
 
 void

Reply via email to