diff options
author | Tilman Schmidt <tilman@imap.cc> | 2006-04-11 01:55:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-04-11 09:18:49 -0400 |
commit | 784d5858aac58c06608def862d73ae9a32f5ee23 (patch) | |
tree | 992ba2e122df6fc90a935dcc1629186bc7e168ac /drivers/isdn/gigaset/common.c | |
parent | ec81b5e6294088dc4738d0e8c2316c0dc081215c (diff) |
[PATCH] isdn4linux: Siemens Gigaset drivers: logging usage
With Hansjoerg Lipp <hjlipp@web.de>
Improve error reporting of the Gigaset drivers, by using the
dev_err/dev_warn/dev_info macros from device.h instead of err/warn/info from
usb.h whereever possible.
Also rename the private dbg macro to gig_dbg in order to avoid confusion with
the macro of the same name in usb.h.
Signed-off-by: Hansjoerg Lipp <hjlipp@web.de>
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Cc: Karsten Keil <kkeil@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/isdn/gigaset/common.c')
-rw-r--r-- | drivers/isdn/gigaset/common.c | 197 |
1 files changed, 105 insertions, 92 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index a607837b9f6c..fb5cf703133f 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -32,17 +32,14 @@ MODULE_PARM_DESC(debug, "debug level"); | |||
32 | Prototypes of internal functions | 32 | Prototypes of internal functions |
33 | */ | 33 | */ |
34 | 34 | ||
35 | //static void gigaset_process_response(int resp_code, int parameter, | ||
36 | // struct at_state_t *at_state, | ||
37 | // unsigned char ** pstring); | ||
38 | static struct cardstate *alloc_cs(struct gigaset_driver *drv); | 35 | static struct cardstate *alloc_cs(struct gigaset_driver *drv); |
39 | static void free_cs(struct cardstate *cs); | 36 | static void free_cs(struct cardstate *cs); |
40 | static void make_valid(struct cardstate *cs, unsigned mask); | 37 | static void make_valid(struct cardstate *cs, unsigned mask); |
41 | static void make_invalid(struct cardstate *cs, unsigned mask); | 38 | static void make_invalid(struct cardstate *cs, unsigned mask); |
42 | 39 | ||
43 | #define VALID_MINOR 0x01 | 40 | #define VALID_MINOR 0x01 |
44 | #define VALID_ID 0x02 | 41 | #define VALID_ID 0x02 |
45 | #define ASSIGNED 0x04 | 42 | #define ASSIGNED 0x04 |
46 | 43 | ||
47 | /* bitwise byte inversion table */ | 44 | /* bitwise byte inversion table */ |
48 | __u8 gigaset_invtab[256] = { | 45 | __u8 gigaset_invtab[256] = { |
@@ -82,10 +79,11 @@ __u8 gigaset_invtab[256] = { | |||
82 | EXPORT_SYMBOL_GPL(gigaset_invtab); | 79 | EXPORT_SYMBOL_GPL(gigaset_invtab); |
83 | 80 | ||
84 | void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, | 81 | void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, |
85 | size_t len, const unsigned char *buf, int from_user) | 82 | size_t len, const unsigned char *buf, int from_user) |
86 | { | 83 | { |
87 | unsigned char outbuf[80]; | 84 | unsigned char outbuf[80]; |
88 | unsigned char inbuf[80 - 1]; | 85 | unsigned char inbuf[80 - 1]; |
86 | unsigned char c; | ||
89 | size_t numin; | 87 | size_t numin; |
90 | const unsigned char *in; | 88 | const unsigned char *in; |
91 | size_t space = sizeof outbuf - 1; | 89 | size_t space = sizeof outbuf - 1; |
@@ -99,26 +97,38 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, | |||
99 | in = inbuf; | 97 | in = inbuf; |
100 | if (copy_from_user(inbuf, (const unsigned char __user *) buf, | 98 | if (copy_from_user(inbuf, (const unsigned char __user *) buf, |
101 | numin)) { | 99 | numin)) { |
102 | strncpy(inbuf, "<FAULT>", sizeof inbuf); | 100 | gig_dbg(level, "%s (%u bytes) - copy_from_user failed", |
103 | numin = sizeof "<FAULT>" - 1; | 101 | msg, (unsigned) len); |
102 | return; | ||
104 | } | 103 | } |
105 | } | 104 | } |
106 | 105 | ||
107 | for (; numin && space; --numin, ++in) { | 106 | while (numin-- > 0) { |
108 | --space; | 107 | c = *buf++; |
109 | if (*in >= 32) | 108 | if (c == '~' || c == '^' || c == '\\') { |
110 | *out++ = *in; | 109 | if (space-- <= 0) |
111 | else { | 110 | break; |
111 | *out++ = '\\'; | ||
112 | } | ||
113 | if (c & 0x80) { | ||
114 | if (space-- <= 0) | ||
115 | break; | ||
116 | *out++ = '~'; | ||
117 | c ^= 0x80; | ||
118 | } | ||
119 | if (c < 0x20 || c == 0x7f) { | ||
120 | if (space-- <= 0) | ||
121 | break; | ||
112 | *out++ = '^'; | 122 | *out++ = '^'; |
113 | if (space) { | 123 | c ^= 0x40; |
114 | *out++ = '@' + *in; | ||
115 | --space; | ||
116 | } | ||
117 | } | 124 | } |
125 | if (space-- <= 0) | ||
126 | break; | ||
127 | *out++ = c; | ||
118 | } | 128 | } |
119 | *out = 0; | 129 | *out = 0; |
120 | 130 | ||
121 | dbg(level, "%s (%u bytes): %s", msg, (unsigned) len, outbuf); | 131 | gig_dbg(level, "%s (%u bytes): %s", msg, (unsigned) len, outbuf); |
122 | } | 132 | } |
123 | EXPORT_SYMBOL_GPL(gigaset_dbg_buffer); | 133 | EXPORT_SYMBOL_GPL(gigaset_dbg_buffer); |
124 | 134 | ||
@@ -171,7 +181,7 @@ int gigaset_enterconfigmode(struct cardstate *cs) | |||
171 | return 0; | 181 | return 0; |
172 | 182 | ||
173 | error: | 183 | error: |
174 | err("error %d on setuartbits!\n", -r); | 184 | dev_err(cs->dev, "error %d on setuartbits\n", -r); |
175 | cs->control_state = TIOCM_RTS|TIOCM_DTR; // FIXME is this a good value? | 185 | cs->control_state = TIOCM_RTS|TIOCM_DTR; // FIXME is this a good value? |
176 | cs->ops->set_modem_ctrl(cs, 0, TIOCM_RTS|TIOCM_DTR); | 186 | cs->ops->set_modem_ctrl(cs, 0, TIOCM_RTS|TIOCM_DTR); |
177 | 187 | ||
@@ -184,13 +194,13 @@ static int test_timeout(struct at_state_t *at_state) | |||
184 | return 0; | 194 | return 0; |
185 | 195 | ||
186 | if (--at_state->timer_expires) { | 196 | if (--at_state->timer_expires) { |
187 | dbg(DEBUG_MCMD, "decreased timer of %p to %lu", | 197 | gig_dbg(DEBUG_MCMD, "decreased timer of %p to %lu", |
188 | at_state, at_state->timer_expires); | 198 | at_state, at_state->timer_expires); |
189 | return 0; | 199 | return 0; |
190 | } | 200 | } |
191 | 201 | ||
192 | if (!gigaset_add_event(at_state->cs, at_state, EV_TIMEOUT, NULL, | 202 | if (!gigaset_add_event(at_state->cs, at_state, EV_TIMEOUT, NULL, |
193 | atomic_read(&at_state->timer_index), NULL)) { | 203 | atomic_read(&at_state->timer_index), NULL)) { |
194 | //FIXME what should we do? | 204 | //FIXME what should we do? |
195 | } | 205 | } |
196 | 206 | ||
@@ -221,7 +231,7 @@ static void timer_tick(unsigned long data) | |||
221 | if (atomic_read(&cs->running)) { | 231 | if (atomic_read(&cs->running)) { |
222 | mod_timer(&cs->timer, jiffies + msecs_to_jiffies(GIG_TICK)); | 232 | mod_timer(&cs->timer, jiffies + msecs_to_jiffies(GIG_TICK)); |
223 | if (timeout) { | 233 | if (timeout) { |
224 | dbg(DEBUG_CMD, "scheduling timeout"); | 234 | gig_dbg(DEBUG_CMD, "scheduling timeout"); |
225 | tasklet_schedule(&cs->event_tasklet); | 235 | tasklet_schedule(&cs->event_tasklet); |
226 | } | 236 | } |
227 | } | 237 | } |
@@ -235,13 +245,14 @@ int gigaset_get_channel(struct bc_state *bcs) | |||
235 | 245 | ||
236 | spin_lock_irqsave(&bcs->cs->lock, flags); | 246 | spin_lock_irqsave(&bcs->cs->lock, flags); |
237 | if (bcs->use_count) { | 247 | if (bcs->use_count) { |
238 | dbg(DEBUG_ANY, "could not allocate channel %d", bcs->channel); | 248 | gig_dbg(DEBUG_ANY, "could not allocate channel %d", |
249 | bcs->channel); | ||
239 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | 250 | spin_unlock_irqrestore(&bcs->cs->lock, flags); |
240 | return 0; | 251 | return 0; |
241 | } | 252 | } |
242 | ++bcs->use_count; | 253 | ++bcs->use_count; |
243 | bcs->busy = 1; | 254 | bcs->busy = 1; |
244 | dbg(DEBUG_ANY, "allocated channel %d", bcs->channel); | 255 | gig_dbg(DEBUG_ANY, "allocated channel %d", bcs->channel); |
245 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | 256 | spin_unlock_irqrestore(&bcs->cs->lock, flags); |
246 | return 1; | 257 | return 1; |
247 | } | 258 | } |
@@ -252,13 +263,13 @@ void gigaset_free_channel(struct bc_state *bcs) | |||
252 | 263 | ||
253 | spin_lock_irqsave(&bcs->cs->lock, flags); | 264 | spin_lock_irqsave(&bcs->cs->lock, flags); |
254 | if (!bcs->busy) { | 265 | if (!bcs->busy) { |
255 | dbg(DEBUG_ANY, "could not free channel %d", bcs->channel); | 266 | gig_dbg(DEBUG_ANY, "could not free channel %d", bcs->channel); |
256 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | 267 | spin_unlock_irqrestore(&bcs->cs->lock, flags); |
257 | return; | 268 | return; |
258 | } | 269 | } |
259 | --bcs->use_count; | 270 | --bcs->use_count; |
260 | bcs->busy = 0; | 271 | bcs->busy = 0; |
261 | dbg(DEBUG_ANY, "freed channel %d", bcs->channel); | 272 | gig_dbg(DEBUG_ANY, "freed channel %d", bcs->channel); |
262 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | 273 | spin_unlock_irqrestore(&bcs->cs->lock, flags); |
263 | } | 274 | } |
264 | 275 | ||
@@ -271,14 +282,14 @@ int gigaset_get_channels(struct cardstate *cs) | |||
271 | for (i = 0; i < cs->channels; ++i) | 282 | for (i = 0; i < cs->channels; ++i) |
272 | if (cs->bcs[i].use_count) { | 283 | if (cs->bcs[i].use_count) { |
273 | spin_unlock_irqrestore(&cs->lock, flags); | 284 | spin_unlock_irqrestore(&cs->lock, flags); |
274 | dbg(DEBUG_ANY, "could not allocated all channels"); | 285 | gig_dbg(DEBUG_ANY, "could not allocate all channels"); |
275 | return 0; | 286 | return 0; |
276 | } | 287 | } |
277 | for (i = 0; i < cs->channels; ++i) | 288 | for (i = 0; i < cs->channels; ++i) |
278 | ++cs->bcs[i].use_count; | 289 | ++cs->bcs[i].use_count; |
279 | spin_unlock_irqrestore(&cs->lock, flags); | 290 | spin_unlock_irqrestore(&cs->lock, flags); |
280 | 291 | ||
281 | dbg(DEBUG_ANY, "allocated all channels"); | 292 | gig_dbg(DEBUG_ANY, "allocated all channels"); |
282 | 293 | ||
283 | return 1; | 294 | return 1; |
284 | } | 295 | } |
@@ -288,7 +299,7 @@ void gigaset_free_channels(struct cardstate *cs) | |||
288 | unsigned long flags; | 299 | unsigned long flags; |
289 | int i; | 300 | int i; |
290 | 301 | ||
291 | dbg(DEBUG_ANY, "unblocking all channels"); | 302 | gig_dbg(DEBUG_ANY, "unblocking all channels"); |
292 | spin_lock_irqsave(&cs->lock, flags); | 303 | spin_lock_irqsave(&cs->lock, flags); |
293 | for (i = 0; i < cs->channels; ++i) | 304 | for (i = 0; i < cs->channels; ++i) |
294 | --cs->bcs[i].use_count; | 305 | --cs->bcs[i].use_count; |
@@ -300,7 +311,7 @@ void gigaset_block_channels(struct cardstate *cs) | |||
300 | unsigned long flags; | 311 | unsigned long flags; |
301 | int i; | 312 | int i; |
302 | 313 | ||
303 | dbg(DEBUG_ANY, "blocking all channels"); | 314 | gig_dbg(DEBUG_ANY, "blocking all channels"); |
304 | spin_lock_irqsave(&cs->lock, flags); | 315 | spin_lock_irqsave(&cs->lock, flags); |
305 | for (i = 0; i < cs->channels; ++i) | 316 | for (i = 0; i < cs->channels; ++i) |
306 | ++cs->bcs[i].use_count; | 317 | ++cs->bcs[i].use_count; |
@@ -328,8 +339,8 @@ static void clear_events(struct cardstate *cs) | |||
328 | } | 339 | } |
329 | 340 | ||
330 | struct event_t *gigaset_add_event(struct cardstate *cs, | 341 | struct event_t *gigaset_add_event(struct cardstate *cs, |
331 | struct at_state_t *at_state, int type, | 342 | struct at_state_t *at_state, int type, |
332 | void *ptr, int parameter, void *arg) | 343 | void *ptr, int parameter, void *arg) |
333 | { | 344 | { |
334 | unsigned long flags; | 345 | unsigned long flags; |
335 | unsigned next, tail; | 346 | unsigned next, tail; |
@@ -388,14 +399,14 @@ static void gigaset_freebcs(struct bc_state *bcs) | |||
388 | { | 399 | { |
389 | int i; | 400 | int i; |
390 | 401 | ||
391 | dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel); | 402 | gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel); |
392 | if (!bcs->cs->ops->freebcshw(bcs)) { | 403 | if (!bcs->cs->ops->freebcshw(bcs)) { |
393 | dbg(DEBUG_INIT, "failed"); | 404 | gig_dbg(DEBUG_INIT, "failed"); |
394 | } | 405 | } |
395 | 406 | ||
396 | dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel); | 407 | gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel); |
397 | clear_at_state(&bcs->at_state); | 408 | clear_at_state(&bcs->at_state); |
398 | dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel); | 409 | gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel); |
399 | 410 | ||
400 | if (bcs->skb) | 411 | if (bcs->skb) |
401 | dev_kfree_skb(bcs->skb); | 412 | dev_kfree_skb(bcs->skb); |
@@ -432,7 +443,7 @@ void gigaset_freecs(struct cardstate *cs) | |||
432 | default: | 443 | default: |
433 | gigaset_if_free(cs); | 444 | gigaset_if_free(cs); |
434 | 445 | ||
435 | dbg(DEBUG_INIT, "clearing hw"); | 446 | gig_dbg(DEBUG_INIT, "clearing hw"); |
436 | cs->ops->freecshw(cs); | 447 | cs->ops->freecshw(cs); |
437 | 448 | ||
438 | //FIXME cmdbuf | 449 | //FIXME cmdbuf |
@@ -441,36 +452,36 @@ void gigaset_freecs(struct cardstate *cs) | |||
441 | case 2: /* error in initcshw */ | 452 | case 2: /* error in initcshw */ |
442 | /* Deregister from LL */ | 453 | /* Deregister from LL */ |
443 | make_invalid(cs, VALID_ID); | 454 | make_invalid(cs, VALID_ID); |
444 | dbg(DEBUG_INIT, "clearing iif"); | 455 | gig_dbg(DEBUG_INIT, "clearing iif"); |
445 | gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD); | 456 | gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD); |
446 | 457 | ||
447 | /* fall through */ | 458 | /* fall through */ |
448 | case 1: /* error when regestering to LL */ | 459 | case 1: /* error when regestering to LL */ |
449 | dbg(DEBUG_INIT, "clearing at_state"); | 460 | gig_dbg(DEBUG_INIT, "clearing at_state"); |
450 | clear_at_state(&cs->at_state); | 461 | clear_at_state(&cs->at_state); |
451 | dealloc_at_states(cs); | 462 | dealloc_at_states(cs); |
452 | 463 | ||
453 | /* fall through */ | 464 | /* fall through */ |
454 | case 0: /* error in one call to initbcs */ | 465 | case 0: /* error in one call to initbcs */ |
455 | for (i = 0; i < cs->channels; ++i) { | 466 | for (i = 0; i < cs->channels; ++i) { |
456 | dbg(DEBUG_INIT, "clearing bcs[%d]", i); | 467 | gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i); |
457 | gigaset_freebcs(cs->bcs + i); | 468 | gigaset_freebcs(cs->bcs + i); |
458 | } | 469 | } |
459 | 470 | ||
460 | clear_events(cs); | 471 | clear_events(cs); |
461 | dbg(DEBUG_INIT, "freeing inbuf"); | 472 | gig_dbg(DEBUG_INIT, "freeing inbuf"); |
462 | kfree(cs->inbuf); | 473 | kfree(cs->inbuf); |
463 | } | 474 | } |
464 | f_bcs: dbg(DEBUG_INIT, "freeing bcs[]"); | 475 | f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]"); |
465 | kfree(cs->bcs); | 476 | kfree(cs->bcs); |
466 | f_cs: dbg(DEBUG_INIT, "freeing cs"); | 477 | f_cs: gig_dbg(DEBUG_INIT, "freeing cs"); |
467 | up(&cs->sem); | 478 | up(&cs->sem); |
468 | free_cs(cs); | 479 | free_cs(cs); |
469 | } | 480 | } |
470 | EXPORT_SYMBOL_GPL(gigaset_freecs); | 481 | EXPORT_SYMBOL_GPL(gigaset_freecs); |
471 | 482 | ||
472 | void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs, | 483 | void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs, |
473 | struct cardstate *cs, int cid) | 484 | struct cardstate *cs, int cid) |
474 | { | 485 | { |
475 | int i; | 486 | int i; |
476 | 487 | ||
@@ -499,7 +510,7 @@ void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs, | |||
499 | 510 | ||
500 | 511 | ||
501 | static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs, | 512 | static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs, |
502 | struct cardstate *cs, int inputstate) | 513 | struct cardstate *cs, int inputstate) |
503 | /* inbuf->read must be allocated before! */ | 514 | /* inbuf->read must be allocated before! */ |
504 | { | 515 | { |
505 | atomic_set(&inbuf->head, 0); | 516 | atomic_set(&inbuf->head, 0); |
@@ -512,7 +523,7 @@ static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs, | |||
512 | 523 | ||
513 | /* Initialize the b-channel structure */ | 524 | /* Initialize the b-channel structure */ |
514 | static struct bc_state *gigaset_initbcs(struct bc_state *bcs, | 525 | static struct bc_state *gigaset_initbcs(struct bc_state *bcs, |
515 | struct cardstate *cs, int channel) | 526 | struct cardstate *cs, int channel) |
516 | { | 527 | { |
517 | int i; | 528 | int i; |
518 | 529 | ||
@@ -524,7 +535,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, | |||
524 | bcs->trans_down = 0; | 535 | bcs->trans_down = 0; |
525 | bcs->trans_up = 0; | 536 | bcs->trans_up = 0; |
526 | 537 | ||
527 | dbg(DEBUG_INIT, "setting up bcs[%d]->at_state", channel); | 538 | gig_dbg(DEBUG_INIT, "setting up bcs[%d]->at_state", channel); |
528 | gigaset_at_init(&bcs->at_state, bcs, cs, -1); | 539 | gigaset_at_init(&bcs->at_state, bcs, cs, -1); |
529 | 540 | ||
530 | bcs->rcvbytes = 0; | 541 | bcs->rcvbytes = 0; |
@@ -533,7 +544,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, | |||
533 | bcs->emptycount = 0; | 544 | bcs->emptycount = 0; |
534 | #endif | 545 | #endif |
535 | 546 | ||
536 | dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel); | 547 | gig_dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel); |
537 | bcs->fcs = PPP_INITFCS; | 548 | bcs->fcs = PPP_INITFCS; |
538 | bcs->inputstate = 0; | 549 | bcs->inputstate = 0; |
539 | if (cs->ignoreframes) { | 550 | if (cs->ignoreframes) { |
@@ -542,7 +553,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, | |||
542 | } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) | 553 | } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) |
543 | skb_reserve(bcs->skb, HW_HDR_LEN); | 554 | skb_reserve(bcs->skb, HW_HDR_LEN); |
544 | else { | 555 | else { |
545 | warn("could not allocate skb"); | 556 | dev_warn(cs->dev, "could not allocate skb\n"); |
546 | bcs->inputstate |= INS_skip_frame; | 557 | bcs->inputstate |= INS_skip_frame; |
547 | } | 558 | } |
548 | 559 | ||
@@ -557,13 +568,13 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, | |||
557 | for (i = 0; i < AT_NUM; ++i) | 568 | for (i = 0; i < AT_NUM; ++i) |
558 | bcs->commands[i] = NULL; | 569 | bcs->commands[i] = NULL; |
559 | 570 | ||
560 | dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel); | 571 | gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel); |
561 | if (cs->ops->initbcshw(bcs)) | 572 | if (cs->ops->initbcshw(bcs)) |
562 | return bcs; | 573 | return bcs; |
563 | 574 | ||
564 | dbg(DEBUG_INIT, " failed"); | 575 | gig_dbg(DEBUG_INIT, " failed"); |
565 | 576 | ||
566 | dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel); | 577 | gig_dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel); |
567 | if (bcs->skb) | 578 | if (bcs->skb) |
568 | dev_kfree_skb(bcs->skb); | 579 | dev_kfree_skb(bcs->skb); |
569 | 580 | ||
@@ -575,7 +586,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, | |||
575 | * Calls hardware dependent gigaset_initcshw() function | 586 | * Calls hardware dependent gigaset_initcshw() function |
576 | * Calls B channel initialization function gigaset_initbcs() for each B channel | 587 | * Calls B channel initialization function gigaset_initbcs() for each B channel |
577 | * parameters: | 588 | * parameters: |
578 | * drv hardware driver the device belongs to | 589 | * drv hardware driver the device belongs to |
579 | * channels number of B channels supported by device | 590 | * channels number of B channels supported by device |
580 | * onechannel !=0: B channel data and AT commands share one | 591 | * onechannel !=0: B channel data and AT commands share one |
581 | * communication channel | 592 | * communication channel |
@@ -593,15 +604,15 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
593 | struct cardstate *cs = NULL; | 604 | struct cardstate *cs = NULL; |
594 | int i; | 605 | int i; |
595 | 606 | ||
596 | dbg(DEBUG_INIT, "allocating cs"); | 607 | gig_dbg(DEBUG_INIT, "allocating cs"); |
597 | cs = alloc_cs(drv); | 608 | cs = alloc_cs(drv); |
598 | if (!cs) | 609 | if (!cs) |
599 | goto error; | 610 | goto error; |
600 | dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); | 611 | gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); |
601 | cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); | 612 | cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); |
602 | if (!cs->bcs) | 613 | if (!cs->bcs) |
603 | goto error; | 614 | goto error; |
604 | dbg(DEBUG_INIT, "allocating inbuf"); | 615 | gig_dbg(DEBUG_INIT, "allocating inbuf"); |
605 | cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL); | 616 | cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL); |
606 | if (!cs->inbuf) | 617 | if (!cs->inbuf) |
607 | goto error; | 618 | goto error; |
@@ -623,6 +634,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
623 | cs->cur_at_seq = 0; | 634 | cs->cur_at_seq = 0; |
624 | cs->gotfwver = -1; | 635 | cs->gotfwver = -1; |
625 | cs->open_count = 0; | 636 | cs->open_count = 0; |
637 | cs->dev = NULL; | ||
626 | cs->tty = NULL; | 638 | cs->tty = NULL; |
627 | atomic_set(&cs->cidmode, cidmode != 0); | 639 | atomic_set(&cs->cidmode, cidmode != 0); |
628 | 640 | ||
@@ -641,20 +653,20 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
641 | atomic_set(&cs->mstate, MS_UNINITIALIZED); | 653 | atomic_set(&cs->mstate, MS_UNINITIALIZED); |
642 | 654 | ||
643 | for (i = 0; i < channels; ++i) { | 655 | for (i = 0; i < channels; ++i) { |
644 | dbg(DEBUG_INIT, "setting up bcs[%d].read", i); | 656 | gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i); |
645 | if (!gigaset_initbcs(cs->bcs + i, cs, i)) | 657 | if (!gigaset_initbcs(cs->bcs + i, cs, i)) |
646 | goto error; | 658 | goto error; |
647 | } | 659 | } |
648 | 660 | ||
649 | ++cs->cs_init; | 661 | ++cs->cs_init; |
650 | 662 | ||
651 | dbg(DEBUG_INIT, "setting up at_state"); | 663 | gig_dbg(DEBUG_INIT, "setting up at_state"); |
652 | spin_lock_init(&cs->lock); | 664 | spin_lock_init(&cs->lock); |
653 | gigaset_at_init(&cs->at_state, NULL, cs, 0); | 665 | gigaset_at_init(&cs->at_state, NULL, cs, 0); |
654 | cs->dle = 0; | 666 | cs->dle = 0; |
655 | cs->cbytes = 0; | 667 | cs->cbytes = 0; |
656 | 668 | ||
657 | dbg(DEBUG_INIT, "setting up inbuf"); | 669 | gig_dbg(DEBUG_INIT, "setting up inbuf"); |
658 | if (onechannel) { //FIXME distinction necessary? | 670 | if (onechannel) { //FIXME distinction necessary? |
659 | gigaset_inbuf_init(cs->inbuf, cs->bcs, cs, INS_command); | 671 | gigaset_inbuf_init(cs->inbuf, cs->bcs, cs, INS_command); |
660 | } else | 672 | } else |
@@ -662,21 +674,21 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
662 | 674 | ||
663 | atomic_set(&cs->connected, 0); | 675 | atomic_set(&cs->connected, 0); |
664 | 676 | ||
665 | dbg(DEBUG_INIT, "setting up cmdbuf"); | 677 | gig_dbg(DEBUG_INIT, "setting up cmdbuf"); |
666 | cs->cmdbuf = cs->lastcmdbuf = NULL; | 678 | cs->cmdbuf = cs->lastcmdbuf = NULL; |
667 | spin_lock_init(&cs->cmdlock); | 679 | spin_lock_init(&cs->cmdlock); |
668 | cs->curlen = 0; | 680 | cs->curlen = 0; |
669 | cs->cmdbytes = 0; | 681 | cs->cmdbytes = 0; |
670 | 682 | ||
671 | dbg(DEBUG_INIT, "setting up iif"); | 683 | gig_dbg(DEBUG_INIT, "setting up iif"); |
672 | if (!gigaset_register_to_LL(cs, modulename)) { | 684 | if (!gigaset_register_to_LL(cs, modulename)) { |
673 | err("register_isdn=>error"); | 685 | err("register_isdn failed"); |
674 | goto error; | 686 | goto error; |
675 | } | 687 | } |
676 | 688 | ||
677 | make_valid(cs, VALID_ID); | 689 | make_valid(cs, VALID_ID); |
678 | ++cs->cs_init; | 690 | ++cs->cs_init; |
679 | dbg(DEBUG_INIT, "setting up hw"); | 691 | gig_dbg(DEBUG_INIT, "setting up hw"); |
680 | if (!cs->ops->initcshw(cs)) | 692 | if (!cs->ops->initcshw(cs)) |
681 | goto error; | 693 | goto error; |
682 | 694 | ||
@@ -691,13 +703,13 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
691 | * Same problem(?) with mod_timer() in timer_tick(). */ | 703 | * Same problem(?) with mod_timer() in timer_tick(). */ |
692 | add_timer(&cs->timer); | 704 | add_timer(&cs->timer); |
693 | 705 | ||
694 | dbg(DEBUG_INIT, "cs initialized!"); | 706 | gig_dbg(DEBUG_INIT, "cs initialized"); |
695 | up(&cs->sem); | 707 | up(&cs->sem); |
696 | return cs; | 708 | return cs; |
697 | 709 | ||
698 | error: if (cs) | 710 | error: if (cs) |
699 | up(&cs->sem); | 711 | up(&cs->sem); |
700 | dbg(DEBUG_INIT, "failed"); | 712 | gig_dbg(DEBUG_INIT, "failed"); |
701 | gigaset_freecs(cs); | 713 | gigaset_freecs(cs); |
702 | return NULL; | 714 | return NULL; |
703 | } | 715 | } |
@@ -719,7 +731,7 @@ void gigaset_bcs_reinit(struct bc_state *bcs) | |||
719 | bcs->at_state.ConState = 0; | 731 | bcs->at_state.ConState = 0; |
720 | bcs->at_state.timer_active = 0; | 732 | bcs->at_state.timer_active = 0; |
721 | bcs->at_state.timer_expires = 0; | 733 | bcs->at_state.timer_expires = 0; |
722 | bcs->at_state.cid = -1; /* No CID defined */ | 734 | bcs->at_state.cid = -1; /* No CID defined */ |
723 | spin_unlock_irqrestore(&cs->lock, flags); | 735 | spin_unlock_irqrestore(&cs->lock, flags); |
724 | 736 | ||
725 | bcs->inputstate = 0; | 737 | bcs->inputstate = 0; |
@@ -816,7 +828,7 @@ int gigaset_start(struct cardstate *cs) | |||
816 | goto error; | 828 | goto error; |
817 | } | 829 | } |
818 | 830 | ||
819 | dbg(DEBUG_CMD, "scheduling START"); | 831 | gig_dbg(DEBUG_CMD, "scheduling START"); |
820 | gigaset_schedule_event(cs); | 832 | gigaset_schedule_event(cs); |
821 | 833 | ||
822 | wait_event(cs->waitqueue, !cs->waiting); | 834 | wait_event(cs->waitqueue, !cs->waiting); |
@@ -841,11 +853,11 @@ void gigaset_shutdown(struct cardstate *cs) | |||
841 | goto exit; | 853 | goto exit; |
842 | } | 854 | } |
843 | 855 | ||
844 | dbg(DEBUG_CMD, "scheduling SHUTDOWN"); | 856 | gig_dbg(DEBUG_CMD, "scheduling SHUTDOWN"); |
845 | gigaset_schedule_event(cs); | 857 | gigaset_schedule_event(cs); |
846 | 858 | ||
847 | if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) { | 859 | if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) { |
848 | warn("aborted"); | 860 | warn("%s: aborted", __func__); |
849 | //FIXME | 861 | //FIXME |
850 | } | 862 | } |
851 | 863 | ||
@@ -879,11 +891,11 @@ void gigaset_stop(struct cardstate *cs) | |||
879 | goto exit; | 891 | goto exit; |
880 | } | 892 | } |
881 | 893 | ||
882 | dbg(DEBUG_CMD, "scheduling STOP"); | 894 | gig_dbg(DEBUG_CMD, "scheduling STOP"); |
883 | gigaset_schedule_event(cs); | 895 | gigaset_schedule_event(cs); |
884 | 896 | ||
885 | if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) { | 897 | if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) { |
886 | warn("aborted"); | 898 | warn("%s: aborted", __func__); |
887 | //FIXME | 899 | //FIXME |
888 | } | 900 | } |
889 | 901 | ||
@@ -937,17 +949,18 @@ void gigaset_debugdrivers(void) | |||
937 | 949 | ||
938 | spin_lock_irqsave(&driver_lock, flags); | 950 | spin_lock_irqsave(&driver_lock, flags); |
939 | list_for_each_entry(drv, &drivers, list) { | 951 | list_for_each_entry(drv, &drivers, list) { |
940 | dbg(DEBUG_DRIVER, "driver %p", drv); | 952 | gig_dbg(DEBUG_DRIVER, "driver %p", drv); |
941 | spin_lock(&drv->lock); | 953 | spin_lock(&drv->lock); |
942 | for (i = 0; i < drv->minors; ++i) { | 954 | for (i = 0; i < drv->minors; ++i) { |
943 | dbg(DEBUG_DRIVER, " index %u", i); | 955 | gig_dbg(DEBUG_DRIVER, " index %u", i); |
944 | dbg(DEBUG_DRIVER, " flags 0x%02x", drv->flags[i]); | 956 | gig_dbg(DEBUG_DRIVER, " flags 0x%02x", |
957 | drv->flags[i]); | ||
945 | cs = drv->cs + i; | 958 | cs = drv->cs + i; |
946 | dbg(DEBUG_DRIVER, " cardstate %p", cs); | 959 | gig_dbg(DEBUG_DRIVER, " cardstate %p", cs); |
947 | dbg(DEBUG_DRIVER, " minor_index %u", | 960 | gig_dbg(DEBUG_DRIVER, " minor_index %u", |
948 | cs->minor_index); | 961 | cs->minor_index); |
949 | dbg(DEBUG_DRIVER, " driver %p", cs->driver); | 962 | gig_dbg(DEBUG_DRIVER, " driver %p", cs->driver); |
950 | dbg(DEBUG_DRIVER, " i4l id %d", cs->myid); | 963 | gig_dbg(DEBUG_DRIVER, " i4l id %d", cs->myid); |
951 | } | 964 | } |
952 | spin_unlock(&drv->lock); | 965 | spin_unlock(&drv->lock); |
953 | } | 966 | } |
@@ -1005,20 +1018,20 @@ EXPORT_SYMBOL_GPL(gigaset_freedriver); | |||
1005 | /* gigaset_initdriver | 1018 | /* gigaset_initdriver |
1006 | * Allocate and initialize gigaset_driver structure. Initialize interface. | 1019 | * Allocate and initialize gigaset_driver structure. Initialize interface. |
1007 | * parameters: | 1020 | * parameters: |
1008 | * minor First minor number | 1021 | * minor First minor number |
1009 | * minors Number of minors this driver can handle | 1022 | * minors Number of minors this driver can handle |
1010 | * procname Name of the driver | 1023 | * procname Name of the driver |
1011 | * devname Name of the device files (prefix without minor number) | 1024 | * devname Name of the device files (prefix without minor number) |
1012 | * devfsname Devfs name of the device files without %d | 1025 | * devfsname Devfs name of the device files without %d |
1013 | * return value: | 1026 | * return value: |
1014 | * Pointer to the gigaset_driver structure on success, NULL on failure. | 1027 | * Pointer to the gigaset_driver structure on success, NULL on failure. |
1015 | */ | 1028 | */ |
1016 | struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, | 1029 | struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, |
1017 | const char *procname, | 1030 | const char *procname, |
1018 | const char *devname, | 1031 | const char *devname, |
1019 | const char *devfsname, | 1032 | const char *devfsname, |
1020 | const struct gigaset_ops *ops, | 1033 | const struct gigaset_ops *ops, |
1021 | struct module *owner) | 1034 | struct module *owner) |
1022 | { | 1035 | { |
1023 | struct gigaset_driver *drv; | 1036 | struct gigaset_driver *drv; |
1024 | unsigned long flags; | 1037 | unsigned long flags; |