From 7e127f12a24acb8f43055af0a9be1ec585bbed36 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 19 May 2011 23:22:27 -0700 Subject: [PATCH] sun_init.c: Move vt switches to a switch_to helper function like lnx_init.c Signed-off-by: Alan Coopersmith Reviewed-by: Julien Cristau --- hw/xfree86/os-support/solaris/sun_init.c | 30 +++++++++++++++--------- 1 file 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 281a6df9f..d8c897d43 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 */