aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/gpm/gpm-1.99.7/remove_nested_functions.patch
blob: d2d6cb8a8c2061de977075044189951483f8f9db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
Remove nested functions, they are not available in all compilers
e.g. clang will not support them.

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>

Index: gpm-1.99.7/src/drivers/summa/i.c
===================================================================
--- gpm-1.99.7.orig/src/drivers/summa/i.c
+++ gpm-1.99.7/src/drivers/summa/i.c
@@ -36,6 +36,28 @@ extern int summamaxy;
 
 extern signed char summaid;
 
+static void resetsumma(int fd)
+{
+   write(fd, 0, 1);          /* Reset */
+   usleep(400000);           /* wait */
+}
+
+static int waitsumma(int fd)
+{
+   struct timeval timeout;
+
+   fd_set readfds;
+
+   int err;
+
+   FD_ZERO(&readfds);
+   FD_SET(fd, &readfds);
+   timeout.tv_sec = 0;
+   timeout.tv_usec = 200000;
+   err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout);
+   return (err);
+}
+
 Gpm_Type *I_summa(int fd, unsigned short flags, struct Gpm_Type *type, int argc,
                   char **argv)
 {
@@ -43,24 +65,6 @@ Gpm_Type *I_summa(int fd, unsigned short
    flags = argc = 0;            /* FIXME: 1.99.13 */
    argv = NULL;
 
-   void resetsumma() {
-      write(fd, 0, 1);          /* Reset */
-      usleep(400000);           /* wait */
-   }
-   int waitsumma() {
-      struct timeval timeout;
-
-      fd_set readfds;
-
-      int err;
-
-      FD_ZERO(&readfds);
-      FD_SET(fd, &readfds);
-      timeout.tv_sec = 0;
-      timeout.tv_usec = 200000;
-      err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout);
-      return (err);
-   }
    int err;
 
    char buffer[255];
@@ -91,7 +95,7 @@ Gpm_Type *I_summa(int fd, unsigned short
     */
    setspeed(fd, 1200, 9600, 1,
             B9600 | CS8 | CREAD | CLOCAL | HUPCL | PARENB | PARODD);
-   resetsumma();
+   resetsumma(fd);
 
    write(fd, SS_PROMPT_MODE, strlen(SS_PROMPT_MODE));
 
@@ -103,7 +107,7 @@ Gpm_Type *I_summa(int fd, unsigned short
        * read the Summa Firm-ID 
        */
       write(fd, SS_FIRMID, strlen(SS_FIRMID));
-      err = waitsumma();
+      err = waitsumma(fd);
       if(!((err == -1) || (!err))) {
          summaid = 10;          /* Original Summagraphics */
          read(fd, buffer, 255); /* Read Firm-ID */
@@ -111,14 +115,14 @@ Gpm_Type *I_summa(int fd, unsigned short
    }
 
    if(summaid < 0) {            /* Genius-test */
-      resetsumma();
+      resetsumma(fd);
       write(fd, GEN_MMSERIES, 1);
       write(fd, &GEN_MODELL, 1);        /* Read modell */
-      err = waitsumma();
+      err = waitsumma(fd);
       if(!((err == -1) || (!err))) {    /* read Genius-ID */
-         err = waitsumma();
+         err = waitsumma(fd);
          if(!((err == -1) || (!err))) {
-            err = waitsumma();
+            err = waitsumma(fd);
             if(!((err == -1) || (!err))) {
                read(fd, &config, 1);
                summaid = (config[0] & 224) >> 5;        /* genius tablet-id
@@ -135,14 +139,14 @@ Gpm_Type *I_summa(int fd, unsigned short
     * unknown tablet ?
     */
    if((summaid < 0) || (summaid == 11)) {
-      resetsumma();
+      resetsumma(fd);
       write(fd, SS_BINARY_FMT SS_PROMPT_MODE, 3);
    }
 
    /*
     * read tablet size 
     */
-   err = waitsumma();
+   err = waitsumma(fd);
    if(!((err == -1) || (!err)))
       read(fd, buffer, sizeof(buffer));
    write(fd, SS_READCONFIG, 1);
Index: gpm-1.99.7/src/drivers/wacom/i.c
===================================================================
--- gpm-1.99.7.orig/src/drivers/wacom/i.c
+++ gpm-1.99.7/src/drivers/wacom/i.c
@@ -30,10 +30,6 @@
 #include "message.h"            /* gpm_report */
 #include "wacom.h"              /* wacom */
 
-Gpm_Type *I_wacom(int fd, unsigned short flags, struct Gpm_Type *type, int argc,
-                  char **argv)
-{
-
 /* wacom graphire tablet */
 #define UD_RESETBAUD     "\r$"  /* reset baud rate to default (wacom V) */
    /*
@@ -45,83 +41,91 @@ Gpm_Type *I_wacom(int fd, unsigned short
 #define UD_COORD         "~C\r" /* Request max coordinates */
 #define UD_STOP          "\nSP\r"       /* stop sending coordinates */
 
-   flags = 0;                   /* FIXME: 1.99.13 */
 
-   void reset_wacom() {
-      /*
-       * Init Wacom communication; this is modified from xf86Wacom.so module 
-       */
-      /*
-       * Set speed to 19200 
-       */
-      setspeed(fd, 1200, 19200, 0, B19200 | CS8 | CREAD | CLOCAL | HUPCL);
-      /*
-       * Send Reset Baudrate Command 
-       */
-      write(fd, UD_RESETBAUD, strlen(UD_RESETBAUD));
-      usleep(250000);
-      /*
-       * Send Reset Command 
-       */
-      write(fd, UD_RESET, strlen(UD_RESET));
-      usleep(75000);
-      /*
-       * Set speed to 9600bps 
-       */
-      setspeed(fd, 1200, 9600, 0, B9600 | CS8 | CREAD | CLOCAL | HUPCL);
-      /*
-       * Send Reset Command 
-       */
-      write(fd, UD_RESET, strlen(UD_RESET));
-      usleep(250000);
-      write(fd, UD_STOP, strlen(UD_STOP));
-      usleep(100000);
-   }
+static void reset_wacom(int fd)
+{
+   /*
+    * Init Wacom communication; this is modified from xf86Wacom.so module 
+    */
+   /*
+    * Set speed to 19200 
+    */
+   setspeed(fd, 1200, 19200, 0, B19200 | CS8 | CREAD | CLOCAL | HUPCL);
+   /*
+    * Send Reset Baudrate Command 
+    */
+   write(fd, UD_RESETBAUD, strlen(UD_RESETBAUD));
+   usleep(250000);
+   /*
+    * Send Reset Command 
+    */
+   write(fd, UD_RESET, strlen(UD_RESET));
+   usleep(75000);
+   /*
+    * Set speed to 9600bps 
+    */
+   setspeed(fd, 1200, 9600, 0, B9600 | CS8 | CREAD | CLOCAL | HUPCL);
+   /*
+    * Send Reset Command 
+    */
+   write(fd, UD_RESET, strlen(UD_RESET));
+   usleep(250000);
+   write(fd, UD_STOP, strlen(UD_STOP));
+   usleep(100000);
+}
 
-   int wait_wacom() {
-      /*
-       *  Wait up to 200 ms for Data from Tablet.
-       *  Do not read that data.
-       *  Give back 0 on timeout condition, -1 on error and 1 for DataPresent
-       */
-      struct timeval timeout;
-
-      fd_set readfds;
-
-      int err;
-
-      FD_ZERO(&readfds);
-      FD_SET(fd, &readfds);
-      timeout.tv_sec = 0;
-      timeout.tv_usec = 200000;
-      err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout);
-      return ((err > 0) ? 1 : err);
-   }
+static int wait_wacom(int fd)
+{
+   /*
+    *  Wait up to 200 ms for Data from Tablet.
+    *  Do not read that data.
+    *  Give back 0 on timeout condition, -1 on error and 1 for DataPresent
+    */
+   struct timeval timeout;
 
-   char buffer[50], *p;
+   fd_set readfds;
 
-   int RequestData(char *cmd) {
-      int err;
+   int err;
 
-      /*
-       * Send cmd if not null, and get back answer from tablet.
-       * Get Data to buffer until full or timeout.
-       * Give back 0 for timeout and !0 for buffer full
-       */
-      if(cmd)
-         write(fd, cmd, strlen(cmd));
-      memset(buffer, 0, sizeof(buffer));
-      p = buffer;
-      err = wait_wacom();
-      while(err != -1 && err && (p - buffer) < (int) (sizeof(buffer) - 1)) {
-         p += read(fd, p, (sizeof(buffer) - 1) - (p - buffer));
-         err = wait_wacom();
-      }
-      /*
-       * return 1 for buffer full 
-       */
-      return ((strlen(buffer) >= (sizeof(buffer) - 1)) ? !0 : 0);
+   FD_ZERO(&readfds);
+   FD_SET(fd, &readfds);
+   timeout.tv_sec = 0;
+   timeout.tv_usec = 200000;
+   err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout);
+   return ((err > 0) ? 1 : err);
+}
+
+static int RequestData(int fd, char *cmd, char *buffer)
+{
+   int err;
+   char *p;
+   /*
+    * Send cmd if not null, and get back answer from tablet.
+    * Get Data to buffer until full or timeout.
+    * Give back 0 for timeout and !0 for buffer full
+    */
+   if(cmd)
+      write(fd, cmd, strlen(cmd));
+   memset(buffer, 0, sizeof(buffer));
+   p = buffer;
+   err = wait_wacom(fd);
+   while(err != -1 && err && (p - buffer) < (int) (sizeof(buffer) - 1)) {
+      p += read(fd, p, (sizeof(buffer) - 1) - (p - buffer));
+      err = wait_wacom(fd);
    }
+   /*
+    * return 1 for buffer full 
+    */
+   return ((strlen(buffer) >= (sizeof(buffer) - 1)) ? !0 : 0);
+}
+
+Gpm_Type *I_wacom(int fd, unsigned short flags, struct Gpm_Type *type, int argc,
+                  char **argv)
+{
+
+   flags = 0;                   /* FIXME: 1.99.13 */
+
+   char buffer[50];
 
    /*
     * We do both modes, relative and absolute, with the same function.
@@ -143,17 +147,17 @@ Gpm_Type *I_wacom(int fd, unsigned short
    };
    parse_argv(optioninfo, argc, argv);
    type->absolute = WacomAbsoluteWanted;
-   reset_wacom();
+   reset_wacom(fd);
 
    /*
     * "Flush" input queque 
     */
-   while(RequestData(NULL)) ;
+   while(RequestData(fd, NULL, buffer)) ;
 
    /*
     * read WACOM-ID 
     */
-   RequestData(UD_FIRMID);
+   RequestData(fd, UD_FIRMID, buffer);
 
    /*
     * Search for matching modell 
@@ -180,7 +184,7 @@ Gpm_Type *I_wacom(int fd, unsigned short
     * read Wacom max size 
     */
    if(WacomModell != (-1) && (!wcmodell[WacomModell].maxX)) {
-      RequestData(UD_COORD);
+      RequestData(fd, UD_COORD, buffer);
       sscanf(buffer + 2, "%d,%d", &wmaxx, &wmaxy);
       wmaxx = (wmaxx - wcmodell[WacomModell].border);
       wmaxy = (wmaxy - wcmodell[WacomModell].border);