st/xorg: Fic bug and close drm_api at proper place
authorJakob Bornecrantz <jakob@vmware.com>
Wed, 20 Jan 2010 14:53:38 +0000 (14:53 +0000)
committerJakob Bornecrantz <jakob@vmware.com>
Wed, 20 Jan 2010 14:55:07 +0000 (14:55 +0000)
src/gallium/state_trackers/xorg/xorg_driver.c

index b74953e54327e6a47b38dc178f7a450a7ba0ed87..2714fba999dfd241d8fa91464767c6c951f905b5 100644 (file)
@@ -214,7 +214,7 @@ drv_init_drm(ScrnInfoPtr pScrn)
        if (ms->fd >= 0)
            return TRUE;
 
-       if (ms->api->destroy)
+       if (ms->api && ms->api->destroy)
            ms->api->destroy(ms->api);
 
        ms->api = NULL;
@@ -225,6 +225,21 @@ drv_init_drm(ScrnInfoPtr pScrn)
     return TRUE;
 }
 
+static Bool
+drv_close_drm(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+
+    if (ms->api && ms->api->destroy)
+       ms->api->destroy(ms->api);
+    ms->api = NULL;
+
+    drmClose(ms->fd);
+    ms->fd = -1;
+
+    return TRUE;
+}
+
 static Bool
 drv_init_resource_management(ScrnInfoPtr pScrn)
 {
@@ -278,10 +293,6 @@ drv_close_resource_management(ScrnInfoPtr pScrn)
     }
     ms->screen = NULL;
 
-    if (ms->api && ms->api->destroy)
-       ms->api->destroy(ms->api);
-    ms->api = NULL;
-
 #ifdef HAVE_LIBKMS
     if (ms->kms)
        kms_destroy(&ms->kms);
@@ -832,8 +843,7 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
 
     drv_close_resource_management(pScrn);
 
-    drmClose(ms->fd);
-    ms->fd = -1;
+    drv_close_drm(pScrn);
 
     pScrn->vtSema = FALSE;
     pScreen->CloseScreen = ms->CloseScreen;