Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame^] | 1 | Remove nested functions, they are not available in all compilers |
| 2 | e.g. clang will not support them. |
| 3 | |
| 4 | Upstream-Status: Pending |
| 5 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 6 | |
| 7 | Index: gpm-1.99.7/src/drivers/summa/i.c |
| 8 | =================================================================== |
| 9 | --- gpm-1.99.7.orig/src/drivers/summa/i.c |
| 10 | +++ gpm-1.99.7/src/drivers/summa/i.c |
| 11 | @@ -36,6 +36,28 @@ extern int summamaxy; |
| 12 | |
| 13 | extern signed char summaid; |
| 14 | |
| 15 | +static void resetsumma(int fd) |
| 16 | +{ |
| 17 | + write(fd, 0, 1); /* Reset */ |
| 18 | + usleep(400000); /* wait */ |
| 19 | +} |
| 20 | + |
| 21 | +static int waitsumma(int fd) |
| 22 | +{ |
| 23 | + struct timeval timeout; |
| 24 | + |
| 25 | + fd_set readfds; |
| 26 | + |
| 27 | + int err; |
| 28 | + |
| 29 | + FD_ZERO(&readfds); |
| 30 | + FD_SET(fd, &readfds); |
| 31 | + timeout.tv_sec = 0; |
| 32 | + timeout.tv_usec = 200000; |
| 33 | + err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); |
| 34 | + return (err); |
| 35 | +} |
| 36 | + |
| 37 | Gpm_Type *I_summa(int fd, unsigned short flags, struct Gpm_Type *type, int argc, |
| 38 | char **argv) |
| 39 | { |
| 40 | @@ -43,24 +65,6 @@ Gpm_Type *I_summa(int fd, unsigned short |
| 41 | flags = argc = 0; /* FIXME: 1.99.13 */ |
| 42 | argv = NULL; |
| 43 | |
| 44 | - void resetsumma() { |
| 45 | - write(fd, 0, 1); /* Reset */ |
| 46 | - usleep(400000); /* wait */ |
| 47 | - } |
| 48 | - int waitsumma() { |
| 49 | - struct timeval timeout; |
| 50 | - |
| 51 | - fd_set readfds; |
| 52 | - |
| 53 | - int err; |
| 54 | - |
| 55 | - FD_ZERO(&readfds); |
| 56 | - FD_SET(fd, &readfds); |
| 57 | - timeout.tv_sec = 0; |
| 58 | - timeout.tv_usec = 200000; |
| 59 | - err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); |
| 60 | - return (err); |
| 61 | - } |
| 62 | int err; |
| 63 | |
| 64 | char buffer[255]; |
| 65 | @@ -91,7 +95,7 @@ Gpm_Type *I_summa(int fd, unsigned short |
| 66 | */ |
| 67 | setspeed(fd, 1200, 9600, 1, |
| 68 | B9600 | CS8 | CREAD | CLOCAL | HUPCL | PARENB | PARODD); |
| 69 | - resetsumma(); |
| 70 | + resetsumma(fd); |
| 71 | |
| 72 | write(fd, SS_PROMPT_MODE, strlen(SS_PROMPT_MODE)); |
| 73 | |
| 74 | @@ -103,7 +107,7 @@ Gpm_Type *I_summa(int fd, unsigned short |
| 75 | * read the Summa Firm-ID |
| 76 | */ |
| 77 | write(fd, SS_FIRMID, strlen(SS_FIRMID)); |
| 78 | - err = waitsumma(); |
| 79 | + err = waitsumma(fd); |
| 80 | if(!((err == -1) || (!err))) { |
| 81 | summaid = 10; /* Original Summagraphics */ |
| 82 | read(fd, buffer, 255); /* Read Firm-ID */ |
| 83 | @@ -111,14 +115,14 @@ Gpm_Type *I_summa(int fd, unsigned short |
| 84 | } |
| 85 | |
| 86 | if(summaid < 0) { /* Genius-test */ |
| 87 | - resetsumma(); |
| 88 | + resetsumma(fd); |
| 89 | write(fd, GEN_MMSERIES, 1); |
| 90 | write(fd, &GEN_MODELL, 1); /* Read modell */ |
| 91 | - err = waitsumma(); |
| 92 | + err = waitsumma(fd); |
| 93 | if(!((err == -1) || (!err))) { /* read Genius-ID */ |
| 94 | - err = waitsumma(); |
| 95 | + err = waitsumma(fd); |
| 96 | if(!((err == -1) || (!err))) { |
| 97 | - err = waitsumma(); |
| 98 | + err = waitsumma(fd); |
| 99 | if(!((err == -1) || (!err))) { |
| 100 | read(fd, &config, 1); |
| 101 | summaid = (config[0] & 224) >> 5; /* genius tablet-id |
| 102 | @@ -135,14 +139,14 @@ Gpm_Type *I_summa(int fd, unsigned short |
| 103 | * unknown tablet ? |
| 104 | */ |
| 105 | if((summaid < 0) || (summaid == 11)) { |
| 106 | - resetsumma(); |
| 107 | + resetsumma(fd); |
| 108 | write(fd, SS_BINARY_FMT SS_PROMPT_MODE, 3); |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | * read tablet size |
| 113 | */ |
| 114 | - err = waitsumma(); |
| 115 | + err = waitsumma(fd); |
| 116 | if(!((err == -1) || (!err))) |
| 117 | read(fd, buffer, sizeof(buffer)); |
| 118 | write(fd, SS_READCONFIG, 1); |
| 119 | Index: gpm-1.99.7/src/drivers/wacom/i.c |
| 120 | =================================================================== |
| 121 | --- gpm-1.99.7.orig/src/drivers/wacom/i.c |
| 122 | +++ gpm-1.99.7/src/drivers/wacom/i.c |
| 123 | @@ -30,10 +30,6 @@ |
| 124 | #include "message.h" /* gpm_report */ |
| 125 | #include "wacom.h" /* wacom */ |
| 126 | |
| 127 | -Gpm_Type *I_wacom(int fd, unsigned short flags, struct Gpm_Type *type, int argc, |
| 128 | - char **argv) |
| 129 | -{ |
| 130 | - |
| 131 | /* wacom graphire tablet */ |
| 132 | #define UD_RESETBAUD "\r$" /* reset baud rate to default (wacom V) */ |
| 133 | /* |
| 134 | @@ -45,83 +41,91 @@ Gpm_Type *I_wacom(int fd, unsigned short |
| 135 | #define UD_COORD "~C\r" /* Request max coordinates */ |
| 136 | #define UD_STOP "\nSP\r" /* stop sending coordinates */ |
| 137 | |
| 138 | - flags = 0; /* FIXME: 1.99.13 */ |
| 139 | |
| 140 | - void reset_wacom() { |
| 141 | - /* |
| 142 | - * Init Wacom communication; this is modified from xf86Wacom.so module |
| 143 | - */ |
| 144 | - /* |
| 145 | - * Set speed to 19200 |
| 146 | - */ |
| 147 | - setspeed(fd, 1200, 19200, 0, B19200 | CS8 | CREAD | CLOCAL | HUPCL); |
| 148 | - /* |
| 149 | - * Send Reset Baudrate Command |
| 150 | - */ |
| 151 | - write(fd, UD_RESETBAUD, strlen(UD_RESETBAUD)); |
| 152 | - usleep(250000); |
| 153 | - /* |
| 154 | - * Send Reset Command |
| 155 | - */ |
| 156 | - write(fd, UD_RESET, strlen(UD_RESET)); |
| 157 | - usleep(75000); |
| 158 | - /* |
| 159 | - * Set speed to 9600bps |
| 160 | - */ |
| 161 | - setspeed(fd, 1200, 9600, 0, B9600 | CS8 | CREAD | CLOCAL | HUPCL); |
| 162 | - /* |
| 163 | - * Send Reset Command |
| 164 | - */ |
| 165 | - write(fd, UD_RESET, strlen(UD_RESET)); |
| 166 | - usleep(250000); |
| 167 | - write(fd, UD_STOP, strlen(UD_STOP)); |
| 168 | - usleep(100000); |
| 169 | - } |
| 170 | +static void reset_wacom(int fd) |
| 171 | +{ |
| 172 | + /* |
| 173 | + * Init Wacom communication; this is modified from xf86Wacom.so module |
| 174 | + */ |
| 175 | + /* |
| 176 | + * Set speed to 19200 |
| 177 | + */ |
| 178 | + setspeed(fd, 1200, 19200, 0, B19200 | CS8 | CREAD | CLOCAL | HUPCL); |
| 179 | + /* |
| 180 | + * Send Reset Baudrate Command |
| 181 | + */ |
| 182 | + write(fd, UD_RESETBAUD, strlen(UD_RESETBAUD)); |
| 183 | + usleep(250000); |
| 184 | + /* |
| 185 | + * Send Reset Command |
| 186 | + */ |
| 187 | + write(fd, UD_RESET, strlen(UD_RESET)); |
| 188 | + usleep(75000); |
| 189 | + /* |
| 190 | + * Set speed to 9600bps |
| 191 | + */ |
| 192 | + setspeed(fd, 1200, 9600, 0, B9600 | CS8 | CREAD | CLOCAL | HUPCL); |
| 193 | + /* |
| 194 | + * Send Reset Command |
| 195 | + */ |
| 196 | + write(fd, UD_RESET, strlen(UD_RESET)); |
| 197 | + usleep(250000); |
| 198 | + write(fd, UD_STOP, strlen(UD_STOP)); |
| 199 | + usleep(100000); |
| 200 | +} |
| 201 | |
| 202 | - int wait_wacom() { |
| 203 | - /* |
| 204 | - * Wait up to 200 ms for Data from Tablet. |
| 205 | - * Do not read that data. |
| 206 | - * Give back 0 on timeout condition, -1 on error and 1 for DataPresent |
| 207 | - */ |
| 208 | - struct timeval timeout; |
| 209 | - |
| 210 | - fd_set readfds; |
| 211 | - |
| 212 | - int err; |
| 213 | - |
| 214 | - FD_ZERO(&readfds); |
| 215 | - FD_SET(fd, &readfds); |
| 216 | - timeout.tv_sec = 0; |
| 217 | - timeout.tv_usec = 200000; |
| 218 | - err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); |
| 219 | - return ((err > 0) ? 1 : err); |
| 220 | - } |
| 221 | +static int wait_wacom(int fd) |
| 222 | +{ |
| 223 | + /* |
| 224 | + * Wait up to 200 ms for Data from Tablet. |
| 225 | + * Do not read that data. |
| 226 | + * Give back 0 on timeout condition, -1 on error and 1 for DataPresent |
| 227 | + */ |
| 228 | + struct timeval timeout; |
| 229 | |
| 230 | - char buffer[50], *p; |
| 231 | + fd_set readfds; |
| 232 | |
| 233 | - int RequestData(char *cmd) { |
| 234 | - int err; |
| 235 | + int err; |
| 236 | |
| 237 | - /* |
| 238 | - * Send cmd if not null, and get back answer from tablet. |
| 239 | - * Get Data to buffer until full or timeout. |
| 240 | - * Give back 0 for timeout and !0 for buffer full |
| 241 | - */ |
| 242 | - if(cmd) |
| 243 | - write(fd, cmd, strlen(cmd)); |
| 244 | - memset(buffer, 0, sizeof(buffer)); |
| 245 | - p = buffer; |
| 246 | - err = wait_wacom(); |
| 247 | - while(err != -1 && err && (p - buffer) < (int) (sizeof(buffer) - 1)) { |
| 248 | - p += read(fd, p, (sizeof(buffer) - 1) - (p - buffer)); |
| 249 | - err = wait_wacom(); |
| 250 | - } |
| 251 | - /* |
| 252 | - * return 1 for buffer full |
| 253 | - */ |
| 254 | - return ((strlen(buffer) >= (sizeof(buffer) - 1)) ? !0 : 0); |
| 255 | + FD_ZERO(&readfds); |
| 256 | + FD_SET(fd, &readfds); |
| 257 | + timeout.tv_sec = 0; |
| 258 | + timeout.tv_usec = 200000; |
| 259 | + err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); |
| 260 | + return ((err > 0) ? 1 : err); |
| 261 | +} |
| 262 | + |
| 263 | +static int RequestData(int fd, char *cmd, char *buffer) |
| 264 | +{ |
| 265 | + int err; |
| 266 | + char *p; |
| 267 | + /* |
| 268 | + * Send cmd if not null, and get back answer from tablet. |
| 269 | + * Get Data to buffer until full or timeout. |
| 270 | + * Give back 0 for timeout and !0 for buffer full |
| 271 | + */ |
| 272 | + if(cmd) |
| 273 | + write(fd, cmd, strlen(cmd)); |
| 274 | + memset(buffer, 0, sizeof(buffer)); |
| 275 | + p = buffer; |
| 276 | + err = wait_wacom(fd); |
| 277 | + while(err != -1 && err && (p - buffer) < (int) (sizeof(buffer) - 1)) { |
| 278 | + p += read(fd, p, (sizeof(buffer) - 1) - (p - buffer)); |
| 279 | + err = wait_wacom(fd); |
| 280 | } |
| 281 | + /* |
| 282 | + * return 1 for buffer full |
| 283 | + */ |
| 284 | + return ((strlen(buffer) >= (sizeof(buffer) - 1)) ? !0 : 0); |
| 285 | +} |
| 286 | + |
| 287 | +Gpm_Type *I_wacom(int fd, unsigned short flags, struct Gpm_Type *type, int argc, |
| 288 | + char **argv) |
| 289 | +{ |
| 290 | + |
| 291 | + flags = 0; /* FIXME: 1.99.13 */ |
| 292 | + |
| 293 | + char buffer[50]; |
| 294 | |
| 295 | /* |
| 296 | * We do both modes, relative and absolute, with the same function. |
| 297 | @@ -143,17 +147,17 @@ Gpm_Type *I_wacom(int fd, unsigned short |
| 298 | }; |
| 299 | parse_argv(optioninfo, argc, argv); |
| 300 | type->absolute = WacomAbsoluteWanted; |
| 301 | - reset_wacom(); |
| 302 | + reset_wacom(fd); |
| 303 | |
| 304 | /* |
| 305 | * "Flush" input queque |
| 306 | */ |
| 307 | - while(RequestData(NULL)) ; |
| 308 | + while(RequestData(fd, NULL, buffer)) ; |
| 309 | |
| 310 | /* |
| 311 | * read WACOM-ID |
| 312 | */ |
| 313 | - RequestData(UD_FIRMID); |
| 314 | + RequestData(fd, UD_FIRMID, buffer); |
| 315 | |
| 316 | /* |
| 317 | * Search for matching modell |
| 318 | @@ -180,7 +184,7 @@ Gpm_Type *I_wacom(int fd, unsigned short |
| 319 | * read Wacom max size |
| 320 | */ |
| 321 | if(WacomModell != (-1) && (!wcmodell[WacomModell].maxX)) { |
| 322 | - RequestData(UD_COORD); |
| 323 | + RequestData(fd, UD_COORD, buffer); |
| 324 | sscanf(buffer + 2, "%d,%d", &wmaxx, &wmaxy); |
| 325 | wmaxx = (wmaxx - wcmodell[WacomModell].border); |
| 326 | wmaxy = (wmaxy - wcmodell[WacomModell].border); |