[PATCH 3/4] sun_init.c: Move vt switches to a switch_to helper function like lnx_init.c

Alan Coopersmith alan.coopersmith at oracle.com
Fri Aug 26 19:19:58 PDT 2011


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 hw/xfree86/os-support/solaris/sun_init.c |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index 281a6df..d8c897d 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -63,6 +63,22 @@ static char consoleDev[PATH_MAX] = "/dev/fb";
    Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */
 _X_HIDDEN char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
 
+static void
+switch_to(int vt, const char *from)
+{
+    int ret;
+
+    SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt));
+    if (ret != 0)
+        xf86Msg(X_WARNING, "%s: VT_ACTIVATE failed: %s\n",
+		from, strerror(errno));
+
+    SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt));
+    if (ret != 0)
+        xf86Msg(X_WARNING, "%s: VT_WAITACTIVE failed: %s\n",
+		from, strerror(errno));
+}
+
 void
 xf86OpenConsole(void)
 {
@@ -206,11 +222,7 @@ OPENCONSOLE:
 	    /*
 	     * Now get the VT
 	     */
-	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
-		xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
-
-	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
-		xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+	    switch_to(xf86Info.vtno, "xf86OpenConsole");
 
 #ifdef VT_SET_CONSUSER /* added in snv_139 */
 	    if (strcmp(display, "0") == 0)
@@ -254,11 +266,7 @@ OPENCONSOLE:
 	    /*
 	     * Now re-get the VT
 	     */
-	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
-		xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
-
-	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
-		xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+	    switch_to(xf86Info.vtno, "xf86OpenConsole");
 
 #ifdef VT_SET_CONSUSER /* added in snv_139 */
 	    if (strcmp(display, "0") == 0)
@@ -347,7 +355,7 @@ xf86CloseConsole(void)
 	}
 
 	/* Activate the VT that X was started on */
-	ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86StartVT);
+	switch_to(xf86StartVT, "xf86CloseConsole");
     }
 #endif /* HAS_USL_VTS */
 
-- 
1.7.3.2



More information about the xorg-devel mailing list