[PATCH synaptics v2 1/2] On/Off hooks to return boolean so we can bail out of the caller

Alexandr Shadchin alexandr.shadchin at gmail.com
Fri Aug 26 05:42:07 PDT 2011


Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
---

s/RetValue/rc/

 src/eventcomm.c |    5 ++++-
 src/ps2comm.c   |    4 +++-
 src/synaptics.c |   13 ++++++++-----
 src/synproto.h  |    4 ++--
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/eventcomm.c b/src/eventcomm.c
index d70e735..e0a6965 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -61,7 +61,7 @@ struct eventcomm_proto_data
     BOOL need_grab;
 };
 
-static void
+static Bool
 EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters *para)
 {
     SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
@@ -79,10 +79,13 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters *para)
 	if (ret < 0) {
 	    xf86IDrvMsg(pInfo, X_WARNING, "can't grab event device, errno=%d\n",
 			errno);
+	    return FALSE;
 	}
     }
 
     proto_data->need_grab = FALSE;
+
+    return TRUE;
 }
 
 /**
diff --git a/src/ps2comm.c b/src/ps2comm.c
index 3178175..b7995ee 100644
--- a/src/ps2comm.c
+++ b/src/ps2comm.c
@@ -369,11 +369,13 @@ ps2_print_ident(InputInfoPtr pInfo, const struct PS2SynapticsHwInfo *synhw)
     }
 }
 
-static void
+static Bool
 PS2DeviceOffHook(InputInfoPtr pInfo)
 {
     ps2_synaptics_reset(pInfo->fd);
     ps2_synaptics_enable_device(pInfo->fd);
+
+    return TRUE;
 }
 
 static Bool
diff --git a/src/synaptics.c b/src/synaptics.c
index 2f60322..c043b5d 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -845,8 +845,9 @@ DeviceOn(DeviceIntPtr dev)
 	return !Success;
     }
 
-    if (priv->proto_ops->DeviceOnHook)
-        priv->proto_ops->DeviceOnHook(pInfo, &priv->synpara);
+    if (priv->proto_ops->DeviceOnHook &&
+        !priv->proto_ops->DeviceOnHook(pInfo, &priv->synpara))
+        return !Success;
 
     priv->comm.buffer = XisbNew(pInfo->fd, INPUT_BUFFER_SIZE);
     if (!priv->comm.buffer) {
@@ -878,14 +879,16 @@ DeviceOff(DeviceIntPtr dev)
 {
     InputInfoPtr pInfo = dev->public.devicePrivate;
     SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
+    Bool rc = Success;
 
     DBG(3, "Synaptics DeviceOff called\n");
 
     if (pInfo->fd != -1) {
 	TimerCancel(priv->timer);
 	xf86RemoveEnabledDevice(pInfo);
-        if (priv->proto_ops->DeviceOffHook)
-            priv->proto_ops->DeviceOffHook(pInfo);
+        if (priv->proto_ops->DeviceOffHook &&
+            !priv->proto_ops->DeviceOffHook(pInfo))
+            rc = !Success;
 	if (priv->comm.buffer) {
 	    XisbFree(priv->comm.buffer);
 	    priv->comm.buffer = NULL;
@@ -894,7 +897,7 @@ DeviceOff(DeviceIntPtr dev)
 	pInfo->fd = -1;
     }
     dev->public.on = FALSE;
-    return Success;
+    return rc;
 }
 
 static Bool
diff --git a/src/synproto.h b/src/synproto.h
index f9af37c..6962bbf 100644
--- a/src/synproto.h
+++ b/src/synproto.h
@@ -70,8 +70,8 @@ struct CommData {
 struct _SynapticsParameters;
 
 struct SynapticsProtocolOperations {
-    void (*DeviceOnHook)(InputInfoPtr pInfo, struct _SynapticsParameters *para);
-    void (*DeviceOffHook)(InputInfoPtr pInfo);
+    Bool (*DeviceOnHook)(InputInfoPtr pInfo, struct _SynapticsParameters *para);
+    Bool (*DeviceOffHook)(InputInfoPtr pInfo);
     Bool (*QueryHardware)(InputInfoPtr pInfo);
     Bool (*ReadHwState)(InputInfoPtr pInfo,
 			struct CommData *comm, struct SynapticsHwState *hwRet);
-- 
1.7.6



More information about the xorg-devel mailing list