The branch stable/13 has been updated by dumbbell (ports committer):

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

commit a0bf2c3aab9dded785f2a406744e673a291e26c1
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-02-16 11:55:13 +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
    
    (cherry picked from commit 29ab19455484be96150fa5e87bd38aefb85c888a)
---
 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 2f6c4c3939d5..a84e182ef557 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -509,19 +509,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 e148fa4f8d7d..72e3e8f24883 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -3138,12 +3138,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;
@@ -3157,31 +3157,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