From 48b489769e78fa20911630173ab708feecb0fb0e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 19 Dec 2013 11:28:40 +0100 Subject: xf86Events: refactor xf86VTLeave error handling Use kernel goto style error handling for xf86VTSwitchAway() failure. This makes it much easier to read the straight path. Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer --- hw/xfree86/common/xf86Events.c | 94 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index e4ec1774f..e0ec76825 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -454,62 +454,60 @@ xf86VTLeave(void) xf86AccessLeave(); /* We need this here, otherwise */ - if (!xf86VTSwitchAway()) { + if (!xf86VTSwitchAway()) + goto switch_failed; + +#ifdef XF86PM + if (xf86OSPMClose) + xf86OSPMClose(); + xf86OSPMClose = NULL; +#endif + + for (i = 0; i < xf86NumScreens; i++) { /* - * switch failed + * zero all access functions to + * trap calls when switched away. */ + xf86Screens[i]->vtSema = FALSE; + } + if (xorgHWAccess) + xf86DisableIO(); - DebugF("xf86VTSwitch: Leave failed\n"); - xf86AccessEnter(); - for (i = 0; i < xf86NumScreens; i++) { - if (!xf86Screens[i]->EnterVT(xf86Screens[i])) - FatalError("EnterVT failed for screen %d\n", i); - } - for (i = 0; i < xf86NumGPUScreens; i++) { - if (!xf86GPUScreens[i]->EnterVT(xf86GPUScreens[i])) - FatalError("EnterVT failed for gpu screen %d\n", i); - } - if (!(dispatchException & DE_TERMINATE)) { - for (i = 0; i < xf86NumScreens; i++) { - if (xf86Screens[i]->EnableDisableFBAccess) - (*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE); - } - } - dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); - - pInfo = xf86InputDevs; - while (pInfo) { - if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0) - EnableDevice(pInfo->dev, TRUE); - pInfo->flags &= ~XI86_DEVICE_DISABLED; - pInfo = pInfo->next; - } - for (ih = InputHandlers; ih; ih = ih->next) { - if (ih->is_input) - xf86EnableInputHandler(ih); - else - xf86EnableGeneralHandler(ih); - } - OsReleaseSIGIO(); + return; +switch_failed: + DebugF("xf86VTSwitch: Leave failed\n"); + xf86AccessEnter(); + for (i = 0; i < xf86NumScreens; i++) { + if (!xf86Screens[i]->EnterVT(xf86Screens[i])) + FatalError("EnterVT failed for screen %d\n", i); } - else { -#ifdef XF86PM - if (xf86OSPMClose) - xf86OSPMClose(); - xf86OSPMClose = NULL; -#endif - + for (i = 0; i < xf86NumGPUScreens; i++) { + if (!xf86GPUScreens[i]->EnterVT(xf86GPUScreens[i])) + FatalError("EnterVT failed for gpu screen %d\n", i); + } + if (!(dispatchException & DE_TERMINATE)) { for (i = 0; i < xf86NumScreens; i++) { - /* - * zero all access functions to - * trap calls when switched away. - */ - xf86Screens[i]->vtSema = FALSE; + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE); } - if (xorgHWAccess) - xf86DisableIO(); } + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); + + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0) + EnableDevice(pInfo->dev, TRUE); + pInfo->flags &= ~XI86_DEVICE_DISABLED; + pInfo = pInfo->next; + } + for (ih = InputHandlers; ih; ih = ih->next) { + if (ih->is_input) + xf86EnableInputHandler(ih); + else + xf86EnableGeneralHandler(ih); + } + OsReleaseSIGIO(); } void -- cgit v1.2.3