summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-03-12 12:35:05 +0100
committerHans de Goede <hdegoede@redhat.com>2014-03-12 12:35:05 +0100
commit42910168adf682b1eec5d3298173789fcfdda927 (patch)
treea6080e7cac4033b89b9b1be4de4bb0563ede174b
parent37981fa7e168d2c5928f01797647150b1e89abee (diff)
Add a wcmClose helper function
This is a preparation patch for adding server managed fds support. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/wcmConfig.c13
-rw-r--r--src/xf86Wacom.c32
-rw-r--r--src/xf86Wacom.h3
3 files changed, 27 insertions, 21 deletions
diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index bb2c975..d19b9b4 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -601,11 +601,7 @@ static int wcmPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
wcmHotplugOthers(pInfo, oldname);
}
- if (pInfo->fd != -1)
- {
- close(pInfo->fd);
- pInfo->fd = -1;
- }
+ wcmClose(pInfo);
/* only link them once per port. We need to try for both tablet tool
* and touch since we do not know which tool will be added first.
@@ -623,12 +619,7 @@ SetupProc_fail:
if (common && priv)
common->wcmDevices = priv->next;
- if (pInfo->fd != -1)
- {
- close(pInfo->fd);
- pInfo->fd = -1;
- }
-
+ wcmClose(pInfo);
free(type);
free(oldname);
return BadMatch;
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index b0a60ff..3057d7a 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -55,6 +55,10 @@
#define XIGetKnownProperty(prop) 0
#endif
+#ifndef XI86_SERVER_FD
+#define XI86_SERVER_FD 0x20
+#endif
+
static int wcmDevOpen(DeviceIntPtr pWcm);
static int wcmReady(InputInfoPtr pInfo);
static void wcmDevReadInput(InputInfoPtr pInfo);
@@ -544,6 +548,22 @@ Bool wcmOpen(InputInfoPtr pInfo)
}
/*****************************************************************************
+ * wcmClose --
+ ****************************************************************************/
+
+void wcmClose(InputInfoPtr pInfo)
+{
+ WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
+
+ DBG(1, priv, "closing device file\n");
+
+ if (pInfo->fd > -1 && !(pInfo->flags & XI86_SERVER_FD)) {
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ }
+}
+
+/*****************************************************************************
* wcmDevOpen --
* Open the physical device and init information structs.
****************************************************************************/
@@ -564,12 +584,7 @@ static int wcmDevOpen(DeviceIntPtr pWcm)
if ((wcmOpen (pInfo) != Success) || !common->device_path)
{
DBG(1, priv, "Failed to open device (fd=%d)\n", pInfo->fd);
- if (pInfo->fd >= 0)
- {
- DBG(1, priv, "Closing device\n");
- xf86CloseSerial(pInfo->fd);
- }
- pInfo->fd = -1;
+ wcmClose(pInfo);
return FALSE;
}
@@ -745,10 +760,7 @@ static void wcmDevClose(InputInfoPtr pInfo)
{
pInfo->fd = -1;
if (!--common->fd_refs)
- {
- DBG(1, common, "Closing device; uninitializing.\n");
- xf86CloseSerial (common->fd);
- }
+ wcmClose(pInfo);
}
}
diff --git a/src/xf86Wacom.h b/src/xf86Wacom.h
index c0448f2..882d8cd 100644
--- a/src/xf86Wacom.h
+++ b/src/xf86Wacom.h
@@ -106,6 +106,9 @@ struct _WacomModule
/* Open the device with the right serial parmeters */
extern Bool wcmOpen(InputInfoPtr pInfo);
+/* Close the device */
+extern void wcmClose(InputInfoPtr pInfo);
+
/* device autoprobing */
char *wcmEventAutoDevProbe (InputInfoPtr pInfo);