[xf86-input-synaptics v3 05/14] Allocate SynapticsPrivate.comm->hwState

Chase Douglas chase.douglas at canonical.com
Fri Feb 10 11:56:49 PST 2012


This is needed for when SynapticsHwState can't be allocated on the stack.

Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
 src/alpscomm.c        |    2 +-
 src/eventcomm.c       |    2 +-
 src/ps2comm.c         |    2 +-
 src/synaptics.c       |    3 +++
 src/synproto.h        |    2 +-
 test/eventcomm-test.c |    4 ++++
 6 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/alpscomm.c b/src/alpscomm.c
index 7ae2da1..dbc3554 100644
--- a/src/alpscomm.c
+++ b/src/alpscomm.c
@@ -211,7 +211,7 @@ ALPSReadHwState(InputInfoPtr pInfo,
 		struct CommData *comm, struct SynapticsHwState *hwRet)
 {
     unsigned char *buf = comm->protoBuf;
-    struct SynapticsHwState *hw = &(comm->hwState);
+    struct SynapticsHwState *hw = comm->hwState;
 
     if (!ALPS_get_packet(comm, pInfo))
 	return FALSE;
diff --git a/src/eventcomm.c b/src/eventcomm.c
index a52e8b8..bfcce28 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -702,7 +702,7 @@ EventReadHwState(InputInfoPtr pInfo,
 {
     struct input_event ev;
     Bool v;
-    struct SynapticsHwState *hw = &(comm->hwState);
+    struct SynapticsHwState *hw = comm->hwState;
     SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
     SynapticsParameters *para = &priv->synpara;
 
diff --git a/src/ps2comm.c b/src/ps2comm.c
index b7995ee..74bd937 100644
--- a/src/ps2comm.c
+++ b/src/ps2comm.c
@@ -521,7 +521,7 @@ PS2ReadHwStateProto(InputInfoPtr pInfo,
 	       struct CommData *comm, struct SynapticsHwState *hwRet)
 {
     unsigned char *buf = comm->protoBuf;
-    struct SynapticsHwState *hw = &(comm->hwState);
+    struct SynapticsHwState *hw = comm->hwState;
     SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
     SynapticsParameters *para = &priv->synpara;
     struct PS2SynapticsHwInfo *synhw;
diff --git a/src/synaptics.c b/src/synaptics.c
index e7deb9b..8f0ad9b 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -935,6 +935,7 @@ DeviceClose(DeviceIntPtr dev)
     priv->timer = NULL;
     free_shm_data(priv);
     SynapticsHwStateFree(&priv->local_hw_state);
+    SynapticsHwStateFree(&priv->comm.hwState);
     return RetValue;
 }
 
@@ -1184,6 +1185,8 @@ no_touch:
     if (!priv->local_hw_state)
 	return !Success;
 
+    priv->comm.hwState = SynapticsHwStateAlloc(priv);
+
     if (!alloc_shm_data(pInfo))
     {
 	free(priv->local_hw_state);
diff --git a/src/synproto.h b/src/synproto.h
index 3f09bb2..74becca 100644
--- a/src/synproto.h
+++ b/src/synproto.h
@@ -64,7 +64,7 @@ struct CommData {
     int protoBufTail;
 
     /* Used for keeping track of partial HwState updates. */
-    struct SynapticsHwState hwState;
+    struct SynapticsHwState *hwState;
     Bool oneFinger;
     Bool twoFingers;
     Bool threeFingers;
diff --git a/test/eventcomm-test.c b/test/eventcomm-test.c
index 81d931a..1ee2760 100644
--- a/test/eventcomm-test.c
+++ b/test/eventcomm-test.c
@@ -57,9 +57,11 @@ static void
 reset_data(struct SynapticsHwState **hw, struct CommData *comm,
            SynapticsPrivate *priv)
 {
+    SynapticsHwStateFree(&comm->hwState);
     memset(comm, 0, sizeof(struct CommData));
     SynapticsHwStateFree(hw);
     *hw = SynapticsHwStateAlloc(priv);
+    comm->hwState = SynapticsHwStateAlloc(priv);
 }
 
 /**
@@ -188,6 +190,7 @@ test_read_hw_state(void)
     test_buttons(fd_write, &info, &comm);
 
     SynapticsHwStateFree(&hw);
+    SynapticsHwStateFree(&comm.hwState);
 }
 
 static Bool
@@ -310,6 +313,7 @@ test_ignore_hw_state(void)
 
     SynapticsHwStateFree(&hw);
     SynapticsHwStateFree(&hw_zero);
+    SynapticsHwStateFree(&comm.hwState);
 }
 
 int main (int argc, char **argv)
-- 
1.7.8.3



More information about the xorg-devel mailing list