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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
Index: linux-2.6.20.7/drivers/char/ts0710_mux.c
===================================================================
--- linux-2.6.20.7.orig/drivers/char/ts0710_mux.c 2007-04-22 12:24:18.000000000 +0200
+++ linux-2.6.20.7/drivers/char/ts0710_mux.c 2007-04-22 12:26:47.000000000 +0200
@@ -85,6 +85,9 @@
#include "ts0710.h"
#include "ts0710_mux.h"
+#define TS0710DEBUG
+#define PRINT_OUTPUT_PRINTK
+
#define TS0710MUX_GPRS_SESSION_MAX 2
#define TS0710MUX_MAJOR 250
#define TS0710MUX_MINOR_START 0
@@ -316,7 +319,7 @@
#ifdef TS0710DEBUG
#ifdef PRINT_OUTPUT_PRINTK
-#define TS0710_DEBUG(fmt, arg...) printk(KERN_INFO "MUX " __FUNCTION__ ": " fmt "\n" , ## arg)
+#define TS0710_DEBUG(fmt, arg...) printk(KERN_INFO "MUX %s: " fmt "\n" , __func__, ## arg)
#else
#include "ezxlog.h"
static __u8 strDebug[256];
@@ -530,10 +533,10 @@
if (strncmp(p->comm, "aplogd", 6) == 0) {
sig = 1;
if (send_sig(SIGUSR2, p, 1) == 0) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX: success to send SIGUSR2 to aplogd!\n");
} else {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX: failure to send SIGUSR2 to aplogd!\n");
}
break;
@@ -542,7 +545,7 @@
read_unlock(&tasklist_lock);
if (!sig) {
- TS0710_PRINTK("MUX: not found aplogd!\n");
+ TS0710_DEBUG("MUX: not found aplogd!\n");
}
}
#else
@@ -559,11 +562,11 @@
buf[len + 1] = TS0710_BASIC_FLAG;
if ((COMM_FOR_MUX_DRIVER == 0) || (COMM_FOR_MUX_TTY == 0)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX basic_write: (COMM_FOR_MUX_DRIVER == 0) || (COMM_FOR_MUX_TTY == 0)\n");
#ifndef USB_FOR_MUX
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX basic_write: tapisrv might be down!!! (serial_for_mux_driver == 0) || (serial_for_mux_tty == 0)\n");
TS0710_SIG2APLOGD();
#endif
@@ -577,7 +580,7 @@
res = COMM_FOR_MUX_DRIVER->write(COMM_FOR_MUX_TTY, buf, len + 2);
if (res != len + 2) {
- TS0710_PRINTK("MUX basic_write: Write Error!\n");
+ TS0710_DEBUG("MUX basic_write: Write Error!\n");
return -1;
}
@@ -601,7 +604,7 @@
TS0710_DEBUG("crc_check: CRC check OK\n");
return 0;
} else {
- TS0710_PRINTK("MUX crc_check: CRC check failed\n");
+ TS0710_DEBUG("MUX crc_check: CRC check failed\n");
return 1;
}
}
@@ -1266,7 +1269,7 @@
break;
case FCON: /*Flow control on command */
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Received Flow control(all channels) on command\n");
if (mcc_short_pkt->h.type.cr == MCC_CMD) {
ts0710->dlci[0].state = CONNECTED;
@@ -1276,7 +1279,7 @@
break;
case FCOFF: /*Flow control off command */
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Received Flow control(all channels) off command\n");
if (mcc_short_pkt->h.type.cr == MCC_CMD) {
for (j = 0; j < TS0710_MAX_CHN; j++) {
@@ -1823,7 +1826,7 @@
TS0710_DEBUG("UIH on channel %d\n", dlci);
if (uih_len > ts0710->dlci[dlci].mtu) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: DLCI:%d, uih_len:%d is bigger than mtu:%d, discard data!\n",
dlci, uih_len, ts0710->dlci[dlci].mtu);
break;
@@ -1844,7 +1847,7 @@
dlci, tty_idx);
TS0710_DEBUGSTR(uih_data_start, uih_len);
if (!(iscmdtty[tty_idx])) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: %s: Wrong CMDTAG on DLCI:%d, /dev/mux%d\n",
__FUNCTION__, dlci, tty_idx);
}
@@ -1856,7 +1859,7 @@
("NON-CMDTAG on DLCI:%d, /dev/mux%d\n",
dlci, tty_idx);
if (iscmdtty[tty_idx]) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: %s: Wrong NON-CMDTAG on DLCI:%d, /dev/mux%d\n",
__FUNCTION__, dlci, tty_idx);
}
@@ -1864,13 +1867,14 @@
}
tty = mux_table[tty_idx];
if ((!mux_tty[tty_idx]) || (!tty)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX: No application waiting for, discard it! /dev/mux%d\n",
tty_idx);
+ TS0710_DEBUG("MUX: mux_tty[%d] = %d, tty is at %i", tty_idx, mux_tty[tty_idx], tty);
} else { /* Begin processing received data */
if ((!mux_recv_info_flags[tty_idx])
|| (!mux_recv_info[tty_idx])) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: No mux_recv_info, discard it! /dev/mux%d\n",
tty_idx);
break;
@@ -1878,7 +1882,7 @@
recv_info = mux_recv_info[tty_idx];
if (recv_info->total > 8192) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX : discard data for tty_idx:%d, recv_info->total > 8192 \n",
tty_idx);
break;
@@ -1949,7 +1953,7 @@
get_mux_recv_packet
(uih_len);
if (!recv_packet) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX %s: no memory\n",
__FUNCTION__);
break;
@@ -1980,7 +1984,7 @@
} else { /* recv_info->total == 0 */
if (uih_len >
TS0710MUX_RECV_BUF_SIZE) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: tty_idx:%d, uih_len == %d is too big\n",
tty_idx, uih_len);
uih_len =
@@ -2120,12 +2124,12 @@
if (ts0710->dlci[dlci].state == DISCONNECTED) {
break;
} else if (signal_pending(current)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI %d Send DISC got signal!\n",
dlci);
break;
} else if ((jiffies - t) >= TS0710MUX_TIME_OUT) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI %d Send DISC timeout!\n", dlci);
continue;
}
@@ -2158,7 +2162,7 @@
return 0;
} else if (ts0710->dlci[0].state == CONNECTING) {
/* Reentry */
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI: 0, reentry to open DLCI 0, pid: %d, %s !\n",
current->pid, current->comm);
try = 11;
@@ -2179,13 +2183,13 @@
DISCONNECTED) {
break;
} else if (signal_pending(current)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Wait for connecting got signal!\n",
dlci);
retval = -EAGAIN;
break;
} else if ((jiffies - t) >= TS0710MUX_TIME_OUT) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Wait for connecting timeout!\n",
dlci);
continue;
@@ -2199,7 +2203,7 @@
}
} else if ((ts0710->dlci[0].state != DISCONNECTED)
&& (ts0710->dlci[0].state != REJECTED)) {
- TS0710_PRINTK("MUX DLCI:%d state is invalid!\n", dlci);
+ TS0710_DEBUG("MUX DLCI:%d state is invalid!\n", dlci);
return retval;
} else {
ts0710->initiator = 1;
@@ -2218,19 +2222,19 @@
retval = 0;
break;
} else if (ts0710->dlci[0].state == REJECTED) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Send SABM got rejected!\n",
dlci);
retval = -EREJECTED;
break;
} else if (signal_pending(current)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Send SABM got signal!\n",
dlci);
retval = -EAGAIN;
break;
} else if ((jiffies - t) >= TS0710MUX_TIME_OUT) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Send SABM timeout!\n",
dlci);
continue;
@@ -2271,13 +2275,13 @@
DISCONNECTED) {
break;
} else if (signal_pending(current)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Wait for connecting got signal!\n",
dlci);
retval = -EAGAIN;
break;
} else if ((jiffies - t) >= TS0710MUX_TIME_OUT) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Wait for connecting timeout!\n",
dlci);
continue;
@@ -2296,7 +2300,7 @@
}
} else if ((ts0710->dlci[dlci].state != DISCONNECTED)
&& (ts0710->dlci[dlci].state != REJECTED)) {
- TS0710_PRINTK("MUX DLCI:%d state is invalid!\n", dlci);
+ TS0710_DEBUG("MUX DLCI:%d state is invalid!\n", dlci);
return retval;
} else {
ts0710->dlci[dlci].state = NEGOTIATING;
@@ -2313,13 +2317,13 @@
if (ts0710->dlci[dlci].state == CONNECTING) {
break;
} else if (signal_pending(current)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Send pn_msg got signal!\n",
dlci);
retval = -EAGAIN;
break;
} else if ((jiffies - t) >= TS0710MUX_TIME_OUT) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Send pn_msg timeout!\n",
dlci);
continue;
@@ -2344,20 +2348,20 @@
break;
} else if (ts0710->dlci[dlci].state ==
REJECTED) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Send SABM got rejected!\n",
dlci);
retval = -EREJECTED;
break;
} else if (signal_pending(current)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Send SABM got signal!\n",
dlci);
retval = -EAGAIN;
break;
} else if ((jiffies - t) >=
TS0710MUX_TIME_OUT) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX DLCI:%d Send SABM timeout!\n",
dlci);
continue;
@@ -2468,7 +2472,7 @@
schedule_work(&send_tqueue);
#else
if (!tq_serial_for_mux) {
- TS0710_PRINTK("MUX Error: %s: tq_serial_for_mux == 0\n",
+ TS0710_DEBUG("MUX Error: %s: tq_serial_for_mux == 0\n",
__FUNCTION__);
return;
}
@@ -2508,7 +2512,7 @@
if ((mux_tty[cmdtty] == 0) && (mux_tty[datatty] == 0)) {
if (dlci == 1) {
ts0710_close_channel(0);
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX mux_close: tapisrv might be down!!! Close DLCI 1\n");
TS0710_SIG2APLOGD();
}
@@ -2673,12 +2677,12 @@
UNUSED_PARAM(tty);
if ((COMM_FOR_MUX_DRIVER == 0) || (COMM_FOR_MUX_TTY == 0)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX %s: (COMM_FOR_MUX_DRIVER == 0) || (COMM_FOR_MUX_TTY == 0)\n",
__FUNCTION__);
#ifndef USB_FOR_MUX
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX %s: tapisrv might be down!!! (serial_for_mux_driver == 0) || (serial_for_mux_tty == 0)\n",
__FUNCTION__);
TS0710_SIG2APLOGD();
@@ -2724,14 +2728,14 @@
} else if (ts0710->dlci[dlci].state == CONNECTED) {
if (!(mux_send_info_flags[line])) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: mux_write: mux_send_info_flags[%d] == 0\n",
line);
return -ENODEV;
}
send_info = mux_send_info[line];
if (!send_info) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: mux_write: mux_send_info[%d] == 0\n",
line);
return -ENODEV;
@@ -2800,7 +2804,7 @@
}
return c;
} else {
- TS0710_PRINTK("MUX mux_write: DLCI %d not connected\n", dlci);
+ TS0710_DEBUG("MUX mux_write: DLCI %d not connected\n", dlci);
return -EDISCONNECTED;
}
}
@@ -2940,7 +2944,7 @@
return;
}
- TS0710_PRINTK("MUX %s: line is:%d\n", __FUNCTION__, line);
+ TS0710_DEBUG("MUX %s: line is:%d\n", __FUNCTION__, line);
if ((mux_send_info_flags[line])
&& (mux_send_info[line])
@@ -2960,10 +2964,10 @@
/*
if( (COMM_FOR_MUX_DRIVER == 0) || (COMM_FOR_MUX_TTY == 0) ) {
- TS0710_PRINTK("MUX %s: (COMM_FOR_MUX_DRIVER == 0) || (COMM_FOR_MUX_TTY == 0)\n", __FUNCTION__);
+ TS0710_DEBUG("MUX %s: (COMM_FOR_MUX_DRIVER == 0) || (COMM_FOR_MUX_TTY == 0)\n", __FUNCTION__);
#ifndef USB_FOR_MUX
- TS0710_PRINTK("MUX %s: tapisrv might be down!!! (serial_for_mux_driver == 0) || (serial_for_mux_tty == 0)\n", __FUNCTION__);
+ TS0710_DEBUG("MUX %s: tapisrv might be down!!! (serial_for_mux_driver == 0) || (serial_for_mux_tty == 0)\n", __FUNCTION__);
TS0710_SIG2APLOGD();
#endif
@@ -2989,9 +2993,9 @@
if ((COMM_FOR_MUX_DRIVER == NULL) || (COMM_FOR_MUX_TTY == NULL)) {
#ifdef USB_FOR_MUX
- TS0710_PRINTK("MUX: please install and open IPC-USB first\n");
+ TS0710_DEBUG("MUX: please install and open IPC-USB first\n");
#else
- TS0710_PRINTK("MUX: please install and open ttyS0 first\n");
+ TS0710_DEBUG("MUX: please install and open ttyS0 first\n");
#endif
goto out;
@@ -3016,7 +3020,7 @@
/* if( dlci == 1 ) { */
/* Open server channel 0 first */
if ((retval = ts0710_open_channel(0)) != 0) {
- TS0710_PRINTK("MUX: Can't connect server channel 0!\n");
+ TS0710_DEBUG("MUX: Can't connect server channel 0!\n");
ts0710_init();
mux_tty[line]--;
@@ -3073,7 +3077,7 @@
datatty = dlci2tty[dlci].datatty;
if ((mux_tty[cmdtty] > 0) || (mux_tty[datatty] > 0)) {
if ((retval = ts0710_open_channel(dlci)) != 0) {
- TS0710_PRINTK("MUX: Can't connected channel %d!\n",
+ TS0710_DEBUG("MUX: Can't connected channel %d!\n",
dlci);
ts0710_reset_dlci(dlci);
@@ -3096,6 +3100,7 @@
retval = 0;
#endif
out:
+ TS0710_DEBUG("returning %d for open of /dev/mux%d (mux_tty[%d] = %d", retval, line, line, mux_tty[line]);
return retval;
}
@@ -3178,12 +3183,12 @@
while (1) {
tbuf_free = TS0710MUX_MAX_BUF_SIZE - (tbuf_ptr - tbuf);
- TS0710_PRINTK("Reading max %i bytes from ts0710_mux_usb inbuf.\n", tbuf_free);
+ TS0710_DEBUG("Reading max %i bytes from ts0710_mux_usb inbuf.\n", tbuf_free);
tbuf_read = get_from_inbuf_list(tbuf_ptr, tbuf_free);
if (tbuf_read == 0) {
break;
} else {
- TS0710_PRINTK("Read %i bytes.\n", tbuf_read);
+ TS0710_DEBUG("Read %i bytes.\n", tbuf_read);
};
tbuf_ptr += tbuf_read;
};
@@ -3192,7 +3197,7 @@
// Should be impossible?
//if (count > (TS0710MUX_MAX_BUF_SIZE - (tbuf_ptr - tbuf))) {
- // TS0710_PRINTK
+ // TS0710_DEBUG
// ("MUX receive_worker: !!!!! Exceed buffer boundary !!!!!\n");
// count = (TS0710MUX_MAX_BUF_SIZE - (tbuf_ptr - tbuf));
//}
@@ -3264,7 +3269,7 @@
TS0710_LOGSTR_FRAME(0, start_flag,
(tbuf_ptr -
start_flag));
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: %s: frame length:%d is bigger than Max total frame size:%d\n",
/*__FUNCTION__, framelen, TS0710MUX_MAX_TOTAL_FRAME_SIZE);*/
__FUNCTION__, framelen, (TS0710MUX_MAX_TOTAL_FRAME_SIZE + SEQ_FIELD_SIZE)); /*For BP UART problem */
@@ -3389,7 +3394,7 @@
*(uih_data_start
+ uih_len) =
0;
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX bp log: %s\n",
uih_data_start);
}
@@ -3415,7 +3420,7 @@
TS0710_LOGSTR_FRAME(0, start_flag,
framelen);
TS0710_DEBUGHEX(start_flag, framelen);
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX: Lost synchronization!\n");
search = start_flag + 1;
}
@@ -3476,7 +3481,7 @@
recv_info2 = recv_info->next;
if (!(recv_info->total)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: %s: Should not get here, recv_info->total == 0 \n",
__FUNCTION__);
continue;
@@ -3486,7 +3491,7 @@
dlci = tty2dlci[tty_idx];
tty = mux_table[tty_idx];
if ((!mux_tty[tty_idx]) || (!tty)) {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX: No application waiting for, free recv_info! tty_idx:%d\n",
tty_idx);
mux_recv_info_flags[tty_idx] = 0;
@@ -3560,7 +3565,7 @@
recv_info->total -= recv_packet->length;
free_mux_recv_packet(recv_packet);
} else {
- TS0710_PRINTK
+ TS0710_DEBUG
("MUX Error: %s: Should not get here, recv_info->total is:%u \n",
__FUNCTION__, recv_info->total);
}
@@ -3760,7 +3765,7 @@
int ret;
if (idx > TS0710MUX_COUNT_MAX_IDX) {
- TS0710_PRINTK("MUX get_count: invalid idx: %d!\n", idx);
+ TS0710_DEBUG("MUX get_count: invalid idx: %d!\n", idx);
return -1;
}
@@ -3774,11 +3779,11 @@
static int set_count(__u8 idx, int count)
{
if (idx > TS0710MUX_COUNT_MAX_IDX) {
- TS0710_PRINTK("MUX set_count: invalid idx: %d!\n", idx);
+ TS0710_DEBUG("MUX set_count: invalid idx: %d!\n", idx);
return -1;
}
if (count < 0) {
- TS0710_PRINTK("MUX set_count: invalid count: %d!\n", count);
+ TS0710_DEBUG("MUX set_count: invalid count: %d!\n", count);
return -1;
}
@@ -3792,11 +3797,11 @@
static int add_count(__u8 idx, int count)
{
if (idx > TS0710MUX_COUNT_MAX_IDX) {
- TS0710_PRINTK("MUX add_count: invalid idx: %d!\n", idx);
+ TS0710_DEBUG("MUX add_count: invalid idx: %d!\n", idx);
return -1;
}
if (count <= 0) {
- TS0710_PRINTK("MUX add_count: invalid count: %d!\n", count);
+ TS0710_DEBUG("MUX add_count: invalid count: %d!\n", count);
return -1;
}
Index: linux-2.6.20.7/drivers/char/ts0710_mux_usb.c
===================================================================
--- linux-2.6.20.7.orig/drivers/char/ts0710_mux_usb.c 2007-04-22 12:26:47.000000000 +0200
+++ linux-2.6.20.7/drivers/char/ts0710_mux_usb.c 2007-04-22 12:26:47.000000000 +0200
@@ -72,7 +72,8 @@
#define IPC_USB_PROBE_NOT_READY 4
#define DBG_MAX_BUF_SIZE 1024
#define ICL_EVENT_INTERVAL (HZ)
-#undef BVD_DEBUG
+
+#define BVD_DEBUG
#define IS_EP_BULK(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_BULK ? 1 : 0)
#define IS_EP_BULK_IN(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)
|