summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2017-03-06 18:59:23 +0900
committerMichel Dänzer <michel@daenzer.net>2017-03-07 16:57:51 +0900
commita2c360fa1d33d6a5aa64c396197e119ff77d1379 (patch)
tree3d645cb5374e2a1852fb5291a9a64e5eca23acd6 /src
parent947017194d07e32876a43ee0efc45fdc71385748 (diff)
Refactor amdgpu_kernel_close_fd helper
Preparation for the following change. Assign pAMDGPUEnt->fd = -1 instead of 0 when we're not using the file descriptor anymore. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src')
-rw-r--r--src/amdgpu_kms.c7
-rw-r--r--src/amdgpu_probe.c10
-rw-r--r--src/amdgpu_probe.h2
3 files changed, 13 insertions, 6 deletions
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 31c2e86..92bf5fa 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -132,12 +132,7 @@ static void AMDGPUFreeRec(ScrnInfoPtr pScrn)
pAMDGPUEnt->fd_ref--;
if (!pAMDGPUEnt->fd_ref) {
amdgpu_device_deinitialize(pAMDGPUEnt->pDev);
-#ifdef XF86_PDEV_SERVER_FD
- if (!(pAMDGPUEnt->platform_dev &&
- pAMDGPUEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
-#endif
- drmClose(pAMDGPUEnt->fd);
- pAMDGPUEnt->fd = 0;
+ amdgpu_kernel_close_fd(pAMDGPUEnt);
}
}
diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index 94da7f6..fc93ac6 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -134,6 +134,16 @@ static int amdgpu_kernel_open_fd(ScrnInfoPtr pScrn, char *busid,
return fd;
}
+void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt)
+{
+#ifdef XF86_PDEV_SERVER_FD
+ if (!(pAMDGPUEnt->platform_dev &&
+ pAMDGPUEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
+#endif
+ drmClose(pAMDGPUEnt->fd);
+ pAMDGPUEnt->fd = -1;
+}
+
static Bool amdgpu_open_drm_master(ScrnInfoPtr pScrn, AMDGPUEntPtr pAMDGPUEnt,
char *busid)
{
diff --git a/src/amdgpu_probe.h b/src/amdgpu_probe.h
index 0f43233..9e4a9a4 100644
--- a/src/amdgpu_probe.h
+++ b/src/amdgpu_probe.h
@@ -71,6 +71,8 @@ typedef struct {
char *render_node;
} AMDGPUEntRec, *AMDGPUEntPtr;
+extern void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt);
+
extern const OptionInfoRec *AMDGPUOptionsWeak(void);
extern Bool AMDGPUPreInit_KMS(ScrnInfoPtr, int);