if (ms->fd >= 0)
return TRUE;
- if (ms->api->destroy)
+ if (ms->api && ms->api->destroy)
ms->api->destroy(ms->api);
ms->api = NULL;
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)
{
}
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);
drv_close_resource_management(pScrn);
- drmClose(ms->fd);
- ms->fd = -1;
+ drv_close_drm(pScrn);
pScrn->vtSema = FALSE;
pScreen->CloseScreen = ms->CloseScreen;