aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2006-04-11 01:55:04 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-11 09:18:49 -0400
commit784d5858aac58c06608def862d73ae9a32f5ee23 (patch)
tree992ba2e122df6fc90a935dcc1629186bc7e168ac /drivers/isdn
parentec81b5e6294088dc4738d0e8c2316c0dc081215c (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')
-rw-r--r--drivers/isdn/gigaset/asyncdata.c80
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c611
-rw-r--r--drivers/isdn/gigaset/common.c197
-rw-r--r--drivers/isdn/gigaset/ev-layer.c265
-rw-r--r--drivers/isdn/gigaset/gigaset.h199
-rw-r--r--drivers/isdn/gigaset/i4l.c178
-rw-r--r--drivers/isdn/gigaset/interface.c157
-rw-r--r--drivers/isdn/gigaset/isocdata.c109
-rw-r--r--drivers/isdn/gigaset/proc.c8
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c239
10 files changed, 1078 insertions, 965 deletions
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c
index 778d864ab612..a375d0a411b5 100644
--- a/drivers/isdn/gigaset/asyncdata.c
+++ b/drivers/isdn/gigaset/asyncdata.c
@@ -41,7 +41,7 @@ static inline int muststuff(unsigned char c)
41 * number of processed bytes 41 * number of processed bytes
42 */ 42 */
43static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes, 43static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
44 struct inbuf_t *inbuf) 44 struct inbuf_t *inbuf)
45{ 45{
46 struct cardstate *cs = inbuf->cs; 46 struct cardstate *cs = inbuf->cs;
47 unsigned cbytes = cs->cbytes; 47 unsigned cbytes = cs->cbytes;
@@ -51,8 +51,8 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
51 for (;;) { 51 for (;;) {
52 cs->respdata[cbytes] = c; 52 cs->respdata[cbytes] = c;
53 if (c == 10 || c == 13) { 53 if (c == 10 || c == 13) {
54 dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)", 54 gig_dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
55 __func__, cbytes); 55 __func__, cbytes);
56 cs->cbytes = cbytes; 56 cs->cbytes = cbytes;
57 gigaset_handle_modem_response(cs); /* can change 57 gigaset_handle_modem_response(cs); /* can change
58 cs->dle */ 58 cs->dle */
@@ -68,7 +68,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
68 if (cbytes < MAX_RESP_SIZE - 1) 68 if (cbytes < MAX_RESP_SIZE - 1)
69 cbytes++; 69 cbytes++;
70 else 70 else
71 warn("response too large"); 71 dev_warn(cs->dev, "response too large\n");
72 } 72 }
73 73
74 if (!numbytes) 74 if (!numbytes)
@@ -93,7 +93,7 @@ static inline int cmd_loop(unsigned char c, unsigned char *src, int numbytes,
93 * number of processed bytes 93 * number of processed bytes
94 */ 94 */
95static inline int lock_loop(unsigned char *src, int numbytes, 95static inline int lock_loop(unsigned char *src, int numbytes,
96 struct inbuf_t *inbuf) 96 struct inbuf_t *inbuf)
97{ 97{
98 struct cardstate *cs = inbuf->cs; 98 struct cardstate *cs = inbuf->cs;
99 99
@@ -113,7 +113,7 @@ static inline int lock_loop(unsigned char *src, int numbytes,
113 * numbytes (all bytes processed) on error --FIXME 113 * numbytes (all bytes processed) on error --FIXME
114 */ 114 */
115static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes, 115static inline int hdlc_loop(unsigned char c, unsigned char *src, int numbytes,
116 struct inbuf_t *inbuf) 116 struct inbuf_t *inbuf)
117{ 117{
118 struct cardstate *cs = inbuf->cs; 118 struct cardstate *cs = inbuf->cs;
119 struct bc_state *bcs = inbuf->bcs; 119 struct bc_state *bcs = inbuf->bcs;
@@ -154,39 +154,37 @@ byte_stuff:
154 c ^= PPP_TRANS; 154 c ^= PPP_TRANS;
155#ifdef CONFIG_GIGASET_DEBUG 155#ifdef CONFIG_GIGASET_DEBUG
156 if (unlikely(!muststuff(c))) 156 if (unlikely(!muststuff(c)))
157 dbg(DEBUG_HDLC, 157 gig_dbg(DEBUG_HDLC, "byte stuffed: 0x%02x", c);
158 "byte stuffed: 0x%02x", c);
159#endif 158#endif
160 } else if (unlikely(c == PPP_FLAG)) { 159 } else if (unlikely(c == PPP_FLAG)) {
161 if (unlikely(inputstate & INS_skip_frame)) { 160 if (unlikely(inputstate & INS_skip_frame)) {
162 if (!(inputstate & INS_have_data)) { /* 7E 7E */ 161 if (!(inputstate & INS_have_data)) { /* 7E 7E */
163 //dbg(DEBUG_HDLC, "(7e)7e------------------------");
164#ifdef CONFIG_GIGASET_DEBUG 162#ifdef CONFIG_GIGASET_DEBUG
165 ++bcs->emptycount; 163 ++bcs->emptycount;
166#endif 164#endif
167 } else 165 } else
168 dbg(DEBUG_HDLC, 166 gig_dbg(DEBUG_HDLC,
169 "7e----------------------------"); 167 "7e----------------------------");
170 168
171 /* end of frame */ 169 /* end of frame */
172 error = 1; 170 error = 1;
173 gigaset_rcv_error(NULL, cs, bcs); 171 gigaset_rcv_error(NULL, cs, bcs);
174 } else if (!(inputstate & INS_have_data)) { /* 7E 7E */ 172 } else if (!(inputstate & INS_have_data)) { /* 7E 7E */
175 //dbg(DEBUG_HDLC, "(7e)7e------------------------");
176#ifdef CONFIG_GIGASET_DEBUG 173#ifdef CONFIG_GIGASET_DEBUG
177 ++bcs->emptycount; 174 ++bcs->emptycount;
178#endif 175#endif
179 break; 176 break;
180 } else { 177 } else {
181 dbg(DEBUG_HDLC, 178 gig_dbg(DEBUG_HDLC,
182 "7e----------------------------"); 179 "7e----------------------------");
183 180
184 /* end of frame */ 181 /* end of frame */
185 error = 0; 182 error = 0;
186 183
187 if (unlikely(fcs != PPP_GOODFCS)) { 184 if (unlikely(fcs != PPP_GOODFCS)) {
188 err("Packet checksum at %lu failed, " 185 dev_err(cs->dev,
189 "packet is corrupted (%u bytes)!", 186 "Packet checksum at %lu failed, "
187 "packet is corrupted (%u bytes)!\n",
190 bcs->rcvbytes, skb->len); 188 bcs->rcvbytes, skb->len);
191 compskb = NULL; 189 compskb = NULL;
192 gigaset_rcv_error(compskb, cs, bcs); 190 gigaset_rcv_error(compskb, cs, bcs);
@@ -200,9 +198,11 @@ byte_stuff:
200 skb = NULL; 198 skb = NULL;
201 inputstate |= INS_skip_frame; 199 inputstate |= INS_skip_frame;
202 if (l == 1) { 200 if (l == 1) {
203 err("invalid packet size (1)!"); 201 dev_err(cs->dev,
202 "invalid packet size (1)!\n");
204 error = 1; 203 error = 1;
205 gigaset_rcv_error(NULL, cs, bcs); 204 gigaset_rcv_error(NULL,
205 cs, bcs);
206 } 206 }
207 } 207 }
208 if (likely(!(error || 208 if (likely(!(error ||
@@ -225,7 +225,8 @@ byte_stuff:
225 } else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) { 225 } else if (likely((skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)) {
226 skb_reserve(skb, HW_HDR_LEN); 226 skb_reserve(skb, HW_HDR_LEN);
227 } else { 227 } else {
228 warn("could not allocate new skb"); 228 dev_warn(cs->dev,
229 "could not allocate new skb\n");
229 inputstate |= INS_skip_frame; 230 inputstate |= INS_skip_frame;
230 } 231 }
231 232
@@ -233,7 +234,7 @@ byte_stuff:
233#ifdef CONFIG_GIGASET_DEBUG 234#ifdef CONFIG_GIGASET_DEBUG
234 } else if (unlikely(muststuff(c))) { 235 } else if (unlikely(muststuff(c))) {
235 /* Should not happen. Possible after ZDLE=1<CR><LF>. */ 236 /* Should not happen. Possible after ZDLE=1<CR><LF>. */
236 dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c); 237 gig_dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c);
237#endif 238#endif
238 } 239 }
239 240
@@ -241,8 +242,8 @@ byte_stuff:
241 242
242#ifdef CONFIG_GIGASET_DEBUG 243#ifdef CONFIG_GIGASET_DEBUG
243 if (unlikely(!(inputstate & INS_have_data))) { 244 if (unlikely(!(inputstate & INS_have_data))) {
244 dbg(DEBUG_HDLC, 245 gig_dbg(DEBUG_HDLC, "7e (%d x) ================",
245 "7e (%d x) ================", bcs->emptycount); 246 bcs->emptycount);
246 bcs->emptycount = 0; 247 bcs->emptycount = 0;
247 } 248 }
248#endif 249#endif
@@ -251,7 +252,7 @@ byte_stuff:
251 252
252 if (likely(!(inputstate & INS_skip_frame))) { 253 if (likely(!(inputstate & INS_skip_frame))) {
253 if (unlikely(skb->len == SBUFSIZE)) { 254 if (unlikely(skb->len == SBUFSIZE)) {
254 warn("received packet too long"); 255 dev_warn(cs->dev, "received packet too long\n");
255 dev_kfree_skb_any(skb); 256 dev_kfree_skb_any(skb);
256 skb = NULL; 257 skb = NULL;
257 inputstate |= INS_skip_frame; 258 inputstate |= INS_skip_frame;
@@ -287,7 +288,7 @@ byte_stuff:
287 * numbytes (all bytes processed) on error --FIXME 288 * numbytes (all bytes processed) on error --FIXME
288 */ 289 */
289static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes, 290static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
290 struct inbuf_t *inbuf) 291 struct inbuf_t *inbuf)
291{ 292{
292 struct cardstate *cs = inbuf->cs; 293 struct cardstate *cs = inbuf->cs;
293 struct bc_state *bcs = inbuf->bcs; 294 struct bc_state *bcs = inbuf->bcs;
@@ -307,7 +308,7 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
307 if (likely(!(inputstate & INS_skip_frame))) { 308 if (likely(!(inputstate & INS_skip_frame))) {
308 if (unlikely(skb->len == SBUFSIZE)) { 309 if (unlikely(skb->len == SBUFSIZE)) {
309 //FIXME just pass skb up and allocate a new one 310 //FIXME just pass skb up and allocate a new one
310 warn("received packet too long"); 311 dev_warn(cs->dev, "received packet too long\n");
311 dev_kfree_skb_any(skb); 312 dev_kfree_skb_any(skb);
312 skb = NULL; 313 skb = NULL;
313 inputstate |= INS_skip_frame; 314 inputstate |= INS_skip_frame;
@@ -341,7 +342,7 @@ static inline int iraw_loop(unsigned char c, unsigned char *src, int numbytes,
341 != NULL)) { 342 != NULL)) {
342 skb_reserve(skb, HW_HDR_LEN); 343 skb_reserve(skb, HW_HDR_LEN);
343 } else { 344 } else {
344 warn("could not allocate new skb"); 345 dev_warn(cs->dev, "could not allocate new skb\n");
345 inputstate |= INS_skip_frame; 346 inputstate |= INS_skip_frame;
346 } 347 }
347 } 348 }
@@ -362,13 +363,13 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
362 363
363 head = atomic_read(&inbuf->head); 364 head = atomic_read(&inbuf->head);
364 tail = atomic_read(&inbuf->tail); 365 tail = atomic_read(&inbuf->tail);
365 dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); 366 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
366 367
367 if (head != tail) { 368 if (head != tail) {
368 cs = inbuf->cs; 369 cs = inbuf->cs;
369 src = inbuf->data + head; 370 src = inbuf->data + head;
370 numbytes = (head > tail ? RBUFSIZE : tail) - head; 371 numbytes = (head > tail ? RBUFSIZE : tail) - head;
371 dbg(DEBUG_INTR, "processing %u bytes", numbytes); 372 gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
372 373
373 while (numbytes) { 374 while (numbytes) {
374 if (atomic_read(&cs->mstate) == MS_LOCKED) { 375 if (atomic_read(&cs->mstate) == MS_LOCKED) {
@@ -400,13 +401,14 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
400 401
401 src += procbytes; 402 src += procbytes;
402 numbytes -= procbytes; 403 numbytes -= procbytes;
403 } else { /* DLE-char */ 404 } else { /* DLE char */
404 inbuf->inputstate &= ~INS_DLE_char; 405 inbuf->inputstate &= ~INS_DLE_char;
405 switch (c) { 406 switch (c) {
406 case 'X': /*begin of command*/ 407 case 'X': /*begin of command*/
407#ifdef CONFIG_GIGASET_DEBUG 408#ifdef CONFIG_GIGASET_DEBUG
408 if (inbuf->inputstate & INS_command) 409 if (inbuf->inputstate & INS_command)
409 err("received <DLE> 'X' in command mode"); 410 dev_err(cs->dev,
411 "received <DLE> 'X' in command mode\n");
410#endif 412#endif
411 inbuf->inputstate |= 413 inbuf->inputstate |=
412 INS_command | INS_DLE_command; 414 INS_command | INS_DLE_command;
@@ -414,7 +416,8 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
414 case '.': /*end of command*/ 416 case '.': /*end of command*/
415#ifdef CONFIG_GIGASET_DEBUG 417#ifdef CONFIG_GIGASET_DEBUG
416 if (!(inbuf->inputstate & INS_command)) 418 if (!(inbuf->inputstate & INS_command))
417 err("received <DLE> '.' in hdlc mode"); 419 dev_err(cs->dev,
420 "received <DLE> '.' in hdlc mode\n");
418#endif 421#endif
419 inbuf->inputstate &= cs->dle ? 422 inbuf->inputstate &= cs->dle ?
420 ~(INS_DLE_command|INS_command) 423 ~(INS_DLE_command|INS_command)
@@ -422,7 +425,9 @@ void gigaset_m10x_input(struct inbuf_t *inbuf)
422 break; 425 break;
423 //case DLE_FLAG: /*DLE_FLAG in data stream*/ /* schon oben behandelt! */ 426 //case DLE_FLAG: /*DLE_FLAG in data stream*/ /* schon oben behandelt! */
424 default: 427 default:
425 err("received 0x10 0x%02x!", (int) c); 428 dev_err(cs->dev,
429 "received 0x10 0x%02x!\n",
430 (int) c);
426 /* FIXME: reset driver?? */ 431 /* FIXME: reset driver?? */
427 } 432 }
428 } 433 }
@@ -441,7 +446,7 @@ nextbyte:
441 } 446 }
442 } 447 }
443 448
444 dbg(DEBUG_INTR, "setting head to %u", head); 449 gig_dbg(DEBUG_INTR, "setting head to %u", head);
445 atomic_set(&inbuf->head, head); 450 atomic_set(&inbuf->head, head);
446 } 451 }
447} 452}
@@ -476,14 +481,13 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
476 stuf_cnt++; 481 stuf_cnt++;
477 fcs = crc_ccitt_byte(fcs, *cp++); 482 fcs = crc_ccitt_byte(fcs, *cp++);
478 } 483 }
479 fcs ^= 0xffff; /* complement */ 484 fcs ^= 0xffff; /* complement */
480 485
481 /* size of new buffer: original size + number of stuffing bytes 486 /* size of new buffer: original size + number of stuffing bytes
482 * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes 487 * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes
483 */ 488 */
484 hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + tail + head); 489 hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + tail + head);
485 if (!hdlc_skb) { 490 if (!hdlc_skb) {
486 err("unable to allocate memory for HDLC encoding!");
487 dev_kfree_skb(skb); 491 dev_kfree_skb(skb);
488 return NULL; 492 return NULL;
489 } 493 }
@@ -505,7 +509,7 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int head, int tail)
505 } 509 }
506 510
507 /* Finally add FCS (byte stuffed) and flag sequence */ 511 /* Finally add FCS (byte stuffed) and flag sequence */
508 c = (fcs & 0x00ff); /* least significant byte first */ 512 c = (fcs & 0x00ff); /* least significant byte first */
509 if (muststuff(c)) { 513 if (muststuff(c)) {
510 *(skb_put(hdlc_skb, 1)) = PPP_ESCAPE; 514 *(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
511 c ^= PPP_TRANS; 515 c ^= PPP_TRANS;
@@ -543,7 +547,6 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int head, int tail)
543 /* worst case: every byte must be stuffed */ 547 /* worst case: every byte must be stuffed */
544 iraw_skb = dev_alloc_skb(2*skb->len + tail + head); 548 iraw_skb = dev_alloc_skb(2*skb->len + tail + head);
545 if (!iraw_skb) { 549 if (!iraw_skb) {
546 err("unable to allocate memory for HDLC encoding!");
547 dev_kfree_skb(skb); 550 dev_kfree_skb(skb);
548 return NULL; 551 return NULL;
549 } 552 }
@@ -584,8 +587,11 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
584 skb = HDLC_Encode(skb, HW_HDR_LEN, 0); 587 skb = HDLC_Encode(skb, HW_HDR_LEN, 0);
585 else 588 else
586 skb = iraw_encode(skb, HW_HDR_LEN, 0); 589 skb = iraw_encode(skb, HW_HDR_LEN, 0);
587 if (!skb) 590 if (!skb) {
591 dev_err(bcs->cs->dev,
592 "unable to allocate memory for encoding!\n");
588 return -ENOMEM; 593 return -ENOMEM;
594 }
589 595
590 skb_queue_tail(&bcs->squeue, skb); 596 skb_queue_tail(&bcs->squeue, skb);
591 tasklet_schedule(&bcs->cs->write_tasklet); 597 tasklet_schedule(&bcs->cs->write_tasklet);
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index fb2c13ae7cfd..580831d9dba1 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -81,25 +81,25 @@ static void gigaset_disconnect(struct usb_interface *interface);
81/*==============================================================================*/ 81/*==============================================================================*/
82 82
83struct bas_cardstate { 83struct bas_cardstate {
84 struct usb_device *udev; /* USB device pointer */ 84 struct usb_device *udev; /* USB device pointer */
85 struct usb_interface *interface; /* interface for this device */ 85 struct usb_interface *interface; /* interface for this device */
86 unsigned char minor; /* starting minor number */ 86 unsigned char minor; /* starting minor number */
87 87
88 struct urb *urb_ctrl; /* control pipe default URB */ 88 struct urb *urb_ctrl; /* control pipe default URB */
89 struct usb_ctrlrequest dr_ctrl; 89 struct usb_ctrlrequest dr_ctrl;
90 struct timer_list timer_ctrl; /* control request timeout */ 90 struct timer_list timer_ctrl; /* control request timeout */
91 91
92 struct timer_list timer_atrdy; /* AT command ready timeout */ 92 struct timer_list timer_atrdy; /* AT command ready timeout */
93 struct urb *urb_cmd_out; /* for sending AT commands */ 93 struct urb *urb_cmd_out; /* for sending AT commands */
94 struct usb_ctrlrequest dr_cmd_out; 94 struct usb_ctrlrequest dr_cmd_out;
95 int retry_cmd_out; 95 int retry_cmd_out;
96 96
97 struct urb *urb_cmd_in; /* for receiving AT replies */ 97 struct urb *urb_cmd_in; /* for receiving AT replies */
98 struct usb_ctrlrequest dr_cmd_in; 98 struct usb_ctrlrequest dr_cmd_in;
99 struct timer_list timer_cmd_in; /* receive request timeout */ 99 struct timer_list timer_cmd_in; /* receive request timeout */
100 unsigned char *rcvbuf; /* AT reply receive buffer */ 100 unsigned char *rcvbuf; /* AT reply receive buffer */
101 101
102 struct urb *urb_int_in; /* URB for interrupt pipe */ 102 struct urb *urb_int_in; /* URB for interrupt pipe */
103 unsigned char int_in_buf[3]; 103 unsigned char int_in_buf[3];
104 104
105 spinlock_t lock; /* locks all following */ 105 spinlock_t lock; /* locks all following */
@@ -201,54 +201,55 @@ static inline char *usb_pipetype_str(int pipe)
201 * write content of URB to syslog for debugging 201 * write content of URB to syslog for debugging
202 */ 202 */
203static inline void dump_urb(enum debuglevel level, const char *tag, 203static inline void dump_urb(enum debuglevel level, const char *tag,
204 struct urb *urb) 204 struct urb *urb)
205{ 205{
206#ifdef CONFIG_GIGASET_DEBUG 206#ifdef CONFIG_GIGASET_DEBUG
207 int i; 207 int i;
208 IFNULLRET(tag); 208 IFNULLRET(tag);
209 dbg(level, "%s urb(0x%08lx)->{", tag, (unsigned long) urb); 209 gig_dbg(level, "%s urb(0x%08lx)->{", tag, (unsigned long) urb);
210 if (urb) { 210 if (urb) {
211 dbg(level, 211 gig_dbg(level,
212 " dev=0x%08lx, pipe=%s:EP%d/DV%d:%s, " 212 " dev=0x%08lx, pipe=%s:EP%d/DV%d:%s, "
213 "status=%d, hcpriv=0x%08lx, transfer_flags=0x%x,", 213 "status=%d, hcpriv=0x%08lx, transfer_flags=0x%x,",
214 (unsigned long) urb->dev, 214 (unsigned long) urb->dev,
215 usb_pipetype_str(urb->pipe), 215 usb_pipetype_str(urb->pipe),
216 usb_pipeendpoint(urb->pipe), usb_pipedevice(urb->pipe), 216 usb_pipeendpoint(urb->pipe), usb_pipedevice(urb->pipe),
217 usb_pipein(urb->pipe) ? "in" : "out", 217 usb_pipein(urb->pipe) ? "in" : "out",
218 urb->status, (unsigned long) urb->hcpriv, 218 urb->status, (unsigned long) urb->hcpriv,
219 urb->transfer_flags); 219 urb->transfer_flags);
220 dbg(level, 220 gig_dbg(level,
221 " transfer_buffer=0x%08lx[%d], actual_length=%d, " 221 " transfer_buffer=0x%08lx[%d], actual_length=%d, "
222 "bandwidth=%d, setup_packet=0x%08lx,", 222 "bandwidth=%d, setup_packet=0x%08lx,",
223 (unsigned long) urb->transfer_buffer, 223 (unsigned long) urb->transfer_buffer,
224 urb->transfer_buffer_length, urb->actual_length, 224 urb->transfer_buffer_length, urb->actual_length,
225 urb->bandwidth, (unsigned long) urb->setup_packet); 225 urb->bandwidth, (unsigned long) urb->setup_packet);
226 dbg(level, 226 gig_dbg(level,
227 " start_frame=%d, number_of_packets=%d, interval=%d, " 227 " start_frame=%d, number_of_packets=%d, interval=%d, "
228 "error_count=%d,", 228 "error_count=%d,",
229 urb->start_frame, urb->number_of_packets, urb->interval, 229 urb->start_frame, urb->number_of_packets, urb->interval,
230 urb->error_count); 230 urb->error_count);
231 dbg(level, 231 gig_dbg(level,
232 " context=0x%08lx, complete=0x%08lx, iso_frame_desc[]={", 232 " context=0x%08lx, complete=0x%08lx, "
233 (unsigned long) urb->context, 233 "iso_frame_desc[]={",
234 (unsigned long) urb->complete); 234 (unsigned long) urb->context,
235 (unsigned long) urb->complete);
235 for (i = 0; i < urb->number_of_packets; i++) { 236 for (i = 0; i < urb->number_of_packets; i++) {
236 struct usb_iso_packet_descriptor *pifd 237 struct usb_iso_packet_descriptor *pifd
237 = &urb->iso_frame_desc[i]; 238 = &urb->iso_frame_desc[i];
238 dbg(level, 239 gig_dbg(level,
239 " {offset=%u, length=%u, actual_length=%u, " 240 " {offset=%u, length=%u, actual_length=%u, "
240 "status=%u}", 241 "status=%u}",
241 pifd->offset, pifd->length, pifd->actual_length, 242 pifd->offset, pifd->length, pifd->actual_length,
242 pifd->status); 243 pifd->status);
243 } 244 }
244 } 245 }
245 dbg(level, "}}"); 246 gig_dbg(level, "}}");
246#endif 247#endif
247} 248}
248 249
249/* read/set modem control bits etc. (m10x only) */ 250/* read/set modem control bits etc. (m10x only) */
250static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, 251static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
251 unsigned new_state) 252 unsigned new_state)
252{ 253{
253 return -EINVAL; 254 return -EINVAL;
254} 255}
@@ -274,8 +275,8 @@ static inline void error_hangup(struct bc_state *bcs)
274{ 275{
275 struct cardstate *cs = bcs->cs; 276 struct cardstate *cs = bcs->cs;
276 277
277 dbg(DEBUG_ANY, 278 gig_dbg(DEBUG_ANY, "%s: scheduling HUP for channel %d",
278 "%s: scheduling HUP for channel %d", __func__, bcs->channel); 279 __func__, bcs->channel);
279 280
280 if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) { 281 if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) {
281 //FIXME what should we do? 282 //FIXME what should we do?
@@ -295,21 +296,20 @@ static inline void error_hangup(struct bc_state *bcs)
295static inline void error_reset(struct cardstate *cs) 296static inline void error_reset(struct cardstate *cs)
296{ 297{
297 //FIXME try to recover without bothering the user 298 //FIXME try to recover without bothering the user
298 err("unrecoverable error - please disconnect the Gigaset base to reset"); 299 dev_err(cs->dev,
300 "unrecoverable error - please disconnect Gigaset base to reset\n");
299} 301}
300 302
301/* check_pending 303/* check_pending
302 * check for completion of pending control request 304 * check for completion of pending control request
303 * parameter: 305 * parameter:
304 * urb USB request block of completed request 306 * ucs hardware specific controller state structure
305 * urb->context = hardware specific controller state structure
306 */ 307 */
307static void check_pending(struct bas_cardstate *ucs) 308static void check_pending(struct bas_cardstate *ucs)
308{ 309{
309 unsigned long flags; 310 unsigned long flags;
310 311
311 IFNULLRET(ucs); 312 IFNULLRET(ucs);
312 IFNULLRET(cardstate);
313 313
314 spin_lock_irqsave(&ucs->lock, flags); 314 spin_lock_irqsave(&ucs->lock, flags);
315 switch (ucs->pending) { 315 switch (ucs->pending) {
@@ -330,8 +330,6 @@ static void check_pending(struct bas_cardstate *ucs)
330 case HD_CLOSE_ATCHANNEL: 330 case HD_CLOSE_ATCHANNEL:
331 if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) 331 if (!(atomic_read(&ucs->basstate) & BS_ATOPEN))
332 ucs->pending = 0; 332 ucs->pending = 0;
333 //wake_up_interruptible(cs->initwait);
334 //FIXME need own wait queue?
335 break; 333 break;
336 case HD_CLOSE_B1CHANNEL: 334 case HD_CLOSE_B1CHANNEL:
337 if (!(atomic_read(&ucs->basstate) & BS_B1OPEN)) 335 if (!(atomic_read(&ucs->basstate) & BS_B1OPEN))
@@ -348,7 +346,9 @@ static void check_pending(struct bas_cardstate *ucs)
348 * are handled separately and should never end up here 346 * are handled separately and should never end up here
349 */ 347 */
350 default: 348 default:
351 warn("unknown pending request 0x%02x cleared", ucs->pending); 349 dev_warn(&ucs->interface->dev,
350 "unknown pending request 0x%02x cleared\n",
351 ucs->pending);
352 ucs->pending = 0; 352 ucs->pending = 0;
353 } 353 }
354 354
@@ -374,19 +374,19 @@ static void cmd_in_timeout(unsigned long data)
374 IFNULLRET(ucs); 374 IFNULLRET(ucs);
375 375
376 spin_lock_irqsave(&cs->lock, flags); 376 spin_lock_irqsave(&cs->lock, flags);
377 if (!atomic_read(&cs->connected)) { 377 if (unlikely(!atomic_read(&cs->connected))) {
378 dbg(DEBUG_USBREQ, "%s: disconnected", __func__); 378 gig_dbg(DEBUG_USBREQ, "%s: disconnected", __func__);
379 spin_unlock_irqrestore(&cs->lock, flags); 379 spin_unlock_irqrestore(&cs->lock, flags);
380 return; 380 return;
381 } 381 }
382 if (!ucs->rcvbuf_size) { 382 if (!ucs->rcvbuf_size) {
383 dbg(DEBUG_USBREQ, "%s: no receive in progress", __func__); 383 gig_dbg(DEBUG_USBREQ, "%s: no receive in progress", __func__);
384 spin_unlock_irqrestore(&cs->lock, flags); 384 spin_unlock_irqrestore(&cs->lock, flags);
385 return; 385 return;
386 } 386 }
387 spin_unlock_irqrestore(&cs->lock, flags); 387 spin_unlock_irqrestore(&cs->lock, flags);
388 388
389 err("timeout reading AT response"); 389 dev_err(cs->dev, "timeout reading AT response\n");
390 error_reset(cs); //FIXME retry? 390 error_reset(cs); //FIXME retry?
391} 391}
392 392
@@ -414,10 +414,12 @@ static int atread_submit(struct cardstate *cs, int timeout)
414 IFNULLRETVAL(ucs, -EINVAL); 414 IFNULLRETVAL(ucs, -EINVAL);
415 IFNULLRETVAL(ucs->urb_cmd_in, -EINVAL); 415 IFNULLRETVAL(ucs->urb_cmd_in, -EINVAL);
416 416
417 dbg(DEBUG_USBREQ, "-------> HD_READ_ATMESSAGE (%d)", ucs->rcvbuf_size); 417 gig_dbg(DEBUG_USBREQ, "-------> HD_READ_ATMESSAGE (%d)",
418 ucs->rcvbuf_size);
418 419
419 if (ucs->urb_cmd_in->status == -EINPROGRESS) { 420 if (ucs->urb_cmd_in->status == -EINPROGRESS) {
420 err("could not submit HD_READ_ATMESSAGE: URB busy"); 421 dev_err(cs->dev,
422 "could not submit HD_READ_ATMESSAGE: URB busy\n");
421 return -EBUSY; 423 return -EBUSY;
422 } 424 }
423 425
@@ -427,19 +429,19 @@ static int atread_submit(struct cardstate *cs, int timeout)
427 ucs->dr_cmd_in.wIndex = 0; 429 ucs->dr_cmd_in.wIndex = 0;
428 ucs->dr_cmd_in.wLength = cpu_to_le16(ucs->rcvbuf_size); 430 ucs->dr_cmd_in.wLength = cpu_to_le16(ucs->rcvbuf_size);
429 usb_fill_control_urb(ucs->urb_cmd_in, ucs->udev, 431 usb_fill_control_urb(ucs->urb_cmd_in, ucs->udev,
430 usb_rcvctrlpipe(ucs->udev, 0), 432 usb_rcvctrlpipe(ucs->udev, 0),
431 (unsigned char*) & ucs->dr_cmd_in, 433 (unsigned char*) & ucs->dr_cmd_in,
432 ucs->rcvbuf, ucs->rcvbuf_size, 434 ucs->rcvbuf, ucs->rcvbuf_size,
433 read_ctrl_callback, cs->inbuf); 435 read_ctrl_callback, cs->inbuf);
434 436
435 if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) { 437 if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) {
436 err("could not submit HD_READ_ATMESSAGE: %s", 438 dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n",
437 get_usb_statmsg(ret)); 439 get_usb_statmsg(ret));
438 return ret; 440 return ret;
439 } 441 }
440 442
441 if (timeout > 0) { 443 if (timeout > 0) {
442 dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout); 444 gig_dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout);
443 ucs->timer_cmd_in.expires = jiffies + timeout * HZ / 10; 445 ucs->timer_cmd_in.expires = jiffies + timeout * HZ / 10;
444 ucs->timer_cmd_in.data = (unsigned long) cs; 446 ucs->timer_cmd_in.data = (unsigned long) cs;
445 ucs->timer_cmd_in.function = cmd_in_timeout; 447 ucs->timer_cmd_in.function = cmd_in_timeout;
@@ -503,11 +505,12 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
503 case -ECONNRESET: /* canceled (async) */ 505 case -ECONNRESET: /* canceled (async) */
504 case -EINPROGRESS: /* pending */ 506 case -EINPROGRESS: /* pending */
505 /* ignore silently */ 507 /* ignore silently */
506 dbg(DEBUG_USBREQ, 508 gig_dbg(DEBUG_USBREQ, "%s: %s",
507 "%s: %s", __func__, get_usb_statmsg(urb->status)); 509 __func__, get_usb_statmsg(urb->status));
508 return; 510 return;
509 default: /* severe trouble */ 511 default: /* severe trouble */
510 warn("interrupt read: %s", get_usb_statmsg(urb->status)); 512 dev_warn(cs->dev, "interrupt read: %s\n",
513 get_usb_statmsg(urb->status));
511 //FIXME corrective action? resubmission always ok? 514 //FIXME corrective action? resubmission always ok?
512 goto resubmit; 515 goto resubmit;
513 } 516 }
@@ -515,10 +518,9 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
515 l = (unsigned) ucs->int_in_buf[1] + 518 l = (unsigned) ucs->int_in_buf[1] +
516 (((unsigned) ucs->int_in_buf[2]) << 8); 519 (((unsigned) ucs->int_in_buf[2]) << 8);
517 520
518 dbg(DEBUG_USBREQ, 521 gig_dbg(DEBUG_USBREQ, "<-------%d: 0x%02x (%u [0x%02x 0x%02x])",
519 "<-------%d: 0x%02x (%u [0x%02x 0x%02x])", urb->actual_length, 522 urb->actual_length, (int)ucs->int_in_buf[0], l,
520 (int)ucs->int_in_buf[0], l, 523 (int)ucs->int_in_buf[1], (int)ucs->int_in_buf[2]);
521 (int)ucs->int_in_buf[1], (int)ucs->int_in_buf[2]);
522 524
523 channel = 0; 525 channel = 0;
524 526
@@ -564,28 +566,30 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
564 case HD_B1_FLOW_CONTROL: 566 case HD_B1_FLOW_CONTROL:
565 bcs = cs->bcs + channel; 567 bcs = cs->bcs + channel;
566 atomic_add((l - BAS_NORMFRAME) * BAS_CORRFRAMES, 568 atomic_add((l - BAS_NORMFRAME) * BAS_CORRFRAMES,
567 &bcs->hw.bas->corrbytes); 569 &bcs->hw.bas->corrbytes);
568 dbg(DEBUG_ISO, 570 gig_dbg(DEBUG_ISO,
569 "Flow control (channel %d, sub %d): 0x%02x => %d", 571 "Flow control (channel %d, sub %d): 0x%02x => %d",
570 channel, bcs->hw.bas->numsub, l, 572 channel, bcs->hw.bas->numsub, l,
571 atomic_read(&bcs->hw.bas->corrbytes)); 573 atomic_read(&bcs->hw.bas->corrbytes));
572 break; 574 break;
573 575
574 case HD_RECEIVEATDATA_ACK: /* AT response ready to be received */ 576 case HD_RECEIVEATDATA_ACK: /* AT response ready to be received */
575 if (!l) { 577 if (!l) {
576 warn("HD_RECEIVEATDATA_ACK with length 0 ignored"); 578 dev_warn(cs->dev,
579 "HD_RECEIVEATDATA_ACK with length 0 ignored\n");
577 break; 580 break;
578 } 581 }
579 spin_lock_irqsave(&cs->lock, flags); 582 spin_lock_irqsave(&cs->lock, flags);
580 if (ucs->rcvbuf_size) { 583 if (ucs->rcvbuf_size) {
581 spin_unlock_irqrestore(&cs->lock, flags); 584 spin_unlock_irqrestore(&cs->lock, flags);
582 err("receive AT data overrun, %d bytes lost", l); 585 dev_err(cs->dev,
586 "receive AT data overrun, %d bytes lost\n", l);
583 error_reset(cs); //FIXME reschedule 587 error_reset(cs); //FIXME reschedule
584 break; 588 break;
585 } 589 }
586 if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) { 590 if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) {
587 spin_unlock_irqrestore(&cs->lock, flags); 591 spin_unlock_irqrestore(&cs->lock, flags);
588 err("%s: out of memory, %d bytes lost", __func__, l); 592 dev_err(cs->dev, "out of memory, %d bytes lost\n", l);
589 error_reset(cs); //FIXME reschedule 593 error_reset(cs); //FIXME reschedule
590 break; 594 break;
591 } 595 }
@@ -601,16 +605,17 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
601 break; 605 break;
602 606
603 case HD_RESET_INTERRUPT_PIPE_ACK: 607 case HD_RESET_INTERRUPT_PIPE_ACK:
604 dbg(DEBUG_USBREQ, "HD_RESET_INTERRUPT_PIPE_ACK"); 608 gig_dbg(DEBUG_USBREQ, "HD_RESET_INTERRUPT_PIPE_ACK");
605 break; 609 break;
606 610
607 case HD_SUSPEND_END: 611 case HD_SUSPEND_END:
608 dbg(DEBUG_USBREQ, "HD_SUSPEND_END"); 612 gig_dbg(DEBUG_USBREQ, "HD_SUSPEND_END");
609 break; 613 break;
610 614
611 default: 615 default:
612 warn("unknown Gigaset signal 0x%02x (%u) ignored", 616 dev_warn(cs->dev,
613 (int) ucs->int_in_buf[0], l); 617 "unknown Gigaset signal 0x%02x (%u) ignored\n",
618 (int) ucs->int_in_buf[0], l);
614 } 619 }
615 620
616 check_pending(ucs); 621 check_pending(ucs);
@@ -618,8 +623,8 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs)
618resubmit: 623resubmit:
619 status = usb_submit_urb(urb, SLAB_ATOMIC); 624 status = usb_submit_urb(urb, SLAB_ATOMIC);
620 if (unlikely(status)) { 625 if (unlikely(status)) {
621 err("could not resubmit interrupt URB: %s", 626 dev_err(cs->dev, "could not resubmit interrupt URB: %s\n",
622 get_usb_statmsg(status)); 627 get_usb_statmsg(status));
623 error_reset(cs); 628 error_reset(cs);
624 } 629 }
625} 630}
@@ -649,14 +654,14 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
649 IFNULLRET(ucs); 654 IFNULLRET(ucs);
650 655
651 spin_lock_irqsave(&cs->lock, flags); 656 spin_lock_irqsave(&cs->lock, flags);
652 if (!atomic_read(&cs->connected)) { 657 if (unlikely(!atomic_read(&cs->connected))) {
653 warn("%s: disconnected", __func__); 658 warn("%s: disconnected", __func__);
654 spin_unlock_irqrestore(&cs->lock, flags); 659 spin_unlock_irqrestore(&cs->lock, flags);
655 return; 660 return;
656 } 661 }
657 662
658 if (!ucs->rcvbuf_size) { 663 if (!ucs->rcvbuf_size) {
659 warn("%s: no receive in progress", __func__); 664 dev_warn(cs->dev, "%s: no receive in progress\n", __func__);
660 spin_unlock_irqrestore(&cs->lock, flags); 665 spin_unlock_irqrestore(&cs->lock, flags);
661 return; 666 return;
662 } 667 }
@@ -667,12 +672,14 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
667 case 0: /* normal completion */ 672 case 0: /* normal completion */
668 numbytes = urb->actual_length; 673 numbytes = urb->actual_length;
669 if (unlikely(numbytes == 0)) { 674 if (unlikely(numbytes == 0)) {
670 warn("control read: empty block received"); 675 dev_warn(cs->dev,
676 "control read: empty block received\n");
671 goto retry; 677 goto retry;
672 } 678 }
673 if (unlikely(numbytes != ucs->rcvbuf_size)) { 679 if (unlikely(numbytes != ucs->rcvbuf_size)) {
674 warn("control read: received %d chars, expected %d", 680 dev_warn(cs->dev,
675 numbytes, ucs->rcvbuf_size); 681 "control read: received %d chars, expected %d\n",
682 numbytes, ucs->rcvbuf_size);
676 if (numbytes > ucs->rcvbuf_size) 683 if (numbytes > ucs->rcvbuf_size)
677 numbytes = ucs->rcvbuf_size; 684 numbytes = ucs->rcvbuf_size;
678 } 685 }
@@ -692,23 +699,26 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
692 case -ECONNRESET: /* canceled (async) */ 699 case -ECONNRESET: /* canceled (async) */
693 case -EINPROGRESS: /* pending */ 700 case -EINPROGRESS: /* pending */
694 /* no action necessary */ 701 /* no action necessary */
695 dbg(DEBUG_USBREQ, 702 gig_dbg(DEBUG_USBREQ, "%s: %s",
696 "%s: %s", __func__, get_usb_statmsg(urb->status)); 703 __func__, get_usb_statmsg(urb->status));
697 break; 704 break;
698 705
699 default: /* severe trouble */ 706 default: /* severe trouble */
700 warn("control read: %s", get_usb_statmsg(urb->status)); 707 dev_warn(cs->dev, "control read: %s\n",
708 get_usb_statmsg(urb->status));
701 retry: 709 retry:
702 if (ucs->retry_cmd_in++ < BAS_RETRY) { 710 if (ucs->retry_cmd_in++ < BAS_RETRY) {
703 notice("control read: retry %d", ucs->retry_cmd_in); 711 dev_notice(cs->dev, "control read: retry %d\n",
712 ucs->retry_cmd_in);
704 if (atread_submit(cs, BAS_TIMEOUT) >= 0) { 713 if (atread_submit(cs, BAS_TIMEOUT) >= 0) {
705 /* resubmitted - bypass regular exit block */ 714 /* resubmitted - bypass regular exit block */
706 spin_unlock_irqrestore(&cs->lock, flags); 715 spin_unlock_irqrestore(&cs->lock, flags);
707 return; 716 return;
708 } 717 }
709 } else { 718 } else {
710 err("control read: giving up after %d tries", 719 dev_err(cs->dev,
711 ucs->retry_cmd_in); 720 "control read: giving up after %d tries\n",
721 ucs->retry_cmd_in);
712 } 722 }
713 error_reset(cs); 723 error_reset(cs);
714 } 724 }
@@ -718,7 +728,7 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs)
718 ucs->rcvbuf_size = 0; 728 ucs->rcvbuf_size = 0;
719 spin_unlock_irqrestore(&cs->lock, flags); 729 spin_unlock_irqrestore(&cs->lock, flags);
720 if (have_data) { 730 if (have_data) {
721 dbg(DEBUG_INTR, "%s-->BH", __func__); 731 gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
722 gigaset_schedule_event(cs); 732 gigaset_schedule_event(cs);
723 } 733 }
724} 734}
@@ -743,9 +753,9 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs)
743 753
744 /* status codes not worth bothering the tasklet with */ 754 /* status codes not worth bothering the tasklet with */
745 if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET || 755 if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET ||
746 urb->status == -EINPROGRESS)) { 756 urb->status == -EINPROGRESS)) {
747 dbg(DEBUG_ISO, 757 gig_dbg(DEBUG_ISO, "%s: %s",
748 "%s: %s", __func__, get_usb_statmsg(urb->status)); 758 __func__, get_usb_statmsg(urb->status));
749 return; 759 return;
750 } 760 }
751 761
@@ -771,15 +781,17 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs)
771 urb->iso_frame_desc[i].actual_length = 0; 781 urb->iso_frame_desc[i].actual_length = 0;
772 } 782 }
773 if (likely(atomic_read(&ubc->running))) { 783 if (likely(atomic_read(&ubc->running))) {
774 urb->dev = bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */ 784 /* urb->dev is clobbered by USB subsystem */
785 urb->dev = bcs->cs->hw.bas->udev;
775 urb->transfer_flags = URB_ISO_ASAP; 786 urb->transfer_flags = URB_ISO_ASAP;
776 urb->number_of_packets = BAS_NUMFRAMES; 787 urb->number_of_packets = BAS_NUMFRAMES;
777 dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit", 788 gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit",
778 __func__); 789 __func__);
779 rc = usb_submit_urb(urb, SLAB_ATOMIC); 790 rc = usb_submit_urb(urb, SLAB_ATOMIC);
780 if (unlikely(rc != 0)) { 791 if (unlikely(rc != 0)) {
781 err("could not resubmit isochronous read URB: %s", 792 dev_err(bcs->cs->dev,
782 get_usb_statmsg(rc)); 793 "could not resubmit isochronous read "
794 "URB: %s\n", get_usb_statmsg(rc));
783 dump_urb(DEBUG_ISO, "isoc read", urb); 795 dump_urb(DEBUG_ISO, "isoc read", urb);
784 error_hangup(bcs); 796 error_hangup(bcs);
785 } 797 }
@@ -807,9 +819,9 @@ static void write_iso_callback(struct urb *urb, struct pt_regs *regs)
807 819
808 /* status codes not worth bothering the tasklet with */ 820 /* status codes not worth bothering the tasklet with */
809 if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET || 821 if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET ||
810 urb->status == -EINPROGRESS)) { 822 urb->status == -EINPROGRESS)) {
811 dbg(DEBUG_ISO, 823 gig_dbg(DEBUG_ISO, "%s: %s",
812 "%s: %s", __func__, get_usb_statmsg(urb->status)); 824 __func__, get_usb_statmsg(urb->status));
813 return; 825 return;
814 } 826 }
815 827
@@ -854,7 +866,7 @@ static int starturbs(struct bc_state *bcs)
854 for (k = 0; k < BAS_INURBS; k++) { 866 for (k = 0; k < BAS_INURBS; k++) {
855 urb = ubc->isoinurbs[k]; 867 urb = ubc->isoinurbs[k];
856 if (!urb) { 868 if (!urb) {
857 err("isoinurbs[%d]==NULL", k); 869 dev_err(bcs->cs->dev, "isoinurbs[%d]==NULL\n", k);
858 rc = -EFAULT; 870 rc = -EFAULT;
859 goto error; 871 goto error;
860 } 872 }
@@ -877,8 +889,9 @@ static int starturbs(struct bc_state *bcs)
877 889
878 dump_urb(DEBUG_ISO, "Initial isoc read", urb); 890 dump_urb(DEBUG_ISO, "Initial isoc read", urb);
879 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) { 891 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
880 err("could not submit isochronous read URB %d: %s", 892 dev_err(bcs->cs->dev,
881 k, get_usb_statmsg(rc)); 893 "could not submit isochronous read URB %d: %s\n",
894 k, get_usb_statmsg(rc));
882 goto error; 895 goto error;
883 } 896 }
884 } 897 }
@@ -890,7 +903,7 @@ static int starturbs(struct bc_state *bcs)
890 for (k = 0; k < BAS_OUTURBS; ++k) { 903 for (k = 0; k < BAS_OUTURBS; ++k) {
891 urb = ubc->isoouturbs[k].urb; 904 urb = ubc->isoouturbs[k].urb;
892 if (!urb) { 905 if (!urb) {
893 err("isoouturbs[%d].urb==NULL", k); 906 dev_err(bcs->cs->dev, "isoouturbs[%d].urb==NULL\n", k);
894 rc = -EFAULT; 907 rc = -EFAULT;
895 goto error; 908 goto error;
896 } 909 }
@@ -917,8 +930,9 @@ static int starturbs(struct bc_state *bcs)
917 dump_urb(DEBUG_ISO, "Initial isoc write", urb); 930 dump_urb(DEBUG_ISO, "Initial isoc write", urb);
918 rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC); 931 rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC);
919 if (rc != 0) { 932 if (rc != 0) {
920 err("could not submit isochronous write URB %d: %s", 933 dev_err(bcs->cs->dev,
921 k, get_usb_statmsg(rc)); 934 "could not submit isochronous write URB %d: %s\n",
935 k, get_usb_statmsg(rc));
922 goto error; 936 goto error;
923 } 937 }
924 } 938 }
@@ -947,14 +961,16 @@ static void stopurbs(struct bas_bc_state *ubc)
947 961
948 for (k = 0; k < BAS_INURBS; ++k) { 962 for (k = 0; k < BAS_INURBS; ++k) {
949 rc = usb_unlink_urb(ubc->isoinurbs[k]); 963 rc = usb_unlink_urb(ubc->isoinurbs[k]);
950 dbg(DEBUG_ISO, "%s: isoc input URB %d unlinked, result = %d", 964 gig_dbg(DEBUG_ISO,
951 __func__, k, rc); 965 "%s: isoc input URB %d unlinked, result = %d",
966 __func__, k, rc);
952 } 967 }
953 968
954 for (k = 0; k < BAS_OUTURBS; ++k) { 969 for (k = 0; k < BAS_OUTURBS; ++k) {
955 rc = usb_unlink_urb(ubc->isoouturbs[k].urb); 970 rc = usb_unlink_urb(ubc->isoouturbs[k].urb);
956 dbg(DEBUG_ISO, "%s: isoc output URB %d unlinked, result = %d", 971 gig_dbg(DEBUG_ISO,
957 __func__, k, rc); 972 "%s: isoc output URB %d unlinked, result = %d",
973 __func__, k, rc);
958 } 974 }
959} 975}
960 976
@@ -984,7 +1000,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
984 ubc = ucx->bcs->hw.bas; 1000 ubc = ucx->bcs->hw.bas;
985 IFNULLRETVAL(ubc, -EFAULT); 1001 IFNULLRETVAL(ubc, -EFAULT);
986 1002
987 urb->dev = ucx->bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */ 1003 /* urb->dev is clobbered by USB subsystem */
1004 urb->dev = ucx->bcs->cs->hw.bas->udev;
988 urb->transfer_flags = URB_ISO_ASAP; 1005 urb->transfer_flags = URB_ISO_ASAP;
989 urb->transfer_buffer = ubc->isooutbuf->data; 1006 urb->transfer_buffer = ubc->isooutbuf->data;
990 urb->transfer_buffer_length = sizeof(ubc->isooutbuf->data); 1007 urb->transfer_buffer_length = sizeof(ubc->isooutbuf->data);
@@ -995,7 +1012,8 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
995 /* compute frame length according to flow control */ 1012 /* compute frame length according to flow control */
996 ifd->length = BAS_NORMFRAME; 1013 ifd->length = BAS_NORMFRAME;
997 if ((corrbytes = atomic_read(&ubc->corrbytes)) != 0) { 1014 if ((corrbytes = atomic_read(&ubc->corrbytes)) != 0) {
998 dbg(DEBUG_ISO, "%s: corrbytes=%d", __func__, corrbytes); 1015 gig_dbg(DEBUG_ISO, "%s: corrbytes=%d",
1016 __func__, corrbytes);
999 if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME) 1017 if (corrbytes > BAS_HIGHFRAME - BAS_NORMFRAME)
1000 corrbytes = BAS_HIGHFRAME - BAS_NORMFRAME; 1018 corrbytes = BAS_HIGHFRAME - BAS_NORMFRAME;
1001 else if (corrbytes < BAS_LOWFRAME - BAS_NORMFRAME) 1019 else if (corrbytes < BAS_LOWFRAME - BAS_NORMFRAME)
@@ -1003,19 +1021,21 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
1003 ifd->length += corrbytes; 1021 ifd->length += corrbytes;
1004 atomic_add(-corrbytes, &ubc->corrbytes); 1022 atomic_add(-corrbytes, &ubc->corrbytes);
1005 } 1023 }
1006 //dbg(DEBUG_ISO, "%s: frame %d length=%d", __func__, nframe, ifd->length);
1007 1024
1008 /* retrieve block of data to send */ 1025 /* retrieve block of data to send */
1009 ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf, 1026 ifd->offset = gigaset_isowbuf_getbytes(ubc->isooutbuf,
1010 ifd->length); 1027 ifd->length);
1011 if (ifd->offset < 0) { 1028 if (ifd->offset < 0) {
1012 if (ifd->offset == -EBUSY) { 1029 if (ifd->offset == -EBUSY) {
1013 dbg(DEBUG_ISO, "%s: buffer busy at frame %d", 1030 gig_dbg(DEBUG_ISO,
1014 __func__, nframe); 1031 "%s: buffer busy at frame %d",
1015 /* tasklet will be restarted from gigaset_send_skb() */ 1032 __func__, nframe);
1033 /* tasklet will be restarted from
1034 gigaset_send_skb() */
1016 } else { 1035 } else {
1017 err("%s: buffer error %d at frame %d", 1036 dev_err(ucx->bcs->cs->dev,
1018 __func__, ifd->offset, nframe); 1037 "%s: buffer error %d at frame %d\n",
1038 __func__, ifd->offset, nframe);
1019 return ifd->offset; 1039 return ifd->offset;
1020 } 1040 }
1021 break; 1041 break;
@@ -1026,8 +1046,9 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
1026 } 1046 }
1027 if ((urb->number_of_packets = nframe) > 0) { 1047 if ((urb->number_of_packets = nframe) > 0) {
1028 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) { 1048 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
1029 err("could not submit isochronous write URB: %s", 1049 dev_err(ucx->bcs->cs->dev,
1030 get_usb_statmsg(rc)); 1050 "could not submit isochronous write URB: %s\n",
1051 get_usb_statmsg(rc));
1031 dump_urb(DEBUG_ISO, "isoc write", urb); 1052 dump_urb(DEBUG_ISO, "isoc write", urb);
1032 return rc; 1053 return rc;
1033 } 1054 }
@@ -1071,7 +1092,7 @@ static void write_iso_tasklet(unsigned long data)
1071 } 1092 }
1072 1093
1073 if (unlikely(!(atomic_read(&ubc->running)))) { 1094 if (unlikely(!(atomic_read(&ubc->running)))) {
1074 dbg(DEBUG_ISO, "%s: not running", __func__); 1095 gig_dbg(DEBUG_ISO, "%s: not running", __func__);
1075 return; 1096 return;
1076 } 1097 }
1077 1098
@@ -1083,7 +1104,7 @@ static void write_iso_tasklet(unsigned long data)
1083 ubc->isooutovfl = NULL; 1104 ubc->isooutovfl = NULL;
1084 spin_unlock_irqrestore(&ubc->isooutlock, flags); 1105 spin_unlock_irqrestore(&ubc->isooutlock, flags);
1085 if (ovfl) { 1106 if (ovfl) {
1086 err("isochronous write buffer underrun - buy a faster machine :-)"); 1107 dev_err(cs->dev, "isochronous write buffer underrun\n");
1087 error_hangup(bcs); 1108 error_hangup(bcs);
1088 break; 1109 break;
1089 } 1110 }
@@ -1106,7 +1127,8 @@ static void write_iso_tasklet(unsigned long data)
1106 spin_unlock_irqrestore(&ubc->isooutlock, flags); 1127 spin_unlock_irqrestore(&ubc->isooutlock, flags);
1107 if (next) { 1128 if (next) {
1108 /* couldn't put it back */ 1129 /* couldn't put it back */
1109 err("losing isochronous write URB"); 1130 dev_err(cs->dev,
1131 "losing isochronous write URB\n");
1110 error_hangup(bcs); 1132 error_hangup(bcs);
1111 } 1133 }
1112 } 1134 }
@@ -1123,19 +1145,21 @@ static void write_iso_tasklet(unsigned long data)
1123 * successfully sent 1145 * successfully sent
1124 * - all following frames are not sent at all 1146 * - all following frames are not sent at all
1125 */ 1147 */
1126 dbg(DEBUG_ISO, "%s: URB partially completed", __func__); 1148 gig_dbg(DEBUG_ISO, "%s: URB partially completed",
1149 __func__);
1127 offset = done->limit; /* just in case */ 1150 offset = done->limit; /* just in case */
1128 for (i = 0; i < BAS_NUMFRAMES; i++) { 1151 for (i = 0; i < BAS_NUMFRAMES; i++) {
1129 ifd = &urb->iso_frame_desc[i]; 1152 ifd = &urb->iso_frame_desc[i];
1130 if (ifd->status || 1153 if (ifd->status ||
1131 ifd->actual_length != ifd->length) { 1154 ifd->actual_length != ifd->length) {
1132 warn("isochronous write: frame %d: %s, " 1155 dev_warn(cs->dev,
1133 "only %d of %d bytes sent", 1156 "isochronous write: frame %d: %s, "
1157 "only %d of %d bytes sent\n",
1134 i, get_usb_statmsg(ifd->status), 1158 i, get_usb_statmsg(ifd->status),
1135 ifd->actual_length, ifd->length); 1159 ifd->actual_length, ifd->length);
1136 offset = (ifd->offset + 1160 offset = (ifd->offset +
1137 ifd->actual_length) 1161 ifd->actual_length)
1138 % BAS_OUTBUFSIZE; 1162 % BAS_OUTBUFSIZE;
1139 break; 1163 break;
1140 } 1164 }
1141 } 1165 }
@@ -1145,25 +1169,26 @@ static void write_iso_tasklet(unsigned long data)
1145 ifd = &urb->iso_frame_desc[i]; 1169 ifd = &urb->iso_frame_desc[i];
1146 if (ifd->status != -EINPROGRESS 1170 if (ifd->status != -EINPROGRESS
1147 || ifd->actual_length != 0) { 1171 || ifd->actual_length != 0) {
1148 warn("isochronous write: frame %d: %s, " 1172 dev_warn(cs->dev,
1149 "%d of %d bytes sent", 1173 "isochronous write: frame %d: %s, "
1174 "%d of %d bytes sent\n",
1150 i, get_usb_statmsg(ifd->status), 1175 i, get_usb_statmsg(ifd->status),
1151 ifd->actual_length, ifd->length); 1176 ifd->actual_length, ifd->length);
1152 offset = (ifd->offset + 1177 offset = (ifd->offset +
1153 ifd->actual_length) 1178 ifd->actual_length)
1154 % BAS_OUTBUFSIZE; 1179 % BAS_OUTBUFSIZE;
1155 break; 1180 break;
1156 } 1181 }
1157 } 1182 }
1158#endif 1183#endif
1159 break; 1184 break;
1160 case -EPIPE: //FIXME is this the code for "underrun"? 1185 case -EPIPE: //FIXME is this the code for "underrun"?
1161 err("isochronous write stalled"); 1186 dev_err(cs->dev, "isochronous write stalled\n");
1162 error_hangup(bcs); 1187 error_hangup(bcs);
1163 break; 1188 break;
1164 default: /* severe trouble */ 1189 default: /* severe trouble */
1165 warn("isochronous write: %s", 1190 dev_warn(cs->dev, "isochronous write: %s\n",
1166 get_usb_statmsg(urb->status)); 1191 get_usb_statmsg(urb->status));
1167 } 1192 }
1168 1193
1169 /* mark the write buffer area covered by this URB as free */ 1194 /* mark the write buffer area covered by this URB as free */
@@ -1191,8 +1216,8 @@ static void write_iso_tasklet(unsigned long data)
1191 if (gigaset_isoc_buildframe(bcs, skb->data, len) == -EAGAIN) { 1216 if (gigaset_isoc_buildframe(bcs, skb->data, len) == -EAGAIN) {
1192 /* insufficient buffer space, push back onto queue */ 1217 /* insufficient buffer space, push back onto queue */
1193 skb_queue_head(&bcs->squeue, skb); 1218 skb_queue_head(&bcs->squeue, skb);
1194 dbg(DEBUG_ISO, "%s: skb requeued, qlen=%d", 1219 gig_dbg(DEBUG_ISO, "%s: skb requeued, qlen=%d",
1195 __func__, skb_queue_len(&bcs->squeue)); 1220 __func__, skb_queue_len(&bcs->squeue));
1196 break; 1221 break;
1197 } 1222 }
1198 skb_pull(skb, len); 1223 skb_pull(skb, len);
@@ -1229,7 +1254,7 @@ static void read_iso_tasklet(unsigned long data)
1229 1254
1230 /* loop while more completed URBs arrive in the meantime */ 1255 /* loop while more completed URBs arrive in the meantime */
1231 for (;;) { 1256 for (;;) {
1232 if (!atomic_read(&cs->connected)) { 1257 if (unlikely(!atomic_read(&cs->connected))) {
1233 warn("%s: disconnected", __func__); 1258 warn("%s: disconnected", __func__);
1234 return; 1259 return;
1235 } 1260 }
@@ -1242,15 +1267,20 @@ static void read_iso_tasklet(unsigned long data)
1242 } 1267 }
1243 ubc->isoindone = NULL; 1268 ubc->isoindone = NULL;
1244 if (unlikely(ubc->loststatus != -EINPROGRESS)) { 1269 if (unlikely(ubc->loststatus != -EINPROGRESS)) {
1245 warn("isochronous read overrun, dropped URB with status: %s, %d bytes lost", 1270 dev_warn(cs->dev,
1246 get_usb_statmsg(ubc->loststatus), ubc->isoinlost); 1271 "isochronous read overrun, "
1272 "dropped URB with status: %s, %d bytes lost\n",
1273 get_usb_statmsg(ubc->loststatus),
1274 ubc->isoinlost);
1247 ubc->loststatus = -EINPROGRESS; 1275 ubc->loststatus = -EINPROGRESS;
1248 } 1276 }
1249 spin_unlock_irqrestore(&ubc->isoinlock, flags); 1277 spin_unlock_irqrestore(&ubc->isoinlock, flags);
1250 1278
1251 if (unlikely(!(atomic_read(&ubc->running)))) { 1279 if (unlikely(!(atomic_read(&ubc->running)))) {
1252 dbg(DEBUG_ISO, "%s: channel not running, dropped URB with status: %s", 1280 gig_dbg(DEBUG_ISO,
1253 __func__, get_usb_statmsg(urb->status)); 1281 "%s: channel not running, "
1282 "dropped URB with status: %s",
1283 __func__, get_usb_statmsg(urb->status));
1254 return; 1284 return;
1255 } 1285 }
1256 1286
@@ -1259,22 +1289,23 @@ static void read_iso_tasklet(unsigned long data)
1259 break; 1289 break;
1260 case -EXDEV: /* inspect individual frames 1290 case -EXDEV: /* inspect individual frames
1261 (we do that anyway) */ 1291 (we do that anyway) */
1262 dbg(DEBUG_ISO, "%s: URB partially completed", __func__); 1292 gig_dbg(DEBUG_ISO, "%s: URB partially completed",
1293 __func__);
1263 break; 1294 break;
1264 case -ENOENT: 1295 case -ENOENT:
1265 case -ECONNRESET: 1296 case -ECONNRESET:
1266 dbg(DEBUG_ISO, "%s: URB canceled", __func__); 1297 gig_dbg(DEBUG_ISO, "%s: URB canceled", __func__);
1267 continue; /* -> skip */ 1298 continue; /* -> skip */
1268 case -EINPROGRESS: /* huh? */ 1299 case -EINPROGRESS: /* huh? */
1269 dbg(DEBUG_ISO, "%s: URB still pending", __func__); 1300 gig_dbg(DEBUG_ISO, "%s: URB still pending", __func__);
1270 continue; /* -> skip */ 1301 continue; /* -> skip */
1271 case -EPIPE: 1302 case -EPIPE:
1272 err("isochronous read stalled"); 1303 dev_err(cs->dev, "isochronous read stalled\n");
1273 error_hangup(bcs); 1304 error_hangup(bcs);
1274 continue; /* -> skip */ 1305 continue; /* -> skip */
1275 default: /* severe trouble */ 1306 default: /* severe trouble */
1276 warn("isochronous read: %s", 1307 dev_warn(cs->dev, "isochronous read: %s\n",
1277 get_usb_statmsg(urb->status)); 1308 get_usb_statmsg(urb->status));
1278 goto error; 1309 goto error;
1279 } 1310 }
1280 1311
@@ -1282,33 +1313,44 @@ static void read_iso_tasklet(unsigned long data)
1282 totleft = urb->actual_length; 1313 totleft = urb->actual_length;
1283 for (frame = 0; totleft > 0 && frame < BAS_NUMFRAMES; frame++) { 1314 for (frame = 0; totleft > 0 && frame < BAS_NUMFRAMES; frame++) {
1284 if (unlikely(urb->iso_frame_desc[frame].status)) { 1315 if (unlikely(urb->iso_frame_desc[frame].status)) {
1285 warn("isochronous read: frame %d: %s", frame, 1316 dev_warn(cs->dev,
1286 get_usb_statmsg(urb->iso_frame_desc[frame].status)); 1317 "isochronous read: frame %d: %s\n",
1318 frame,
1319 get_usb_statmsg(
1320 urb->iso_frame_desc[frame].status));
1287 break; 1321 break;
1288 } 1322 }
1289 numbytes = urb->iso_frame_desc[frame].actual_length; 1323 numbytes = urb->iso_frame_desc[frame].actual_length;
1290 if (unlikely(numbytes > BAS_MAXFRAME)) { 1324 if (unlikely(numbytes > BAS_MAXFRAME)) {
1291 warn("isochronous read: frame %d: numbytes (%d) > BAS_MAXFRAME", 1325 dev_warn(cs->dev,
1292 frame, numbytes); 1326 "isochronous read: frame %d: "
1327 "numbytes (%d) > BAS_MAXFRAME\n",
1328 frame, numbytes);
1293 break; 1329 break;
1294 } 1330 }
1295 if (unlikely(numbytes > totleft)) { 1331 if (unlikely(numbytes > totleft)) {
1296 warn("isochronous read: frame %d: numbytes (%d) > totleft (%d)", 1332 dev_warn(cs->dev,
1297 frame, numbytes, totleft); 1333 "isochronous read: frame %d: "
1334 "numbytes (%d) > totleft (%d)\n",
1335 frame, numbytes, totleft);
1298 break; 1336 break;
1299 } 1337 }
1300 offset = urb->iso_frame_desc[frame].offset; 1338 offset = urb->iso_frame_desc[frame].offset;
1301 if (unlikely(offset + numbytes > BAS_INBUFSIZE)) { 1339 if (unlikely(offset + numbytes > BAS_INBUFSIZE)) {
1302 warn("isochronous read: frame %d: offset (%d) + numbytes (%d) > BAS_INBUFSIZE", 1340 dev_warn(cs->dev,
1303 frame, offset, numbytes); 1341 "isochronous read: frame %d: "
1342 "offset (%d) + numbytes (%d) "
1343 "> BAS_INBUFSIZE\n",
1344 frame, offset, numbytes);
1304 break; 1345 break;
1305 } 1346 }
1306 gigaset_isoc_receive(rcvbuf + offset, numbytes, bcs); 1347 gigaset_isoc_receive(rcvbuf + offset, numbytes, bcs);
1307 totleft -= numbytes; 1348 totleft -= numbytes;
1308 } 1349 }
1309 if (unlikely(totleft > 0)) 1350 if (unlikely(totleft > 0))
1310 warn("isochronous read: %d data bytes missing", 1351 dev_warn(cs->dev,
1311 totleft); 1352 "isochronous read: %d data bytes missing\n",
1353 totleft);
1312 1354
1313 error: 1355 error:
1314 /* URB processed, resubmit */ 1356 /* URB processed, resubmit */
@@ -1316,12 +1358,14 @@ static void read_iso_tasklet(unsigned long data)
1316 urb->iso_frame_desc[frame].status = 0; 1358 urb->iso_frame_desc[frame].status = 0;
1317 urb->iso_frame_desc[frame].actual_length = 0; 1359 urb->iso_frame_desc[frame].actual_length = 0;
1318 } 1360 }
1319 urb->dev = bcs->cs->hw.bas->udev; /* clobbered by USB subsystem */ 1361 /* urb->dev is clobbered by USB subsystem */
1362 urb->dev = bcs->cs->hw.bas->udev;
1320 urb->transfer_flags = URB_ISO_ASAP; 1363 urb->transfer_flags = URB_ISO_ASAP;
1321 urb->number_of_packets = BAS_NUMFRAMES; 1364 urb->number_of_packets = BAS_NUMFRAMES;
1322 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) { 1365 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) {
1323 err("could not resubmit isochronous read URB: %s", 1366 dev_err(cs->dev,
1324 get_usb_statmsg(rc)); 1367 "could not resubmit isochronous read URB: %s\n",
1368 get_usb_statmsg(rc));
1325 dump_urb(DEBUG_ISO, "resubmit iso read", urb); 1369 dump_urb(DEBUG_ISO, "resubmit iso read", urb);
1326 error_hangup(bcs); 1370 error_hangup(bcs);
1327 } 1371 }
@@ -1357,33 +1401,34 @@ static void req_timeout(unsigned long data)
1357 1401
1358 switch (pending) { 1402 switch (pending) {
1359 case 0: /* no pending request */ 1403 case 0: /* no pending request */
1360 dbg(DEBUG_USBREQ, "%s: no request pending", __func__); 1404 gig_dbg(DEBUG_USBREQ, "%s: no request pending", __func__);
1361 break; 1405 break;
1362 1406
1363 case HD_OPEN_ATCHANNEL: 1407 case HD_OPEN_ATCHANNEL:
1364 err("timeout opening AT channel"); 1408 dev_err(bcs->cs->dev, "timeout opening AT channel\n");
1365 error_reset(bcs->cs); 1409 error_reset(bcs->cs);
1366 break; 1410 break;
1367 1411
1368 case HD_OPEN_B2CHANNEL: 1412 case HD_OPEN_B2CHANNEL:
1369 case HD_OPEN_B1CHANNEL: 1413 case HD_OPEN_B1CHANNEL:
1370 err("timeout opening channel %d", bcs->channel + 1); 1414 dev_err(bcs->cs->dev, "timeout opening channel %d\n",
1415 bcs->channel + 1);
1371 error_hangup(bcs); 1416 error_hangup(bcs);
1372 break; 1417 break;
1373 1418
1374 case HD_CLOSE_ATCHANNEL: 1419 case HD_CLOSE_ATCHANNEL:
1375 err("timeout closing AT channel"); 1420 dev_err(bcs->cs->dev, "timeout closing AT channel\n");
1376 //wake_up_interruptible(cs->initwait);
1377 //FIXME need own wait queue?
1378 break; 1421 break;
1379 1422
1380 case HD_CLOSE_B2CHANNEL: 1423 case HD_CLOSE_B2CHANNEL:
1381 case HD_CLOSE_B1CHANNEL: 1424 case HD_CLOSE_B1CHANNEL:
1382 err("timeout closing channel %d", bcs->channel + 1); 1425 dev_err(bcs->cs->dev, "timeout closing channel %d\n",
1426 bcs->channel + 1);
1383 break; 1427 break;
1384 1428
1385 default: 1429 default:
1386 warn("request 0x%02x timed out, clearing", pending); 1430 dev_warn(bcs->cs->dev, "request 0x%02x timed out, clearing\n",
1431 pending);
1387 } 1432 }
1388} 1433}
1389 1434
@@ -1406,8 +1451,9 @@ static void write_ctrl_callback(struct urb *urb, struct pt_regs *regs)
1406 ucs = (struct bas_cardstate *) urb->context; 1451 ucs = (struct bas_cardstate *) urb->context;
1407 spin_lock_irqsave(&ucs->lock, flags); 1452 spin_lock_irqsave(&ucs->lock, flags);
1408 if (urb->status && ucs->pending) { 1453 if (urb->status && ucs->pending) {
1409 err("control request 0x%02x failed: %s", 1454 dev_err(&ucs->interface->dev,
1410 ucs->pending, get_usb_statmsg(urb->status)); 1455 "control request 0x%02x failed: %s\n",
1456 ucs->pending, get_usb_statmsg(urb->status));
1411 del_timer(&ucs->timer_ctrl); 1457 del_timer(&ucs->timer_ctrl);
1412 ucs->pending = 0; 1458 ucs->pending = 0;
1413 } 1459 }
@@ -1446,18 +1492,21 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
1446 IFNULLRETVAL(ucs, -EINVAL); 1492 IFNULLRETVAL(ucs, -EINVAL);
1447 IFNULLRETVAL(ucs->urb_ctrl, -EINVAL); 1493 IFNULLRETVAL(ucs->urb_ctrl, -EINVAL);
1448 1494
1449 dbg(DEBUG_USBREQ, "-------> 0x%02x (%d)", req, val); 1495 gig_dbg(DEBUG_USBREQ, "-------> 0x%02x (%d)", req, val);
1450 1496
1451 spin_lock_irqsave(&ucs->lock, flags); 1497 spin_lock_irqsave(&ucs->lock, flags);
1452 if (ucs->pending) { 1498 if (ucs->pending) {
1453 spin_unlock_irqrestore(&ucs->lock, flags); 1499 spin_unlock_irqrestore(&ucs->lock, flags);
1454 err("submission of request 0x%02x failed: request 0x%02x still pending", 1500 dev_err(bcs->cs->dev,
1455 req, ucs->pending); 1501 "submission of request 0x%02x failed: "
1502 "request 0x%02x still pending\n",
1503 req, ucs->pending);
1456 return -EBUSY; 1504 return -EBUSY;
1457 } 1505 }
1458 if (ucs->urb_ctrl->status == -EINPROGRESS) { 1506 if (ucs->urb_ctrl->status == -EINPROGRESS) {
1459 spin_unlock_irqrestore(&ucs->lock, flags); 1507 spin_unlock_irqrestore(&ucs->lock, flags);
1460 err("could not submit request 0x%02x: URB busy", req); 1508 dev_err(bcs->cs->dev,
1509 "could not submit request 0x%02x: URB busy\n", req);
1461 return -EBUSY; 1510 return -EBUSY;
1462 } 1511 }
1463 1512
@@ -1467,19 +1516,19 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
1467 ucs->dr_ctrl.wIndex = 0; 1516 ucs->dr_ctrl.wIndex = 0;
1468 ucs->dr_ctrl.wLength = 0; 1517 ucs->dr_ctrl.wLength = 0;
1469 usb_fill_control_urb(ucs->urb_ctrl, ucs->udev, 1518 usb_fill_control_urb(ucs->urb_ctrl, ucs->udev,
1470 usb_sndctrlpipe(ucs->udev, 0), 1519 usb_sndctrlpipe(ucs->udev, 0),
1471 (unsigned char*) &ucs->dr_ctrl, NULL, 0, 1520 (unsigned char*) &ucs->dr_ctrl, NULL, 0,
1472 write_ctrl_callback, ucs); 1521 write_ctrl_callback, ucs);
1473 if ((ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC)) != 0) { 1522 if ((ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC)) != 0) {
1474 err("could not submit request 0x%02x: %s", 1523 dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n",
1475 req, get_usb_statmsg(ret)); 1524 req, get_usb_statmsg(ret));
1476 spin_unlock_irqrestore(&ucs->lock, flags); 1525 spin_unlock_irqrestore(&ucs->lock, flags);
1477 return ret; 1526 return ret;
1478 } 1527 }
1479 ucs->pending = req; 1528 ucs->pending = req;
1480 1529
1481 if (timeout > 0) { 1530 if (timeout > 0) {
1482 dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout); 1531 gig_dbg(DEBUG_USBREQ, "setting timeout of %d/10 secs", timeout);
1483 ucs->timer_ctrl.expires = jiffies + timeout * HZ / 10; 1532 ucs->timer_ctrl.expires = jiffies + timeout * HZ / 10;
1484 ucs->timer_ctrl.data = (unsigned long) bcs; 1533 ucs->timer_ctrl.data = (unsigned long) bcs;
1485 ucs->timer_ctrl.function = req_timeout; 1534 ucs->timer_ctrl.function = req_timeout;
@@ -1505,16 +1554,17 @@ static int gigaset_init_bchannel(struct bc_state *bcs)
1505 IFNULLRETVAL(bcs, -EINVAL); 1554 IFNULLRETVAL(bcs, -EINVAL);
1506 1555
1507 if ((ret = starturbs(bcs)) < 0) { 1556 if ((ret = starturbs(bcs)) < 0) {
1508 err("could not start isochronous I/O for channel %d", 1557 dev_err(bcs->cs->dev,
1509 bcs->channel + 1); 1558 "could not start isochronous I/O for channel %d\n",
1559 bcs->channel + 1);
1510 error_hangup(bcs); 1560 error_hangup(bcs);
1511 return ret; 1561 return ret;
1512 } 1562 }
1513 1563
1514 req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL; 1564 req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL;
1515 if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) { 1565 if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) {
1516 err("could not open channel %d: %s", 1566 dev_err(bcs->cs->dev, "could not open channel %d: %s\n",
1517 bcs->channel + 1, get_usb_statmsg(ret)); 1567 bcs->channel + 1, get_usb_statmsg(ret));
1518 stopurbs(bcs->hw.bas); 1568 stopurbs(bcs->hw.bas);
1519 error_hangup(bcs); 1569 error_hangup(bcs);
1520 } 1570 }
@@ -1546,8 +1596,9 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
1546 1596
1547 req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL; 1597 req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL;
1548 if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) 1598 if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0)
1549 err("could not submit HD_CLOSE_BxCHANNEL request: %s", 1599 dev_err(bcs->cs->dev,
1550 get_usb_statmsg(ret)); 1600 "could not submit HD_CLOSE_BxCHANNEL request: %s\n",
1601 get_usb_statmsg(ret));
1551 return ret; 1602 return ret;
1552} 1603}
1553 1604
@@ -1570,9 +1621,9 @@ static void complete_cb(struct cardstate *cs)
1570 1621
1571 /* unqueue completed buffer */ 1622 /* unqueue completed buffer */
1572 cs->cmdbytes -= cs->curlen; 1623 cs->cmdbytes -= cs->curlen;
1573 dbg(DEBUG_TRANSCMD | DEBUG_LOCKCMD, 1624 gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD,
1574 "write_command: sent %u bytes, %u left", 1625 "write_command: sent %u bytes, %u left",
1575 cs->curlen, cs->cmdbytes); 1626 cs->curlen, cs->cmdbytes);
1576 if ((cs->cmdbuf = cb->next) != NULL) { 1627 if ((cs->cmdbuf = cb->next) != NULL) {
1577 cs->cmdbuf->prev = NULL; 1628 cs->cmdbuf->prev = NULL;
1578 cs->curlen = cs->cmdbuf->len; 1629 cs->curlen = cs->cmdbuf->len;
@@ -1616,22 +1667,27 @@ static void write_command_callback(struct urb *urb, struct pt_regs *regs)
1616 case -ECONNRESET: /* canceled (async) */ 1667 case -ECONNRESET: /* canceled (async) */
1617 case -EINPROGRESS: /* pending */ 1668 case -EINPROGRESS: /* pending */
1618 /* ignore silently */ 1669 /* ignore silently */
1619 dbg(DEBUG_USBREQ, 1670 gig_dbg(DEBUG_USBREQ, "%s: %s",
1620 "%s: %s", __func__, get_usb_statmsg(urb->status)); 1671 __func__, get_usb_statmsg(urb->status));
1621 return; 1672 return;
1622 default: /* any failure */ 1673 default: /* any failure */
1623 if (++ucs->retry_cmd_out > BAS_RETRY) { 1674 if (++ucs->retry_cmd_out > BAS_RETRY) {
1624 warn("command write: %s, giving up after %d retries", 1675 dev_warn(cs->dev,
1625 get_usb_statmsg(urb->status), ucs->retry_cmd_out); 1676 "command write: %s, "
1677 "giving up after %d retries\n",
1678 get_usb_statmsg(urb->status),
1679 ucs->retry_cmd_out);
1626 break; 1680 break;
1627 } 1681 }
1628 if (cs->cmdbuf == NULL) { 1682 if (cs->cmdbuf == NULL) {
1629 warn("command write: %s, cannot retry - cmdbuf gone", 1683 dev_warn(cs->dev,
1630 get_usb_statmsg(urb->status)); 1684 "command write: %s, "
1685 "cannot retry - cmdbuf gone\n",
1686 get_usb_statmsg(urb->status));
1631 break; 1687 break;
1632 } 1688 }
1633 notice("command write: %s, retry %d", 1689 dev_notice(cs->dev, "command write: %s, retry %d\n",
1634 get_usb_statmsg(urb->status), ucs->retry_cmd_out); 1690 get_usb_statmsg(urb->status), ucs->retry_cmd_out);
1635 if (atwrite_submit(cs, cs->cmdbuf->buf, cs->cmdbuf->len) >= 0) 1691 if (atwrite_submit(cs, cs->cmdbuf->buf, cs->cmdbuf->len) >= 0)
1636 /* resubmitted - bypass regular exit block */ 1692 /* resubmitted - bypass regular exit block */
1637 return; 1693 return;
@@ -1659,7 +1715,7 @@ static void atrdy_timeout(unsigned long data)
1659 ucs = cs->hw.bas; 1715 ucs = cs->hw.bas;
1660 IFNULLRET(ucs); 1716 IFNULLRET(ucs);
1661 1717
1662 warn("timeout waiting for HD_READY_SEND_ATDATA"); 1718 dev_warn(cs->dev, "timeout waiting for HD_READY_SEND_ATDATA\n");
1663 1719
1664 /* fake the missing signal - what else can I do? */ 1720 /* fake the missing signal - what else can I do? */
1665 update_basstate(ucs, BS_ATREADY, BS_ATTIMER); 1721 update_basstate(ucs, BS_ATREADY, BS_ATTIMER);
@@ -1688,10 +1744,11 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
1688 IFNULLRETVAL(ucs, -EFAULT); 1744 IFNULLRETVAL(ucs, -EFAULT);
1689 IFNULLRETVAL(ucs->urb_cmd_out, -EFAULT); 1745 IFNULLRETVAL(ucs->urb_cmd_out, -EFAULT);
1690 1746
1691 dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len); 1747 gig_dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len);
1692 1748
1693 if (ucs->urb_cmd_out->status == -EINPROGRESS) { 1749 if (ucs->urb_cmd_out->status == -EINPROGRESS) {
1694 err("could not submit HD_WRITE_ATMESSAGE: URB busy"); 1750 dev_err(cs->dev,
1751 "could not submit HD_WRITE_ATMESSAGE: URB busy\n");
1695 return -EBUSY; 1752 return -EBUSY;
1696 } 1753 }
1697 1754
@@ -1706,8 +1763,8 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
1706 write_command_callback, cs); 1763 write_command_callback, cs);
1707 1764
1708 if ((ret = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC)) != 0) { 1765 if ((ret = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC)) != 0) {
1709 err("could not submit HD_WRITE_ATMESSAGE: %s", 1766 dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n",
1710 get_usb_statmsg(ret)); 1767 get_usb_statmsg(ret));
1711 return ret; 1768 return ret;
1712 } 1769 }
1713 1770
@@ -1716,8 +1773,8 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
1716 1773
1717 /* start timeout if necessary */ 1774 /* start timeout if necessary */
1718 if (!(atomic_read(&ucs->basstate) & BS_ATTIMER)) { 1775 if (!(atomic_read(&ucs->basstate) & BS_ATTIMER)) {
1719 dbg(DEBUG_OUTPUT, 1776 gig_dbg(DEBUG_OUTPUT, "setting ATREADY timeout of %d/10 secs",
1720 "setting ATREADY timeout of %d/10 secs", ATRDY_TIMEOUT); 1777 ATRDY_TIMEOUT);
1721 ucs->timer_atrdy.expires = jiffies + ATRDY_TIMEOUT * HZ / 10; 1778 ucs->timer_atrdy.expires = jiffies + ATRDY_TIMEOUT * HZ / 10;
1722 ucs->timer_atrdy.data = (unsigned long) cs; 1779 ucs->timer_atrdy.data = (unsigned long) cs;
1723 ucs->timer_atrdy.function = atrdy_timeout; 1780 ucs->timer_atrdy.function = atrdy_timeout;
@@ -1749,10 +1806,10 @@ static int start_cbsend(struct cardstate *cs)
1749 1806
1750 /* check if AT channel is open */ 1807 /* check if AT channel is open */
1751 if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) { 1808 if (!(atomic_read(&ucs->basstate) & BS_ATOPEN)) {
1752 dbg(DEBUG_TRANSCMD | DEBUG_LOCKCMD, "AT channel not open"); 1809 gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "AT channel not open");
1753 rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT); 1810 rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT);
1754 if (rc < 0) { 1811 if (rc < 0) {
1755 err("could not open AT channel"); 1812 dev_err(cs->dev, "could not open AT channel\n");
1756 /* flush command queue */ 1813 /* flush command queue */
1757 spin_lock_irqsave(&cs->cmdlock, flags); 1814 spin_lock_irqsave(&cs->cmdlock, flags);
1758 while (cs->cmdbuf != NULL) 1815 while (cs->cmdbuf != NULL)
@@ -1797,19 +1854,19 @@ static int start_cbsend(struct cardstate *cs)
1797 * error code < 0 on error 1854 * error code < 0 on error
1798 */ 1855 */
1799static int gigaset_write_cmd(struct cardstate *cs, 1856static int gigaset_write_cmd(struct cardstate *cs,
1800 const unsigned char *buf, int len, 1857 const unsigned char *buf, int len,
1801 struct tasklet_struct *wake_tasklet) 1858 struct tasklet_struct *wake_tasklet)
1802{ 1859{
1803 struct cmdbuf_t *cb; 1860 struct cmdbuf_t *cb;
1804 unsigned long flags; 1861 unsigned long flags;
1805 int status; 1862 int status;
1806 1863
1807 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? 1864 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ?
1808 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 1865 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
1809 "CMD Transmit", len, buf, 0); 1866 "CMD Transmit", len, buf, 0);
1810 1867
1811 if (!atomic_read(&cs->connected)) { 1868 if (unlikely(!atomic_read(&cs->connected))) {
1812 err("%s: not connected", __func__); 1869 err("%s: disconnected", __func__);
1813 return -ENODEV; 1870 return -ENODEV;
1814 } 1871 }
1815 1872
@@ -1819,7 +1876,7 @@ static int gigaset_write_cmd(struct cardstate *cs,
1819 if (len > IF_WRITEBUF) 1876 if (len > IF_WRITEBUF)
1820 len = IF_WRITEBUF; 1877 len = IF_WRITEBUF;
1821 if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { 1878 if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) {
1822 err("%s: out of memory", __func__); 1879 dev_err(cs->dev, "%s: out of memory\n", __func__);
1823 return -ENOMEM; 1880 return -ENOMEM;
1824 } 1881 }
1825 1882
@@ -1947,7 +2004,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
1947 return 0; 2004 return 0;
1948 } 2005 }
1949 tasklet_init(&ubc->sent_tasklet, 2006 tasklet_init(&ubc->sent_tasklet,
1950 &write_iso_tasklet, (unsigned long) bcs); 2007 &write_iso_tasklet, (unsigned long) bcs);
1951 2008
1952 spin_lock_init(&ubc->isoinlock); 2009 spin_lock_init(&ubc->isoinlock);
1953 for (i = 0; i < BAS_INURBS; ++i) 2010 for (i = 0; i < BAS_INURBS; ++i)
@@ -1968,7 +2025,7 @@ static int gigaset_initbcshw(struct bc_state *bcs)
1968 ubc->shared0s = 0; 2025 ubc->shared0s = 0;
1969 ubc->stolen0s = 0; 2026 ubc->stolen0s = 0;
1970 tasklet_init(&ubc->rcvd_tasklet, 2027 tasklet_init(&ubc->rcvd_tasklet,
1971 &read_iso_tasklet, (unsigned long) bcs); 2028 &read_iso_tasklet, (unsigned long) bcs);
1972 return 1; 2029 return 1;
1973} 2030}
1974 2031
@@ -2041,43 +2098,47 @@ static void freeurbs(struct cardstate *cs)
2041 for (i = 0; i < BAS_OUTURBS; ++i) 2098 for (i = 0; i < BAS_OUTURBS; ++i)
2042 if (ubc->isoouturbs[i].urb) { 2099 if (ubc->isoouturbs[i].urb) {
2043 usb_kill_urb(ubc->isoouturbs[i].urb); 2100 usb_kill_urb(ubc->isoouturbs[i].urb);
2044 dbg(DEBUG_INIT, 2101 gig_dbg(DEBUG_INIT,
2045 "%s: isoc output URB %d/%d unlinked", 2102 "%s: isoc output URB %d/%d unlinked",
2046 __func__, j, i); 2103 __func__, j, i);
2047 usb_free_urb(ubc->isoouturbs[i].urb); 2104 usb_free_urb(ubc->isoouturbs[i].urb);
2048 ubc->isoouturbs[i].urb = NULL; 2105 ubc->isoouturbs[i].urb = NULL;
2049 } 2106 }
2050 for (i = 0; i < BAS_INURBS; ++i) 2107 for (i = 0; i < BAS_INURBS; ++i)
2051 if (ubc->isoinurbs[i]) { 2108 if (ubc->isoinurbs[i]) {
2052 usb_kill_urb(ubc->isoinurbs[i]); 2109 usb_kill_urb(ubc->isoinurbs[i]);
2053 dbg(DEBUG_INIT, 2110 gig_dbg(DEBUG_INIT,
2054 "%s: isoc input URB %d/%d unlinked", 2111 "%s: isoc input URB %d/%d unlinked",
2055 __func__, j, i); 2112 __func__, j, i);
2056 usb_free_urb(ubc->isoinurbs[i]); 2113 usb_free_urb(ubc->isoinurbs[i]);
2057 ubc->isoinurbs[i] = NULL; 2114 ubc->isoinurbs[i] = NULL;
2058 } 2115 }
2059 } 2116 }
2060 if (ucs->urb_int_in) { 2117 if (ucs->urb_int_in) {
2061 usb_kill_urb(ucs->urb_int_in); 2118 usb_kill_urb(ucs->urb_int_in);
2062 dbg(DEBUG_INIT, "%s: interrupt input URB unlinked", __func__); 2119 gig_dbg(DEBUG_INIT, "%s: interrupt input URB unlinked",
2120 __func__);
2063 usb_free_urb(ucs->urb_int_in); 2121 usb_free_urb(ucs->urb_int_in);
2064 ucs->urb_int_in = NULL; 2122 ucs->urb_int_in = NULL;
2065 } 2123 }
2066 if (ucs->urb_cmd_out) { 2124 if (ucs->urb_cmd_out) {
2067 usb_kill_urb(ucs->urb_cmd_out); 2125 usb_kill_urb(ucs->urb_cmd_out);
2068 dbg(DEBUG_INIT, "%s: command output URB unlinked", __func__); 2126 gig_dbg(DEBUG_INIT, "%s: command output URB unlinked",
2127 __func__);
2069 usb_free_urb(ucs->urb_cmd_out); 2128 usb_free_urb(ucs->urb_cmd_out);
2070 ucs->urb_cmd_out = NULL; 2129 ucs->urb_cmd_out = NULL;
2071 } 2130 }
2072 if (ucs->urb_cmd_in) { 2131 if (ucs->urb_cmd_in) {
2073 usb_kill_urb(ucs->urb_cmd_in); 2132 usb_kill_urb(ucs->urb_cmd_in);
2074 dbg(DEBUG_INIT, "%s: command input URB unlinked", __func__); 2133 gig_dbg(DEBUG_INIT, "%s: command input URB unlinked",
2134 __func__);
2075 usb_free_urb(ucs->urb_cmd_in); 2135 usb_free_urb(ucs->urb_cmd_in);
2076 ucs->urb_cmd_in = NULL; 2136 ucs->urb_cmd_in = NULL;
2077 } 2137 }
2078 if (ucs->urb_ctrl) { 2138 if (ucs->urb_ctrl) {
2079 usb_kill_urb(ucs->urb_ctrl); 2139 usb_kill_urb(ucs->urb_ctrl);
2080 dbg(DEBUG_INIT, "%s: control output URB unlinked", __func__); 2140 gig_dbg(DEBUG_INIT, "%s: control output URB unlinked",
2141 __func__);
2081 usb_free_urb(ucs->urb_ctrl); 2142 usb_free_urb(ucs->urb_ctrl);
2082 ucs->urb_ctrl = NULL; 2143 ucs->urb_ctrl = NULL;
2083 } 2144 }
@@ -2101,10 +2162,10 @@ static int gigaset_probe(struct usb_interface *interface,
2101 2162
2102 IFNULLRETVAL(udev, -ENODEV); 2163 IFNULLRETVAL(udev, -ENODEV);
2103 2164
2104 dbg(DEBUG_ANY, 2165 gig_dbg(DEBUG_ANY,
2105 "%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)", 2166 "%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)",
2106 __func__, le16_to_cpu(udev->descriptor.idVendor), 2167 __func__, le16_to_cpu(udev->descriptor.idVendor),
2107 le16_to_cpu(udev->descriptor.idProduct)); 2168 le16_to_cpu(udev->descriptor.idProduct));
2108 2169
2109 /* See if the device offered us matches what we can accept */ 2170 /* See if the device offered us matches what we can accept */
2110 if ((le16_to_cpu(udev->descriptor.idVendor) != USB_GIGA_VENDOR_ID) || 2171 if ((le16_to_cpu(udev->descriptor.idVendor) != USB_GIGA_VENDOR_ID) ||
@@ -2112,20 +2173,21 @@ static int gigaset_probe(struct usb_interface *interface,
2112 le16_to_cpu(udev->descriptor.idProduct) != USB_4175_PRODUCT_ID && 2173 le16_to_cpu(udev->descriptor.idProduct) != USB_4175_PRODUCT_ID &&
2113 le16_to_cpu(udev->descriptor.idProduct) != USB_SX303_PRODUCT_ID && 2174 le16_to_cpu(udev->descriptor.idProduct) != USB_SX303_PRODUCT_ID &&
2114 le16_to_cpu(udev->descriptor.idProduct) != USB_SX353_PRODUCT_ID)) { 2175 le16_to_cpu(udev->descriptor.idProduct) != USB_SX353_PRODUCT_ID)) {
2115 dbg(DEBUG_ANY, "%s: unmatched ID - exiting", __func__); 2176 gig_dbg(DEBUG_ANY, "%s: unmatched ID - exiting", __func__);
2116 return -ENODEV; 2177 return -ENODEV;
2117 } 2178 }
2118 2179
2119 /* set required alternate setting */ 2180 /* set required alternate setting */
2120 hostif = interface->cur_altsetting; 2181 hostif = interface->cur_altsetting;
2121 if (hostif->desc.bAlternateSetting != 3) { 2182 if (hostif->desc.bAlternateSetting != 3) {
2122 dbg(DEBUG_ANY, 2183 gig_dbg(DEBUG_ANY,
2123 "%s: wrong alternate setting %d - trying to switch", 2184 "%s: wrong alternate setting %d - trying to switch",
2124 __func__, hostif->desc.bAlternateSetting); 2185 __func__, hostif->desc.bAlternateSetting);
2125 if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3) < 0) { 2186 if (usb_set_interface(udev, hostif->desc.bInterfaceNumber, 3) < 0) {
2126 warn("usb_set_interface failed, device %d interface %d altsetting %d", 2187 dev_warn(&udev->dev, "usb_set_interface failed, "
2127 udev->devnum, hostif->desc.bInterfaceNumber, 2188 "device %d interface %d altsetting %d\n",
2128 hostif->desc.bAlternateSetting); 2189 udev->devnum, hostif->desc.bInterfaceNumber,
2190 hostif->desc.bAlternateSetting);
2129 return -ENODEV; 2191 return -ENODEV;
2130 } 2192 }
2131 hostif = interface->cur_altsetting; 2193 hostif = interface->cur_altsetting;
@@ -2134,23 +2196,28 @@ static int gigaset_probe(struct usb_interface *interface,
2134 /* Reject application specific interfaces 2196 /* Reject application specific interfaces
2135 */ 2197 */
2136 if (hostif->desc.bInterfaceClass != 255) { 2198 if (hostif->desc.bInterfaceClass != 255) {
2137 warn("%s: bInterfaceClass == %d", 2199 dev_warn(&udev->dev, "%s: bInterfaceClass == %d\n",
2138 __func__, hostif->desc.bInterfaceClass); 2200 __func__, hostif->desc.bInterfaceClass);
2139 return -ENODEV; 2201 return -ENODEV;
2140 } 2202 }
2141 2203
2142 info("%s: Device matched (Vendor: 0x%x, Product: 0x%x)", 2204 dev_info(&udev->dev,
2143 __func__, le16_to_cpu(udev->descriptor.idVendor), 2205 "%s: Device matched (Vendor: 0x%x, Product: 0x%x)\n",
2144 le16_to_cpu(udev->descriptor.idProduct)); 2206 __func__, le16_to_cpu(udev->descriptor.idVendor),
2207 le16_to_cpu(udev->descriptor.idProduct));
2145 2208
2146 cs = gigaset_getunassignedcs(driver); 2209 cs = gigaset_getunassignedcs(driver);
2147 if (!cs) { 2210 if (!cs) {
2148 err("%s: no free cardstate", __func__); 2211 dev_err(&udev->dev, "no free cardstate\n");
2149 return -ENODEV; 2212 return -ENODEV;
2150 } 2213 }
2151 ucs = cs->hw.bas; 2214 ucs = cs->hw.bas;
2215
2216 /* save off device structure ptrs for later use */
2217 usb_get_dev(udev);
2152 ucs->udev = udev; 2218 ucs->udev = udev;
2153 ucs->interface = interface; 2219 ucs->interface = interface;
2220 cs->dev = &udev->dev;
2154 2221
2155 /* allocate URBs: 2222 /* allocate URBs:
2156 * - one for the interrupt pipe 2223 * - one for the interrupt pipe
@@ -2159,22 +2226,22 @@ static int gigaset_probe(struct usb_interface *interface,
2159 */ 2226 */
2160 ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL); 2227 ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL);
2161 if (!ucs->urb_int_in) { 2228 if (!ucs->urb_int_in) {
2162 err("No free urbs available"); 2229 dev_err(cs->dev, "no free urbs available\n");
2163 goto error; 2230 goto error;
2164 } 2231 }
2165 ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL); 2232 ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL);
2166 if (!ucs->urb_cmd_in) { 2233 if (!ucs->urb_cmd_in) {
2167 err("No free urbs available"); 2234 dev_err(cs->dev, "no free urbs available\n");
2168 goto error; 2235 goto error;
2169 } 2236 }
2170 ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL); 2237 ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL);
2171 if (!ucs->urb_cmd_out) { 2238 if (!ucs->urb_cmd_out) {
2172 err("No free urbs available"); 2239 dev_err(cs->dev, "no free urbs available\n");
2173 goto error; 2240 goto error;
2174 } 2241 }
2175 ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL); 2242 ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL);
2176 if (!ucs->urb_ctrl) { 2243 if (!ucs->urb_ctrl) {
2177 err("No free urbs available"); 2244 dev_err(cs->dev, "no free urbs available\n");
2178 goto error; 2245 goto error;
2179 } 2246 }
2180 2247
@@ -2184,7 +2251,7 @@ static int gigaset_probe(struct usb_interface *interface,
2184 ubc->isoouturbs[i].urb = 2251 ubc->isoouturbs[i].urb =
2185 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL); 2252 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL);
2186 if (!ubc->isoouturbs[i].urb) { 2253 if (!ubc->isoouturbs[i].urb) {
2187 err("No free urbs available"); 2254 dev_err(cs->dev, "no free urbs available\n");
2188 goto error; 2255 goto error;
2189 } 2256 }
2190 } 2257 }
@@ -2192,7 +2259,7 @@ static int gigaset_probe(struct usb_interface *interface,
2192 ubc->isoinurbs[i] = 2259 ubc->isoinurbs[i] =
2193 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL); 2260 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL);
2194 if (!ubc->isoinurbs[i]) { 2261 if (!ubc->isoinurbs[i]) {
2195 err("No free urbs available"); 2262 dev_err(cs->dev, "no free urbs available\n");
2196 goto error; 2263 goto error;
2197 } 2264 }
2198 } 2265 }
@@ -2204,13 +2271,14 @@ static int gigaset_probe(struct usb_interface *interface,
2204 /* Fill the interrupt urb and send it to the core */ 2271 /* Fill the interrupt urb and send it to the core */
2205 endpoint = &hostif->endpoint[0].desc; 2272 endpoint = &hostif->endpoint[0].desc;
2206 usb_fill_int_urb(ucs->urb_int_in, udev, 2273 usb_fill_int_urb(ucs->urb_int_in, udev,
2207 usb_rcvintpipe(udev, 2274 usb_rcvintpipe(udev,
2208 (endpoint->bEndpointAddress) & 0x0f), 2275 (endpoint->bEndpointAddress) & 0x0f),
2209 ucs->int_in_buf, 3, read_int_callback, cs, 2276 ucs->int_in_buf, 3, read_int_callback, cs,
2210 endpoint->bInterval); 2277 endpoint->bInterval);
2211 ret = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL); 2278 ret = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL);
2212 if (ret) { 2279 if (ret) {
2213 err("could not submit interrupt URB: %s", get_usb_statmsg(ret)); 2280 dev_err(cs->dev, "could not submit interrupt URB: %s\n",
2281 get_usb_statmsg(ret));
2214 goto error; 2282 goto error;
2215 } 2283 }
2216 2284
@@ -2255,7 +2323,7 @@ static void gigaset_disconnect(struct usb_interface *interface)
2255 ucs = cs->hw.bas; 2323 ucs = cs->hw.bas;
2256 IFNULLRET(ucs); 2324 IFNULLRET(ucs);
2257 2325
2258 info("disconnecting GigaSet base"); 2326 dev_info(cs->dev, "disconnecting GigaSet base");
2259 gigaset_stop(cs); 2327 gigaset_stop(cs);
2260 freeurbs(cs); 2328 freeurbs(cs);
2261 kfree(ucs->rcvbuf); 2329 kfree(ucs->rcvbuf);
@@ -2293,9 +2361,9 @@ static int __init bas_gigaset_init(void)
2293 2361
2294 /* allocate memory for our driver state and intialize it */ 2362 /* allocate memory for our driver state and intialize it */
2295 if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, 2363 if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
2296 GIGASET_MODULENAME, GIGASET_DEVNAME, 2364 GIGASET_MODULENAME, GIGASET_DEVNAME,
2297 GIGASET_DEVFSNAME, &gigops, 2365 GIGASET_DEVFSNAME, &gigops,
2298 THIS_MODULE)) == NULL) 2366 THIS_MODULE)) == NULL)
2299 goto error; 2367 goto error;
2300 2368
2301 /* allocate memory for our device state and intialize it */ 2369 /* allocate memory for our device state and intialize it */
@@ -2330,19 +2398,18 @@ error: if (cardstate)
2330static void __exit bas_gigaset_exit(void) 2398static void __exit bas_gigaset_exit(void)
2331{ 2399{
2332 gigaset_blockdriver(driver); /* => probe will fail 2400 gigaset_blockdriver(driver); /* => probe will fail
2333 * => no gigaset_start any more 2401 * => no gigaset_start any more
2334 */ 2402 */
2335 2403
2336 gigaset_shutdown(cardstate); 2404 gigaset_shutdown(cardstate);
2337 /* from now on, no isdn callback should be possible */ 2405 /* from now on, no isdn callback should be possible */
2338 2406
2339 if (atomic_read(&cardstate->hw.bas->basstate) & BS_ATOPEN) { 2407 if (atomic_read(&cardstate->hw.bas->basstate) & BS_ATOPEN) {
2340 dbg(DEBUG_ANY, "closing AT channel"); 2408 gig_dbg(DEBUG_ANY, "closing AT channel");
2341 if (req_submit(cardstate->bcs, 2409 if (req_submit(cardstate->bcs,
2342 HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT) >= 0) { 2410 HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT) >= 0) {
2343 /* successfully submitted - wait for completion */ 2411 /* successfully submitted */
2344 //wait_event_interruptible(cs->initwait, !cs->hw.bas->pending); 2412 //FIXME wait for completion?
2345 //FIXME need own wait queue? wakeup?
2346 } 2413 }
2347 } 2414 }
2348 2415
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);
38static struct cardstate *alloc_cs(struct gigaset_driver *drv); 35static struct cardstate *alloc_cs(struct gigaset_driver *drv);
39static void free_cs(struct cardstate *cs); 36static void free_cs(struct cardstate *cs);
40static void make_valid(struct cardstate *cs, unsigned mask); 37static void make_valid(struct cardstate *cs, unsigned mask);
41static void make_invalid(struct cardstate *cs, unsigned mask); 38static 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] = {
82EXPORT_SYMBOL_GPL(gigaset_invtab); 79EXPORT_SYMBOL_GPL(gigaset_invtab);
83 80
84void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, 81void 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}
123EXPORT_SYMBOL_GPL(gigaset_dbg_buffer); 133EXPORT_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
173error: 183error:
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
330struct event_t *gigaset_add_event(struct cardstate *cs, 341struct 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 }
464f_bcs: dbg(DEBUG_INIT, "freeing bcs[]"); 475f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
465 kfree(cs->bcs); 476 kfree(cs->bcs);
466f_cs: dbg(DEBUG_INIT, "freeing cs"); 477f_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}
470EXPORT_SYMBOL_GPL(gigaset_freecs); 481EXPORT_SYMBOL_GPL(gigaset_freecs);
471 482
472void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs, 483void 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
501static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs, 512static 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 */
514static struct bc_state *gigaset_initbcs(struct bc_state *bcs, 525static 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
698error: if (cs) 710error: 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 */
1016struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, 1029struct 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;
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index 6c1000491231..53490430a2e1 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -171,7 +171,7 @@ struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
171 // {ACT_TIMEOUT}}, 171 // {ACT_TIMEOUT}},
172 172
173 {RSP_INIT, -1, -1,SEQ_INIT, 100, INIT_TIMEOUT, 173 {RSP_INIT, -1, -1,SEQ_INIT, 100, INIT_TIMEOUT,
174 {ACT_TIMEOUT}}, /* wait until device is ready */ 174 {ACT_TIMEOUT}}, /* wait until device is ready */
175 175
176 {EV_TIMEOUT, 100,100, -1, 101, 3, {0}, "Z\r"}, /* device in transparent mode? try to initialize it. */ 176 {EV_TIMEOUT, 100,100, -1, 101, 3, {0}, "Z\r"}, /* device in transparent mode? try to initialize it. */
177 {RSP_OK, 101,103, -1, 120, 5, {ACT_GETSTRING}, "+GMR\r"}, /* get version */ 177 {RSP_OK, 101,103, -1, 120, 5, {ACT_GETSTRING}, "+GMR\r"}, /* get version */
@@ -186,8 +186,8 @@ struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
186 {RSP_ERROR, 108,108, -1, 0, 0, {ACT_FAILINIT}}, 186 {RSP_ERROR, 108,108, -1, 0, 0, {ACT_FAILINIT}},
187 187
188 {EV_TIMEOUT, 108,108, -1, 105, 2, {ACT_SETDLE0, 188 {EV_TIMEOUT, 108,108, -1, 105, 2, {ACT_SETDLE0,
189 ACT_HUPMODEM, 189 ACT_HUPMODEM,
190 ACT_TIMEOUT}}, /* still timeout => connection in unimodem mode? */ 190 ACT_TIMEOUT}}, /* still timeout => connection in unimodem mode? */
191 {EV_TIMEOUT, 105,105, -1, 103, 5, {0}, "Z\r"}, 191 {EV_TIMEOUT, 105,105, -1, 103, 5, {0}, "Z\r"},
192 192
193 {RSP_ERROR, 102,102, -1, 107, 5, {0}, "^GETPRE\r"}, /* ERROR on ATZ => maybe in config mode? */ 193 {RSP_ERROR, 102,102, -1, 107, 5, {0}, "^GETPRE\r"}, /* ERROR on ATZ => maybe in config mode? */
@@ -444,7 +444,7 @@ static int isdn_getnum(char *p)
444 444
445 IFNULLRETVAL(p, -1); 445 IFNULLRETVAL(p, -1);
446 446
447 dbg(DEBUG_TRANSCMD, "string: %s", p); 447 gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
448 448
449 while (*p >= '0' && *p <= '9') 449 while (*p >= '0' && *p <= '9')
450 v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0'); 450 v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0');
@@ -463,7 +463,7 @@ static int isdn_gethex(char *p)
463 463
464 IFNULLRETVAL(p, -1); 464 IFNULLRETVAL(p, -1);
465 465
466 dbg(DEBUG_TRANSCMD, "string: %s", p); 466 gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
467 467
468 if (!*p) 468 if (!*p)
469 return -1; 469 return -1;
@@ -537,11 +537,11 @@ void gigaset_handle_modem_response(struct cardstate *cs)
537 len = cs->cbytes; 537 len = cs->cbytes;
538 if (!len) { 538 if (!len) {
539 /* ignore additional LFs/CRs (M10x config mode or cx100) */ 539 /* ignore additional LFs/CRs (M10x config mode or cx100) */
540 dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]); 540 gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]);
541 return; 541 return;
542 } 542 }
543 cs->respdata[len] = 0; 543 cs->respdata[len] = 0;
544 dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata); 544 gig_dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata);
545 argv[0] = cs->respdata; 545 argv[0] = cs->respdata;
546 params = 1; 546 params = 1;
547 if (cs->at_state.getstring) { 547 if (cs->at_state.getstring) {
@@ -557,7 +557,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
557 case ',': 557 case ',':
558 case '=': 558 case '=':
559 if (params > MAX_REC_PARAMS) { 559 if (params > MAX_REC_PARAMS) {
560 warn("too many parameters in response"); 560 dev_warn(cs->dev,
561 "too many parameters in response\n");
561 /* need last parameter (might be CID) */ 562 /* need last parameter (might be CID) */
562 params--; 563 params--;
563 } 564 }
@@ -568,21 +569,21 @@ void gigaset_handle_modem_response(struct cardstate *cs)
568 cid = params > 1 ? cid_of_response(argv[params-1]) : 0; 569 cid = params > 1 ? cid_of_response(argv[params-1]) : 0;
569 if (cid < 0) { 570 if (cid < 0) {
570 gigaset_add_event(cs, &cs->at_state, RSP_INVAL, 571 gigaset_add_event(cs, &cs->at_state, RSP_INVAL,
571 NULL, 0, NULL); 572 NULL, 0, NULL);
572 return; 573 return;
573 } 574 }
574 575
575 for (j = 1; j < params; ++j) 576 for (j = 1; j < params; ++j)
576 argv[j][-1] = 0; 577 argv[j][-1] = 0;
577 578
578 dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]); 579 gig_dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]);
579 if (cid) { 580 if (cid) {
580 --params; 581 --params;
581 dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]); 582 gig_dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]);
582 } 583 }
583 dbg(DEBUG_TRANSCMD, "available params: %d", params - 1); 584 gig_dbg(DEBUG_TRANSCMD, "available params: %d", params - 1);
584 for (j = 1; j < params; j++) 585 for (j = 1; j < params; j++)
585 dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]); 586 gig_dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]);
586 } 587 }
587 588
588 spin_lock_irqsave(&cs->ev_lock, flags); 589 spin_lock_irqsave(&cs->ev_lock, flags);
@@ -594,7 +595,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
594 while (curarg < params) { 595 while (curarg < params) {
595 next = (tail + 1) % MAX_EVENTS; 596 next = (tail + 1) % MAX_EVENTS;
596 if (unlikely(next == head)) { 597 if (unlikely(next == head)) {
597 err("event queue full"); 598 dev_err(cs->dev, "event queue full\n");
598 break; 599 break;
599 } 600 }
600 601
@@ -615,8 +616,9 @@ void gigaset_handle_modem_response(struct cardstate *cs)
615 616
616 if (!rt->response) { 617 if (!rt->response) {
617 event->type = RSP_UNKNOWN; 618 event->type = RSP_UNKNOWN;
618 warn("unknown modem response: %s", 619 dev_warn(cs->dev,
619 argv[curarg]); 620 "unknown modem response: %s\n",
621 argv[curarg]);
620 break; 622 break;
621 } 623 }
622 624
@@ -632,7 +634,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
632 break; 634 break;
633 case RT_RING: 635 case RT_RING:
634 if (!cid) { 636 if (!cid) {
635 err("received RING without CID!"); 637 dev_err(cs->dev,
638 "received RING without CID!\n");
636 event->type = RSP_INVAL; 639 event->type = RSP_INVAL;
637 abort = 1; 640 abort = 1;
638 } else { 641 } else {
@@ -660,27 +663,25 @@ void gigaset_handle_modem_response(struct cardstate *cs)
660 event->parameter = ZSAU_DISCONNECT_REQ; 663 event->parameter = ZSAU_DISCONNECT_REQ;
661 else { 664 else {
662 event->parameter = ZSAU_UNKNOWN; 665 event->parameter = ZSAU_UNKNOWN;
663 warn("%s: unknown parameter %s after ZSAU", 666 dev_warn(cs->dev,
664 __func__, argv[curarg]); 667 "%s: unknown parameter %s after ZSAU\n",
668 __func__, argv[curarg]);
665 } 669 }
666 ++curarg; 670 ++curarg;
667 break; 671 break;
668 case RT_STRING: 672 case RT_STRING:
669 if (curarg < params) { 673 if (curarg < params) {
670 len = strlen(argv[curarg]) + 1; 674 event->ptr = kstrdup(argv[curarg], GFP_ATOMIC);
671 event->ptr = kmalloc(len, GFP_ATOMIC); 675 if (!event->ptr)
672 if (event->ptr) 676 dev_err(cs->dev, "out of memory\n");
673 memcpy(event->ptr, argv[curarg], len);
674 else
675 err("no memory for string!");
676 ++curarg; 677 ++curarg;
677 } 678 }
678#ifdef CONFIG_GIGASET_DEBUG 679#ifdef CONFIG_GIGASET_DEBUG
679 if (!event->ptr) 680 if (!event->ptr)
680 dbg(DEBUG_CMD, "string==NULL"); 681 gig_dbg(DEBUG_CMD, "string==NULL");
681 else 682 else
682 dbg(DEBUG_CMD, 683 gig_dbg(DEBUG_CMD, "string==%s",
683 "string==%s", (char *) event->ptr); 684 (char *) event->ptr);
684#endif 685#endif
685 break; 686 break;
686 case RT_ZCAU: 687 case RT_ZCAU:
@@ -690,7 +691,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
690 j = isdn_gethex(argv[curarg + 1]); 691 j = isdn_gethex(argv[curarg + 1]);
691 if (i >= 0 && i < 256 && j >= 0 && j < 256) 692 if (i >= 0 && i < 256 && j >= 0 && j < 256)
692 event->parameter = (unsigned) i << 8 693 event->parameter = (unsigned) i << 8
693 | j; 694 | j;
694 curarg += 2; 695 curarg += 2;
695 } else 696 } else
696 curarg = params - 1; 697 curarg = params - 1;
@@ -708,7 +709,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
708 } else 709 } else
709 event->parameter = -1; 710 event->parameter = -1;
710#ifdef CONFIG_GIGASET_DEBUG 711#ifdef CONFIG_GIGASET_DEBUG
711 dbg(DEBUG_CMD, "parameter==%d", event->parameter); 712 gig_dbg(DEBUG_CMD, "parameter==%d", event->parameter);
712#endif 713#endif
713 break; 714 break;
714 } 715 }
@@ -724,8 +725,9 @@ void gigaset_handle_modem_response(struct cardstate *cs)
724 spin_unlock_irqrestore(&cs->ev_lock, flags); 725 spin_unlock_irqrestore(&cs->ev_lock, flags);
725 726
726 if (curarg != params) 727 if (curarg != params)
727 dbg(DEBUG_ANY, "invalid number of processed parameters: %d/%d", 728 gig_dbg(DEBUG_ANY,
728 curarg, params); 729 "invalid number of processed parameters: %d/%d",
730 curarg, params);
729} 731}
730EXPORT_SYMBOL_GPL(gigaset_handle_modem_response); 732EXPORT_SYMBOL_GPL(gigaset_handle_modem_response);
731 733
@@ -750,7 +752,7 @@ static void disconnect(struct at_state_t **at_state_p)
750 if (!atomic_read(&cs->cidmode)) { 752 if (!atomic_read(&cs->cidmode)) {
751 cs->at_state.pending_commands |= PC_UMMODE; 753 cs->at_state.pending_commands |= PC_UMMODE;
752 atomic_set(&cs->commands_pending, 1); //FIXME 754 atomic_set(&cs->commands_pending, 1); //FIXME
753 dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); 755 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
754 } 756 }
755 757
756 if (bcs) { 758 if (bcs) {
@@ -773,7 +775,7 @@ static void disconnect(struct at_state_t **at_state_p)
773 * The structure should be freed by calling disconnect() after use. 775 * The structure should be freed by calling disconnect() after use.
774 */ 776 */
775static inline struct at_state_t *get_free_channel(struct cardstate *cs, 777static inline struct at_state_t *get_free_channel(struct cardstate *cs,
776 int cid) 778 int cid)
777/* cids: >0: siemens-cid 779/* cids: >0: siemens-cid
778 0: without cid 780 0: without cid
779 -1: no cid assigned yet 781 -1: no cid assigned yet
@@ -822,7 +824,7 @@ static void init_failed(struct cardstate *cs, int mode)
822static void schedule_init(struct cardstate *cs, int state) 824static void schedule_init(struct cardstate *cs, int state)
823{ 825{
824 if (cs->at_state.pending_commands & PC_INIT) { 826 if (cs->at_state.pending_commands & PC_INIT) {
825 dbg(DEBUG_CMD, "not scheduling PC_INIT again"); 827 gig_dbg(DEBUG_CMD, "not scheduling PC_INIT again");
826 return; 828 return;
827 } 829 }
828 atomic_set(&cs->mstate, state); 830 atomic_set(&cs->mstate, state);
@@ -830,53 +832,56 @@ static void schedule_init(struct cardstate *cs, int state)
830 gigaset_block_channels(cs); 832 gigaset_block_channels(cs);
831 cs->at_state.pending_commands |= PC_INIT; 833 cs->at_state.pending_commands |= PC_INIT;
832 atomic_set(&cs->commands_pending, 1); 834 atomic_set(&cs->commands_pending, 1);
833 dbg(DEBUG_CMD, "Scheduling PC_INIT"); 835 gig_dbg(DEBUG_CMD, "Scheduling PC_INIT");
834} 836}
835 837
836/* Add "AT" to a command, add the cid, dle encode it, send the result to the 838/* Add "AT" to a command, add the cid, dle encode it, send the result to the
837 hardware. */ 839 hardware. */
838static void send_command(struct cardstate *cs, const char *cmd, int cid, 840static void send_command(struct cardstate *cs, const char *cmd, int cid,
839 int dle, gfp_t kmallocflags) 841 int dle, gfp_t kmallocflags)
840{ 842{
841 size_t cmdlen, buflen; 843 size_t cmdlen, buflen;
842 char *cmdpos, *cmdbuf, *cmdtail; 844 char *cmdpos, *cmdbuf, *cmdtail;
843 845
844 cmdlen = strlen(cmd); 846 cmdlen = strlen(cmd);
845 buflen = 11 + cmdlen; 847 buflen = 11 + cmdlen;
848 if (unlikely(buflen <= cmdlen)) {
849 dev_err(cs->dev, "integer overflow in buflen\n");
850 return;
851 }
846 852
847 if (likely(buflen > cmdlen)) { 853 cmdbuf = kmalloc(buflen, kmallocflags);
848 cmdbuf = kmalloc(buflen, kmallocflags); 854 if (unlikely(!cmdbuf)) {
849 if (likely(cmdbuf != NULL)) { 855 dev_err(cs->dev, "out of memory\n");
850 cmdpos = cmdbuf + 9; 856 return;
851 cmdtail = cmdpos + cmdlen; 857 }
852 memcpy(cmdpos, cmd, cmdlen);
853
854 if (cid > 0 && cid <= 65535) {
855 do {
856 *--cmdpos = '0' + cid % 10;
857 cid /= 10;
858 ++cmdlen;
859 } while (cid);
860 }
861 858
862 cmdlen += 2; 859 cmdpos = cmdbuf + 9;
863 *--cmdpos = 'T'; 860 cmdtail = cmdpos + cmdlen;
864 *--cmdpos = 'A'; 861 memcpy(cmdpos, cmd, cmdlen);
865 862
866 if (dle) { 863 if (cid > 0 && cid <= 65535) {
867 cmdlen += 4; 864 do {
868 *--cmdpos = '('; 865 *--cmdpos = '0' + cid % 10;
869 *--cmdpos = 0x10; 866 cid /= 10;
870 *cmdtail++ = 0x10; 867 ++cmdlen;
871 *cmdtail++ = ')'; 868 } while (cid);
872 } 869 }
873 870
874 cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL); 871 cmdlen += 2;
875 kfree(cmdbuf); 872 *--cmdpos = 'T';
876 } else 873 *--cmdpos = 'A';
877 err("no memory for command buffer"); 874
878 } else 875 if (dle) {
879 err("overflow in buflen"); 876 cmdlen += 4;
877 *--cmdpos = '(';
878 *--cmdpos = 0x10;
879 *cmdtail++ = 0x10;
880 *cmdtail++ = ')';
881 }
882
883 cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL);
884 kfree(cmdbuf);
880} 885}
881 886
882static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid) 887static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid)
@@ -930,13 +935,14 @@ static void bchannel_up(struct bc_state *bcs)
930 IFNULLRET(bcs); 935 IFNULLRET(bcs);
931 936
932 if (!(bcs->chstate & CHS_D_UP)) { 937 if (!(bcs->chstate & CHS_D_UP)) {
933 notice("%s: D channel not up", __func__); 938 dev_notice(bcs->cs->dev, "%s: D channel not up\n", __func__);
934 bcs->chstate |= CHS_D_UP; 939 bcs->chstate |= CHS_D_UP;
935 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN); 940 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
936 } 941 }
937 942
938 if (bcs->chstate & CHS_B_UP) { 943 if (bcs->chstate & CHS_B_UP) {
939 notice("%s: B channel already up", __func__); 944 dev_notice(bcs->cs->dev, "%s: B channel already up\n",
945 __func__);
940 return; 946 return;
941 } 947 }
942 948
@@ -962,13 +968,13 @@ static void start_dial(struct at_state_t *at_state, void *data, int seq_index)
962 968
963 969
964 at_state->pending_commands |= PC_CID; 970 at_state->pending_commands |= PC_CID;
965 dbg(DEBUG_CMD, "Scheduling PC_CID"); 971 gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
966 atomic_set(&cs->commands_pending, 1); 972 atomic_set(&cs->commands_pending, 1);
967 return; 973 return;
968 974
969error: 975error:
970 at_state->pending_commands |= PC_NOCID; 976 at_state->pending_commands |= PC_NOCID;
971 dbg(DEBUG_CMD, "Scheduling PC_NOCID"); 977 gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID");
972 atomic_set(&cs->commands_pending, 1); 978 atomic_set(&cs->commands_pending, 1);
973 return; 979 return;
974} 980}
@@ -982,12 +988,12 @@ static void start_accept(struct at_state_t *at_state)
982 988
983 if (retval == 0) { 989 if (retval == 0) {
984 at_state->pending_commands |= PC_ACCEPT; 990 at_state->pending_commands |= PC_ACCEPT;
985 dbg(DEBUG_CMD, "Scheduling PC_ACCEPT"); 991 gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
986 atomic_set(&cs->commands_pending, 1); 992 atomic_set(&cs->commands_pending, 1);
987 } else { 993 } else {
988 //FIXME 994 //FIXME
989 at_state->pending_commands |= PC_HUP; 995 at_state->pending_commands |= PC_HUP;
990 dbg(DEBUG_CMD, "Scheduling PC_HUP"); 996 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
991 atomic_set(&cs->commands_pending, 1); 997 atomic_set(&cs->commands_pending, 1);
992 } 998 }
993} 999}
@@ -1000,8 +1006,8 @@ static void do_start(struct cardstate *cs)
1000 schedule_init(cs, MS_INIT); 1006 schedule_init(cs, MS_INIT);
1001 1007
1002 gigaset_i4l_cmd(cs, ISDN_STAT_RUN); 1008 gigaset_i4l_cmd(cs, ISDN_STAT_RUN);
1003 // FIXME: not in locked mode 1009 // FIXME: not in locked mode
1004 // FIXME 2: only after init sequence 1010 // FIXME 2: only after init sequence
1005 1011
1006 cs->waiting = 0; 1012 cs->waiting = 0;
1007 wake_up(&cs->waitqueue); 1013 wake_up(&cs->waitqueue);
@@ -1029,7 +1035,7 @@ static void do_shutdown(struct cardstate *cs)
1029 atomic_set(&cs->mstate, MS_SHUTDOWN); 1035 atomic_set(&cs->mstate, MS_SHUTDOWN);
1030 cs->at_state.pending_commands |= PC_SHUTDOWN; 1036 cs->at_state.pending_commands |= PC_SHUTDOWN;
1031 atomic_set(&cs->commands_pending, 1); 1037 atomic_set(&cs->commands_pending, 1);
1032 dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN"); 1038 gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
1033 } else 1039 } else
1034 finish_shutdown(cs); 1040 finish_shutdown(cs);
1035} 1041}
@@ -1059,9 +1065,11 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
1059 return 0; 1065 return 0;
1060 1066
1061 if (channel < 0) 1067 if (channel < 0)
1062 warn("Could not enter cid mode. Reinit device and try again."); 1068 dev_warn(cs->dev,
1069 "Could not enter cid mode. Reinit device and try again.\n");
1063 else { 1070 else {
1064 warn("Could not get a call id. Reinit device and try again."); 1071 dev_warn(cs->dev,
1072 "Could not get a call id. Reinit device and try again.\n");
1065 cs->bcs[channel].at_state.pending_commands |= PC_CID; 1073 cs->bcs[channel].at_state.pending_commands |= PC_CID;
1066 } 1074 }
1067 schedule_init(cs, MS_INIT); 1075 schedule_init(cs, MS_INIT);
@@ -1069,7 +1077,7 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
1069} 1077}
1070 1078
1071static int at_state_invalid(struct cardstate *cs, 1079static int at_state_invalid(struct cardstate *cs,
1072 struct at_state_t *test_ptr) 1080 struct at_state_t *test_ptr)
1073{ 1081{
1074 unsigned long flags; 1082 unsigned long flags;
1075 unsigned channel; 1083 unsigned channel;
@@ -1106,7 +1114,7 @@ static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
1106 case ICALL_ACCEPT: 1114 case ICALL_ACCEPT:
1107 break; 1115 break;
1108 default: 1116 default:
1109 err("internal error: disposition=%d", retval); 1117 dev_err(cs->dev, "internal error: disposition=%d\n", retval);
1110 /* --v-- fall through --v-- */ 1118 /* --v-- fall through --v-- */
1111 case ICALL_IGNORE: 1119 case ICALL_IGNORE:
1112 case ICALL_REJECT: 1120 case ICALL_REJECT:
@@ -1201,10 +1209,10 @@ static void do_action(int action, struct cardstate *cs,
1201 } 1209 }
1202 cs->at_state.pending_commands |= PC_CIDMODE; 1210 cs->at_state.pending_commands |= PC_CIDMODE;
1203 atomic_set(&cs->commands_pending, 1); 1211 atomic_set(&cs->commands_pending, 1);
1204 dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1212 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1205 break; 1213 break;
1206 case ACT_FAILINIT: 1214 case ACT_FAILINIT:
1207 warn("Could not initialize the device."); 1215 dev_warn(cs->dev, "Could not initialize the device.\n");
1208 cs->dle = 0; 1216 cs->dle = 0;
1209 init_failed(cs, M_UNKNOWN); 1217 init_failed(cs, M_UNKNOWN);
1210 cs->cur_at_seq = SEQ_NONE; 1218 cs->cur_at_seq = SEQ_NONE;
@@ -1260,8 +1268,8 @@ static void do_action(int action, struct cardstate *cs,
1260 /* get fresh AT state structure for new CID */ 1268 /* get fresh AT state structure for new CID */
1261 at_state2 = get_free_channel(cs, ev->parameter); 1269 at_state2 = get_free_channel(cs, ev->parameter);
1262 if (!at_state2) { 1270 if (!at_state2) {
1263 warn("RING ignored: " 1271 dev_warn(cs->dev,
1264 "could not allocate channel structure"); 1272 "RING ignored: could not allocate channel structure\n");
1265 break; 1273 break;
1266 } 1274 }
1267 1275
@@ -1289,7 +1297,7 @@ static void do_action(int action, struct cardstate *cs,
1289 at_state = *p_at_state; 1297 at_state = *p_at_state;
1290 break; 1298 break;
1291 case ACT_FAILSDOWN: 1299 case ACT_FAILSDOWN:
1292 warn("Could not shut down the device."); 1300 dev_warn(cs->dev, "Could not shut down the device.\n");
1293 /* fall through */ 1301 /* fall through */
1294 case ACT_FAKESDOWN: 1302 case ACT_FAKESDOWN:
1295 case ACT_SDOWN: 1303 case ACT_SDOWN:
@@ -1342,7 +1350,7 @@ static void do_action(int action, struct cardstate *cs,
1342 break; 1350 break;
1343 case ACT_ABORTHUP: 1351 case ACT_ABORTHUP:
1344 cs->cur_at_seq = SEQ_NONE; 1352 cs->cur_at_seq = SEQ_NONE;
1345 warn("Could not hang up."); 1353 dev_warn(cs->dev, "Could not hang up.\n");
1346 at_state->cid = -1; 1354 at_state->cid = -1;
1347 if (bcs && cs->onechannel) 1355 if (bcs && cs->onechannel)
1348 at_state->pending_commands |= PC_DLE0; 1356 at_state->pending_commands |= PC_DLE0;
@@ -1354,14 +1362,15 @@ static void do_action(int action, struct cardstate *cs,
1354 break; 1362 break;
1355 case ACT_FAILDLE0: 1363 case ACT_FAILDLE0:
1356 cs->cur_at_seq = SEQ_NONE; 1364 cs->cur_at_seq = SEQ_NONE;
1357 warn("Could not leave DLE mode."); 1365 dev_warn(cs->dev, "Could not leave DLE mode.\n");
1358 at_state2 = &cs->bcs[cs->curchannel].at_state; 1366 at_state2 = &cs->bcs[cs->curchannel].at_state;
1359 disconnect(&at_state2); 1367 disconnect(&at_state2);
1360 schedule_init(cs, MS_RECOVER); 1368 schedule_init(cs, MS_RECOVER);
1361 break; 1369 break;
1362 case ACT_FAILDLE1: 1370 case ACT_FAILDLE1:
1363 cs->cur_at_seq = SEQ_NONE; 1371 cs->cur_at_seq = SEQ_NONE;
1364 warn("Could not enter DLE mode. Try to hang up."); 1372 dev_warn(cs->dev,
1373 "Could not enter DLE mode. Trying to hang up.\n");
1365 channel = cs->curchannel; 1374 channel = cs->curchannel;
1366 cs->bcs[channel].at_state.pending_commands |= PC_HUP; 1375 cs->bcs[channel].at_state.pending_commands |= PC_HUP;
1367 atomic_set(&cs->commands_pending, 1); 1376 atomic_set(&cs->commands_pending, 1);
@@ -1382,7 +1391,8 @@ static void do_action(int action, struct cardstate *cs,
1382 cs->cur_at_seq = SEQ_NONE; 1391 cs->cur_at_seq = SEQ_NONE;
1383 channel = cs->curchannel; 1392 channel = cs->curchannel;
1384 if (!reinit_and_retry(cs, channel)) { 1393 if (!reinit_and_retry(cs, channel)) {
1385 warn("Could not get a call id. Dialing not possible"); 1394 dev_warn(cs->dev,
1395 "Could not get a call ID. Cannot dial.\n");
1386 at_state2 = &cs->bcs[channel].at_state; 1396 at_state2 = &cs->bcs[channel].at_state;
1387 disconnect(&at_state2); 1397 disconnect(&at_state2);
1388 } 1398 }
@@ -1416,7 +1426,7 @@ static void do_action(int action, struct cardstate *cs,
1416 atomic_set(&cs->commands_pending, 1); 1426 atomic_set(&cs->commands_pending, 1);
1417 break; 1427 break;
1418 case ACT_GETSTRING: /* warning: RING, ZDLE, ... 1428 case ACT_GETSTRING: /* warning: RING, ZDLE, ...
1419 are not handled properly any more */ 1429 are not handled properly anymore */
1420 at_state->getstring = 1; 1430 at_state->getstring = 1;
1421 break; 1431 break;
1422 case ACT_SETVER: 1432 case ACT_SETVER:
@@ -1457,16 +1467,16 @@ static void do_action(int action, struct cardstate *cs,
1457 case ACT_GOTVER: 1467 case ACT_GOTVER:
1458 if (cs->gotfwver == 0) { 1468 if (cs->gotfwver == 0) {
1459 cs->gotfwver = 1; 1469 cs->gotfwver = 1;
1460 dbg(DEBUG_ANY, 1470 gig_dbg(DEBUG_ANY,
1461 "firmware version %02d.%03d.%02d.%02d", 1471 "firmware version %02d.%03d.%02d.%02d",
1462 cs->fwver[0], cs->fwver[1], 1472 cs->fwver[0], cs->fwver[1],
1463 cs->fwver[2], cs->fwver[3]); 1473 cs->fwver[2], cs->fwver[3]);
1464 break; 1474 break;
1465 } 1475 }
1466 /* fall through */ 1476 /* fall through */
1467 case ACT_FAILVER: 1477 case ACT_FAILVER:
1468 cs->gotfwver = -1; 1478 cs->gotfwver = -1;
1469 err("could not read firmware version."); 1479 dev_err(cs->dev, "could not read firmware version.\n");
1470 break; 1480 break;
1471#ifdef CONFIG_GIGASET_DEBUG 1481#ifdef CONFIG_GIGASET_DEBUG
1472 case ACT_ERROR: 1482 case ACT_ERROR:
@@ -1484,16 +1494,16 @@ static void do_action(int action, struct cardstate *cs,
1484 break; 1494 break;
1485#endif 1495#endif
1486 case ACT_DEBUG: 1496 case ACT_DEBUG:
1487 dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d", 1497 gig_dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d",
1488 __func__, ev->type, at_state->ConState); 1498 __func__, ev->type, at_state->ConState);
1489 break; 1499 break;
1490 case ACT_WARN: 1500 case ACT_WARN:
1491 warn("%s: resp_code %d in ConState %d!", 1501 dev_warn(cs->dev, "%s: resp_code %d in ConState %d!\n",
1492 __func__, ev->type, at_state->ConState); 1502 __func__, ev->type, at_state->ConState);
1493 break; 1503 break;
1494 case ACT_ZCAU: 1504 case ACT_ZCAU:
1495 warn("cause code %04x in connection state %d.", 1505 dev_warn(cs->dev, "cause code %04x in connection state %d.\n",
1496 ev->parameter, at_state->ConState); 1506 ev->parameter, at_state->ConState);
1497 break; 1507 break;
1498 1508
1499 /* events from the LL */ 1509 /* events from the LL */
@@ -1504,14 +1514,14 @@ static void do_action(int action, struct cardstate *cs,
1504 start_accept(at_state); 1514 start_accept(at_state);
1505 break; 1515 break;
1506 case ACT_PROTO_L2: 1516 case ACT_PROTO_L2:
1507 dbg(DEBUG_CMD, 1517 gig_dbg(DEBUG_CMD, "set protocol to %u",
1508 "set protocol to %u", (unsigned) ev->parameter); 1518 (unsigned) ev->parameter);
1509 at_state->bcs->proto2 = ev->parameter; 1519 at_state->bcs->proto2 = ev->parameter;
1510 break; 1520 break;
1511 case ACT_HUP: 1521 case ACT_HUP:
1512 at_state->pending_commands |= PC_HUP; 1522 at_state->pending_commands |= PC_HUP;
1513 atomic_set(&cs->commands_pending, 1); 1523 atomic_set(&cs->commands_pending, 1);
1514 dbg(DEBUG_CMD, "Scheduling PC_HUP"); 1524 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
1515 break; 1525 break;
1516 1526
1517 /* hotplug events */ 1527 /* hotplug events */
@@ -1547,10 +1557,10 @@ static void do_action(int action, struct cardstate *cs,
1547 atomic_set(&cs->cidmode, ev->parameter); 1557 atomic_set(&cs->cidmode, ev->parameter);
1548 if (ev->parameter) { 1558 if (ev->parameter) {
1549 cs->at_state.pending_commands |= PC_CIDMODE; 1559 cs->at_state.pending_commands |= PC_CIDMODE;
1550 dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1560 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1551 } else { 1561 } else {
1552 cs->at_state.pending_commands |= PC_UMMODE; 1562 cs->at_state.pending_commands |= PC_UMMODE;
1553 dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); 1563 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
1554 } 1564 }
1555 atomic_set(&cs->commands_pending, 1); 1565 atomic_set(&cs->commands_pending, 1);
1556 } 1566 }
@@ -1578,7 +1588,7 @@ static void do_action(int action, struct cardstate *cs,
1578 *p_resp_code = RSP_NULL; 1588 *p_resp_code = RSP_NULL;
1579 } 1589 }
1580 } else 1590 } else
1581 err("%s: action==%d!", __func__, action); 1591 dev_err(cs->dev, "%s: action==%d!\n", __func__, action);
1582 } 1592 }
1583} 1593}
1584 1594
@@ -1604,20 +1614,20 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1604 at_state = at_state_from_cid(cs, ev->cid); 1614 at_state = at_state_from_cid(cs, ev->cid);
1605 if (!at_state) { 1615 if (!at_state) {
1606 gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID, 1616 gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID,
1607 NULL, 0, NULL); 1617 NULL, 0, NULL);
1608 return; 1618 return;
1609 } 1619 }
1610 } else { 1620 } else {
1611 at_state = ev->at_state; 1621 at_state = ev->at_state;
1612 if (at_state_invalid(cs, at_state)) { 1622 if (at_state_invalid(cs, at_state)) {
1613 dbg(DEBUG_ANY, 1623 gig_dbg(DEBUG_ANY, "event for invalid at_state %p",
1614 "event for invalid at_state %p", at_state); 1624 at_state);
1615 return; 1625 return;
1616 } 1626 }
1617 } 1627 }
1618 1628
1619 dbg(DEBUG_CMD, 1629 gig_dbg(DEBUG_CMD, "connection state %d, event %d",
1620 "connection state %d, event %d", at_state->ConState, ev->type); 1630 at_state->ConState, ev->type);
1621 1631
1622 bcs = at_state->bcs; 1632 bcs = at_state->bcs;
1623 sendcid = at_state->cid; 1633 sendcid = at_state->cid;
@@ -1630,11 +1640,11 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1630 if (ev->parameter != atomic_read(&at_state->timer_index) 1640 if (ev->parameter != atomic_read(&at_state->timer_index)
1631 || !at_state->timer_active) { 1641 || !at_state->timer_active) {
1632 ev->type = RSP_NONE; /* old timeout */ 1642 ev->type = RSP_NONE; /* old timeout */
1633 dbg(DEBUG_ANY, "old timeout"); 1643 gig_dbg(DEBUG_ANY, "old timeout");
1634 } else if (!at_state->waiting) 1644 } else if (!at_state->waiting)
1635 dbg(DEBUG_ANY, "timeout occured"); 1645 gig_dbg(DEBUG_ANY, "timeout occurred");
1636 else 1646 else
1637 dbg(DEBUG_ANY, "stopped waiting"); 1647 gig_dbg(DEBUG_ANY, "stopped waiting");
1638 } 1648 }
1639 1649
1640 /* if the response belongs to a variable in at_state->int_var[VAR_XXXX] 1650 /* if the response belongs to a variable in at_state->int_var[VAR_XXXX]
@@ -1657,11 +1667,11 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1657 constate */ 1667 constate */
1658 for (;; rep++) { 1668 for (;; rep++) {
1659 rcode = rep->resp_code; 1669 rcode = rep->resp_code;
1660 /* dbg (DEBUG_ANY, "rcode %d", rcode); */
1661 if (rcode == RSP_LAST) { 1670 if (rcode == RSP_LAST) {
1662 /* found nothing...*/ 1671 /* found nothing...*/
1663 warn("%s: rcode=RSP_LAST: resp_code %d in ConState %d!", 1672 dev_warn(cs->dev, "%s: rcode=RSP_LAST: "
1664 __func__, ev->type, at_state->ConState); 1673 "resp_code %d in ConState %d!\n",
1674 __func__, ev->type, at_state->ConState);
1665 return; 1675 return;
1666 } 1676 }
1667 if ((rcode == RSP_ANY || rcode == ev->type) 1677 if ((rcode == RSP_ANY || rcode == ev->type)
@@ -1699,12 +1709,12 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1699 if (p_command/*rep->command*/) { 1709 if (p_command/*rep->command*/) {
1700 if (atomic_read(&cs->connected)) 1710 if (atomic_read(&cs->connected))
1701 send_command(cs, p_command, 1711 send_command(cs, p_command,
1702 sendcid, cs->dle, 1712 sendcid, cs->dle,
1703 GFP_ATOMIC); 1713 GFP_ATOMIC);
1704 else 1714 else
1705 gigaset_add_event(cs, at_state, 1715 gigaset_add_event(cs, at_state,
1706 RSP_NODEV, 1716 RSP_NODEV,
1707 NULL, 0, NULL); 1717 NULL, 0, NULL);
1708 } 1718 }
1709 1719
1710 spin_lock_irqsave(&cs->lock, flags); 1720 spin_lock_irqsave(&cs->lock, flags);
@@ -1715,7 +1725,7 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1715 at_state->timer_expires = rep->timeout * 10; 1725 at_state->timer_expires = rep->timeout * 10;
1716 at_state->timer_active = 1; 1726 at_state->timer_active = 1;
1717 new_index(&at_state->timer_index, 1727 new_index(&at_state->timer_index,
1718 MAX_TIMER_INDEX); 1728 MAX_TIMER_INDEX);
1719 } 1729 }
1720 spin_unlock_irqrestore(&cs->lock, flags); 1730 spin_unlock_irqrestore(&cs->lock, flags);
1721 } 1731 }
@@ -1741,11 +1751,11 @@ static void process_command_flags(struct cardstate *cs)
1741 atomic_set(&cs->commands_pending, 0); 1751 atomic_set(&cs->commands_pending, 0);
1742 1752
1743 if (cs->cur_at_seq) { 1753 if (cs->cur_at_seq) {
1744 dbg(DEBUG_CMD, "not searching scheduled commands: busy"); 1754 gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy");
1745 return; 1755 return;
1746 } 1756 }
1747 1757
1748 dbg(DEBUG_CMD, "searching scheduled commands"); 1758 gig_dbg(DEBUG_CMD, "searching scheduled commands");
1749 1759
1750 sequence = SEQ_NONE; 1760 sequence = SEQ_NONE;
1751 1761
@@ -1884,7 +1894,7 @@ static void process_command_flags(struct cardstate *cs)
1884 switch (atomic_read(&cs->mode)) { 1894 switch (atomic_read(&cs->mode)) {
1885 case M_UNIMODEM: 1895 case M_UNIMODEM:
1886 cs->at_state.pending_commands |= PC_CIDMODE; 1896 cs->at_state.pending_commands |= PC_CIDMODE;
1887 dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1897 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1888 atomic_set(&cs->commands_pending, 1); 1898 atomic_set(&cs->commands_pending, 1);
1889 return; 1899 return;
1890#ifdef GIG_MAYINITONDIAL 1900#ifdef GIG_MAYINITONDIAL
@@ -1945,7 +1955,8 @@ static void process_events(struct cardstate *cs)
1945 } 1955 }
1946 1956
1947 if (i == 2 * MAX_EVENTS) { 1957 if (i == 2 * MAX_EVENTS) {
1948 err("infinite loop in process_events; aborting."); 1958 dev_err(cs->dev,
1959 "infinite loop in process_events; aborting.\n");
1949 } 1960 }
1950} 1961}
1951 1962
@@ -1962,7 +1973,7 @@ void gigaset_handle_event(unsigned long data)
1962 1973
1963 /* handle incoming data on control/common channel */ 1974 /* handle incoming data on control/common channel */
1964 if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) { 1975 if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) {
1965 dbg(DEBUG_INTR, "processing new data"); 1976 gig_dbg(DEBUG_INTR, "processing new data");
1966 cs->ops->handle_input(cs->inbuf); 1977 cs->ops->handle_input(cs->inbuf);
1967 } 1978 }
1968 1979
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index bc5a6294f0c0..d77588de7eb7 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -106,10 +106,10 @@ extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */
106 * DEBUG_INTR. 106 * DEBUG_INTR.
107 */ 107 */
108enum debuglevel { /* up to 24 bits (atomic_t) */ 108enum debuglevel { /* up to 24 bits (atomic_t) */
109 DEBUG_REG = 0x0002,/* serial port I/O register operations */ 109 DEBUG_REG = 0x0002, /* serial port I/O register operations */
110 DEBUG_OPEN = 0x0004, /* open/close serial port */ 110 DEBUG_OPEN = 0x0004, /* open/close serial port */
111 DEBUG_INTR = 0x0008, /* interrupt processing */ 111 DEBUG_INTR = 0x0008, /* interrupt processing */
112 DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on 112 DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on
113 interrupt requests, not available as 113 interrupt requests, not available as
114 run-time option */ 114 run-time option */
115 DEBUG_CMD = 0x00020, /* sent/received LL commands */ 115 DEBUG_CMD = 0x00020, /* sent/received LL commands */
@@ -120,66 +120,68 @@ enum debuglevel { /* up to 24 bits (atomic_t) */
120 DEBUG_DRIVER = 0x00400, /* driver structure */ 120 DEBUG_DRIVER = 0x00400, /* driver structure */
121 DEBUG_HDLC = 0x00800, /* M10x HDLC processing */ 121 DEBUG_HDLC = 0x00800, /* M10x HDLC processing */
122 DEBUG_WRITE = 0x01000, /* M105 data write */ 122 DEBUG_WRITE = 0x01000, /* M105 data write */
123 DEBUG_TRANSCMD = 0x02000, /* AT-COMMANDS+RESPONSES */ 123 DEBUG_TRANSCMD = 0x02000, /* AT-COMMANDS+RESPONSES */
124 DEBUG_MCMD = 0x04000, /* COMMANDS THAT ARE SENT VERY OFTEN */ 124 DEBUG_MCMD = 0x04000, /* COMMANDS THAT ARE SENT VERY OFTEN */
125 DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data 125 DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data
126 structures */ 126 structures */
127 DEBUG_LOCK = 0x10000, /* semaphore operations */ 127 DEBUG_LOCK = 0x10000, /* semaphore operations */
128 DEBUG_OUTPUT = 0x20000, /* output to device */ 128 DEBUG_OUTPUT = 0x20000, /* output to device */
129 DEBUG_ISO = 0x40000, /* isochronous transfers */ 129 DEBUG_ISO = 0x40000, /* isochronous transfers */
130 DEBUG_IF = 0x80000, /* character device operations */ 130 DEBUG_IF = 0x80000, /* character device operations */
131 DEBUG_USBREQ = 0x100000, /* USB communication (except payload 131 DEBUG_USBREQ = 0x100000, /* USB communication (except payload
132 data) */ 132 data) */
133 DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when 133 DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when
134 MS_LOCKED */ 134 MS_LOCKED */
135 135
136 DEBUG_ANY = 0x3fffff, /* print message if any of the others is 136 DEBUG_ANY = 0x3fffff, /* print message if any of the others is
137 activated */ 137 activated */
138}; 138};
139 139
140#ifdef CONFIG_GIGASET_DEBUG 140/* missing from linux/device.h ... */
141#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ) 141#ifndef dev_notice
142#else 142#define dev_notice(dev, format, arg...) \
143#define DEBUG_DEFAULT 0 143 dev_printk(KERN_NOTICE , dev , format , ## arg)
144#endif 144#endif
145 145
146/* redefine syslog macros to prepend module name instead of entire 146/* Kernel message macros for situations where dev_printk and friends cannot be
147 * source path */ 147 * used for lack of reliable access to a device structure.
148 * linux/usb.h already contains these but in an obsolete form which clutters
149 * the log needlessly, and according to the USB maintainer those should be
150 * removed rather than fixed anyway.
151 */
152#undef err
148#undef info 153#undef info
149#define info(format, arg...) \
150 printk(KERN_INFO "%s: " format "\n", \
151 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
152
153#undef notice
154#define notice(format, arg...) \
155 printk(KERN_NOTICE "%s: " format "\n", \
156 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
157
158#undef warn 154#undef warn
159#define warn(format, arg...) \ 155#undef notice
160 printk(KERN_WARNING "%s: " format "\n", \
161 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
162 156
163#undef err 157#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
164#define err(format, arg...) \ 158 format "\n" , ## arg)
165 printk(KERN_ERR "%s: " format "\n", \ 159#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
166 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) 160 format "\n" , ## arg)
161#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \
162 format "\n" , ## arg)
163#define notice(format, arg...) printk(KERN_NOTICE KBUILD_MODNAME ": " \
164 format "\n" , ## arg)
167 165
168#undef dbg
169#ifdef CONFIG_GIGASET_DEBUG 166#ifdef CONFIG_GIGASET_DEBUG
170#define dbg(level, format, arg...) \ 167
168#define gig_dbg(level, format, arg...) \
171 do { \ 169 do { \
172 if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \ 170 if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \
173 printk(KERN_DEBUG "%s: " format "\n", \ 171 printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \
174 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" \ 172 ## arg); \
175 , ## arg); \
176 } while (0) 173 } while (0)
174#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)
175
177#else 176#else
178#define dbg(level, format, arg...) do {} while (0) 177
178#define gig_dbg(level, format, arg...) do {} while (0)
179#define DEBUG_DEFAULT 0
180
179#endif 181#endif
180 182
181void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, 183void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
182 size_t len, const unsigned char *buf, int from_user); 184 size_t len, const unsigned char *buf, int from_user);
183 185
184/* connection state */ 186/* connection state */
185#define ZSAU_NONE 0 187#define ZSAU_NONE 0
@@ -368,16 +370,6 @@ struct inbuf_t {
368 * BAS_OUTBUFPAD bytes immediately before data[write] (if 370 * BAS_OUTBUFPAD bytes immediately before data[write] (if
369 * write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD) 371 * write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD)
370 * are also filled with that value 372 * are also filled with that value
371 * - optionally, the following statistics on the buffer's usage can be
372 * collected:
373 * maxfill: maximum number of bytes occupied
374 * idlefills: number of times a frame of idle bytes is prepared
375 * emptygets: number of times the buffer was empty when a data frame was
376 * requested
377 * backtoback: number of times two data packets were entered into the buffer
378 * without intervening idle flags
379 * nakedback: set if no idle flags have been inserted since the last data
380 * packet
381 */ 373 */
382struct isowbuf_t { 374struct isowbuf_t {
383 atomic_t read; 375 atomic_t read;
@@ -471,7 +463,7 @@ struct bc_state {
471 int busy; 463 int busy;
472 int use_count; 464 int use_count;
473 465
474 /* hardware drivers */ 466 /* private data of hardware drivers */
475 union { 467 union {
476 struct ser_bc_state *ser; /* serial hardware driver */ 468 struct ser_bc_state *ser; /* serial hardware driver */
477 struct usb_bc_state *usb; /* usb hardware driver (m105) */ 469 struct usb_bc_state *usb; /* usb hardware driver (m105) */
@@ -482,6 +474,7 @@ struct bc_state {
482struct cardstate { 474struct cardstate {
483 struct gigaset_driver *driver; 475 struct gigaset_driver *driver;
484 unsigned minor_index; 476 unsigned minor_index;
477 struct device *dev;
485 478
486 const struct gigaset_ops *ops; 479 const struct gigaset_ops *ops;
487 480
@@ -531,11 +524,11 @@ struct cardstate {
531 int cs_init; 524 int cs_init;
532 int ignoreframes; /* frames to ignore after setting up the 525 int ignoreframes; /* frames to ignore after setting up the
533 B channel */ 526 B channel */
534 struct semaphore sem; /* locks this structure: */ 527 struct semaphore sem; /* locks this structure:
535 /* connected is not changed, */ 528 * connected is not changed,
536 /* hardware_up is not changed, */ 529 * hardware_up is not changed,
537 /* MState is not changed to or from 530 * MState is not changed to or from
538 MS_LOCKED */ 531 * MS_LOCKED */
539 532
540 struct timer_list timer; 533 struct timer_list timer;
541 int retry_count; 534 int retry_count;
@@ -543,7 +536,7 @@ struct cardstate {
543 dle encoded */ 536 dle encoded */
544 int cur_at_seq; /* sequence of AT commands being 537 int cur_at_seq; /* sequence of AT commands being
545 processed */ 538 processed */
546 int curchannel; /* channel, those commands are meant 539 int curchannel; /* channel those commands are meant
547 for */ 540 for */
548 atomic_t commands_pending; /* flag(s) in xxx.commands_pending have 541 atomic_t commands_pending; /* flag(s) in xxx.commands_pending have
549 been set */ 542 been set */
@@ -551,7 +544,7 @@ struct cardstate {
551 /* tasklet for serializing AT commands. 544 /* tasklet for serializing AT commands.
552 * Scheduled 545 * Scheduled
553 * -> for modem reponses (and 546 * -> for modem reponses (and
554 * incomming data for M10x) 547 * incoming data for M10x)
555 * -> on timeout 548 * -> on timeout
556 * -> after setting bits in 549 * -> after setting bits in
557 * xxx.at_state.pending_command 550 * xxx.at_state.pending_command
@@ -569,7 +562,7 @@ struct cardstate {
569 unsigned char respdata[MAX_RESP_SIZE]; 562 unsigned char respdata[MAX_RESP_SIZE];
570 unsigned cbytes; 563 unsigned cbytes;
571 564
572 /* hardware drivers */ 565 /* private data of hardware drivers */
573 union { 566 union {
574 struct usb_cardstate *usb; /* USB hardware driver (m105) */ 567 struct usb_cardstate *usb; /* USB hardware driver (m105) */
575 struct ser_cardstate *ser; /* serial hardware driver */ 568 struct ser_cardstate *ser; /* serial hardware driver */
@@ -607,36 +600,33 @@ struct bas_bc_state {
607 struct isow_urbctx_t isoouturbs[BAS_OUTURBS]; 600 struct isow_urbctx_t isoouturbs[BAS_OUTURBS];
608 struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl; 601 struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl;
609 struct isowbuf_t *isooutbuf; 602 struct isowbuf_t *isooutbuf;
610 unsigned numsub; /* submitted URB counter (for 603 unsigned numsub; /* submitted URB counter
611 diagnostic messages only) */ 604 (for diagnostic messages only) */
612 struct tasklet_struct sent_tasklet; 605 struct tasklet_struct sent_tasklet;
613 606
614 /* isochronous input state */ 607 /* isochronous input state */
615 spinlock_t isoinlock; 608 spinlock_t isoinlock;
616 struct urb *isoinurbs[BAS_INURBS]; 609 struct urb *isoinurbs[BAS_INURBS];
617 unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS]; 610 unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS];
618 struct urb *isoindone; /* completed isoc read URB */ 611 struct urb *isoindone; /* completed isoc read URB */
619 int loststatus; /* status of dropped URB */ 612 int loststatus; /* status of dropped URB */
620 unsigned isoinlost; /* number of bytes lost */ 613 unsigned isoinlost; /* number of bytes lost */
621 /* state of bit unstuffing algorithm (in addition to 614 /* state of bit unstuffing algorithm
622 BC_state.inputstate) */ 615 (in addition to BC_state.inputstate) */
623 unsigned seqlen; /* number of '1' bits not yet 616 unsigned seqlen; /* number of '1' bits not yet
624 unstuffed */ 617 unstuffed */
625 unsigned inbyte, inbits; /* collected bits for next byte 618 unsigned inbyte, inbits; /* collected bits for next byte */
626 */
627 /* statistics */ 619 /* statistics */
628 unsigned goodbytes; /* bytes correctly received */ 620 unsigned goodbytes; /* bytes correctly received */
629 unsigned alignerrs; /* frames with incomplete byte 621 unsigned alignerrs; /* frames with incomplete byte at end */
630 at end */ 622 unsigned fcserrs; /* FCS errors */
631 unsigned fcserrs; /* FCS errors */ 623 unsigned frameerrs; /* framing errors */
632 unsigned frameerrs; /* framing errors */ 624 unsigned giants; /* long frames */
633 unsigned giants; /* long frames */ 625 unsigned runts; /* short frames */
634 unsigned runts; /* short frames */ 626 unsigned aborts; /* HDLC aborts */
635 unsigned aborts; /* HDLC aborts */ 627 unsigned shared0s; /* '0' bits shared between flags */
636 unsigned shared0s; /* '0' bits shared between flags 628 unsigned stolen0s; /* '0' stuff bits also serving as
637 */ 629 leading flag bits */
638 unsigned stolen0s; /* '0' stuff bits also serving
639 as leading flag bits */
640 struct tasklet_struct rcvd_tasklet; 630 struct tasklet_struct rcvd_tasklet;
641}; 631};
642 632
@@ -644,8 +634,8 @@ struct gigaset_ops {
644 /* Called from ev-layer.c/interface.c for sending AT commands to the 634 /* Called from ev-layer.c/interface.c for sending AT commands to the
645 device */ 635 device */
646 int (*write_cmd)(struct cardstate *cs, 636 int (*write_cmd)(struct cardstate *cs,
647 const unsigned char *buf, int len, 637 const unsigned char *buf, int len,
648 struct tasklet_struct *wake_tasklet); 638 struct tasklet_struct *wake_tasklet);
649 639
650 /* Called from interface.c for additional device control */ 640 /* Called from interface.c for additional device control */
651 int (*write_room)(struct cardstate *cs); 641 int (*write_room)(struct cardstate *cs);
@@ -699,7 +689,7 @@ struct gigaset_ops {
699 * <DLE_FLAG>: 0x10 689 * <DLE_FLAG>: 0x10
700 * <EVENT>: ((a-z)* | (A-Z)* | (0-10)*)+ 690 * <EVENT>: ((a-z)* | (A-Z)* | (0-10)*)+
701 */ 691 */
702#define DLE_FLAG 0x10 692#define DLE_FLAG 0x10
703 693
704/* =========================================================================== 694/* ===========================================================================
705 * Functions implemented in asyncdata.c 695 * Functions implemented in asyncdata.c
@@ -764,7 +754,7 @@ static inline void gigaset_isdn_rcv_err(struct bc_state *bcs)
764 isdn_ctrl response; 754 isdn_ctrl response;
765 755
766 /* error -> LL */ 756 /* error -> LL */
767 dbg(DEBUG_CMD, "sending L1ERR"); 757 gig_dbg(DEBUG_CMD, "sending L1ERR");
768 response.driver = bcs->cs->myid; 758 response.driver = bcs->cs->myid;
769 response.command = ISDN_STAT_L1ERR; 759 response.command = ISDN_STAT_L1ERR;
770 response.arg = bcs->channel; 760 response.arg = bcs->channel;
@@ -797,7 +787,7 @@ void gigaset_free_dev_sysfs(struct usb_interface *interface);
797 787
798void gigaset_bcs_reinit(struct bc_state *bcs); 788void gigaset_bcs_reinit(struct bc_state *bcs);
799void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs, 789void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
800 struct cardstate *cs, int cid); 790 struct cardstate *cs, int cid);
801int gigaset_get_channel(struct bc_state *bcs); 791int gigaset_get_channel(struct bc_state *bcs);
802void gigaset_free_channel(struct bc_state *bcs); 792void gigaset_free_channel(struct bc_state *bcs);
803int gigaset_get_channels(struct cardstate *cs); 793int gigaset_get_channels(struct cardstate *cs);
@@ -806,11 +796,11 @@ void gigaset_block_channels(struct cardstate *cs);
806 796
807/* Allocate and initialize driver structure. */ 797/* Allocate and initialize driver structure. */
808struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, 798struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
809 const char *procname, 799 const char *procname,
810 const char *devname, 800 const char *devname,
811 const char *devfsname, 801 const char *devfsname,
812 const struct gigaset_ops *ops, 802 const struct gigaset_ops *ops,
813 struct module *owner); 803 struct module *owner);
814 804
815/* Deallocate driver structure. */ 805/* Deallocate driver structure. */
816void gigaset_freedriver(struct gigaset_driver *drv); 806void gigaset_freedriver(struct gigaset_driver *drv);
@@ -850,8 +840,8 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb);
850 * ptr must be kmalloc()ed (and not be freed by the caller). 840 * ptr must be kmalloc()ed (and not be freed by the caller).
851 */ 841 */
852struct event_t *gigaset_add_event(struct cardstate *cs, 842struct event_t *gigaset_add_event(struct cardstate *cs,
853 struct at_state_t *at_state, int type, 843 struct at_state_t *at_state, int type,
854 void *ptr, int parameter, void *arg); 844 void *ptr, int parameter, void *arg);
855 845
856/* Called on CONFIG1 command from frontend. */ 846/* Called on CONFIG1 command from frontend. */
857int gigaset_enterconfigmode(struct cardstate *cs); //0: success <0: errorcode 847int gigaset_enterconfigmode(struct cardstate *cs); //0: success <0: errorcode
@@ -872,7 +862,7 @@ static inline void gigaset_bchannel_down(struct bc_state *bcs)
872{ 862{
873 gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL); 863 gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL);
874 864
875 dbg(DEBUG_CMD, "scheduling BC_CLOSED"); 865 gig_dbg(DEBUG_CMD, "scheduling BC_CLOSED");
876 gigaset_schedule_event(bcs->cs); 866 gigaset_schedule_event(bcs->cs);
877} 867}
878 868
@@ -882,7 +872,7 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs)
882{ 872{
883 gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL); 873 gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL);
884 874
885 dbg(DEBUG_CMD, "scheduling BC_OPEN"); 875 gig_dbg(DEBUG_CMD, "scheduling BC_OPEN");
886 gigaset_schedule_event(bcs->cs); 876 gigaset_schedule_event(bcs->cs);
887} 877}
888 878
@@ -897,7 +887,7 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs)
897 * appropriate locks held only. 887 * appropriate locks held only.
898 */ 888 */
899static inline unsigned char *gigaset_skb_put_quick(struct sk_buff *skb, 889static inline unsigned char *gigaset_skb_put_quick(struct sk_buff *skb,
900 unsigned int len) 890 unsigned int len)
901{ 891{
902 unsigned char *tmp = skb->tail; 892 unsigned char *tmp = skb->tail;
903 /*SKB_LINEAR_ASSERT(skb);*/ /* not needed here */ 893 /*SKB_LINEAR_ASSERT(skb);*/ /* not needed here */
@@ -910,8 +900,8 @@ static inline unsigned char *gigaset_skb_put_quick(struct sk_buff *skb,
910 * Warning: skb must not be accessed anymore! 900 * Warning: skb must not be accessed anymore!
911 */ 901 */
912static inline void gigaset_rcv_skb(struct sk_buff *skb, 902static inline void gigaset_rcv_skb(struct sk_buff *skb,
913 struct cardstate *cs, 903 struct cardstate *cs,
914 struct bc_state *bcs) 904 struct bc_state *bcs)
915{ 905{
916 cs->iif.rcvcallb_skb(cs->myid, bcs->channel, skb); 906 cs->iif.rcvcallb_skb(cs->myid, bcs->channel, skb);
917 bcs->trans_down++; 907 bcs->trans_down++;
@@ -921,8 +911,8 @@ static inline void gigaset_rcv_skb(struct sk_buff *skb,
921 * Warning: skb must not be accessed anymore! 911 * Warning: skb must not be accessed anymore!
922 */ 912 */
923static inline void gigaset_rcv_error(struct sk_buff *procskb, 913static inline void gigaset_rcv_error(struct sk_buff *procskb,
924 struct cardstate *cs, 914 struct cardstate *cs,
925 struct bc_state *bcs) 915 struct bc_state *bcs)
926{ 916{
927 if (procskb) 917 if (procskb)
928 dev_kfree_skb(procskb); 918 dev_kfree_skb(procskb);
@@ -942,12 +932,12 @@ extern __u8 gigaset_invtab[]; /* in common.c */
942 932
943/* append received bytes to inbuf */ 933/* append received bytes to inbuf */
944static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf, 934static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
945 const unsigned char *src, 935 const unsigned char *src,
946 unsigned numbytes) 936 unsigned numbytes)
947{ 937{
948 unsigned n, head, tail, bytesleft; 938 unsigned n, head, tail, bytesleft;
949 939
950 dbg(DEBUG_INTR, "received %u bytes", numbytes); 940 gig_dbg(DEBUG_INTR, "received %u bytes", numbytes);
951 941
952 if (!numbytes) 942 if (!numbytes)
953 return 0; 943 return 0;
@@ -955,7 +945,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
955 bytesleft = numbytes; 945 bytesleft = numbytes;
956 tail = atomic_read(&inbuf->tail); 946 tail = atomic_read(&inbuf->tail);
957 head = atomic_read(&inbuf->head); 947 head = atomic_read(&inbuf->head);
958 dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); 948 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
959 949
960 while (bytesleft) { 950 while (bytesleft) {
961 if (head > tail) 951 if (head > tail)
@@ -965,7 +955,8 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
965 else 955 else
966 n = RBUFSIZE - tail; 956 n = RBUFSIZE - tail;
967 if (!n) { 957 if (!n) {
968 err("buffer overflow (%u bytes lost)", bytesleft); 958 dev_err(inbuf->cs->dev,
959 "buffer overflow (%u bytes lost)", bytesleft);
969 break; 960 break;
970 } 961 }
971 if (n > bytesleft) 962 if (n > bytesleft)
@@ -975,7 +966,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
975 tail = (tail + n) % RBUFSIZE; 966 tail = (tail + n) % RBUFSIZE;
976 src += n; 967 src += n;
977 } 968 }
978 dbg(DEBUG_INTR, "setting tail to %u", tail); 969 gig_dbg(DEBUG_INTR, "setting tail to %u", tail);
979 atomic_set(&inbuf->tail, tail); 970 atomic_set(&inbuf->tail, tail);
980 return numbytes != bytesleft; 971 return numbytes != bytesleft;
981} 972}
@@ -986,7 +977,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf,
986 977
987/* initialize interface */ 978/* initialize interface */
988void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, 979void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
989 const char *devname, const char *devfsname); 980 const char *devname, const char *devfsname);
990/* release interface */ 981/* release interface */
991void gigaset_if_freedriver(struct gigaset_driver *drv); 982void gigaset_if_freedriver(struct gigaset_driver *drv);
992/* add minor */ 983/* add minor */
@@ -995,6 +986,6 @@ void gigaset_if_init(struct cardstate *cs);
995void gigaset_if_free(struct cardstate *cs); 986void gigaset_if_free(struct cardstate *cs);
996/* device received data */ 987/* device received data */
997void gigaset_if_receive(struct cardstate *cs, 988void gigaset_if_receive(struct cardstate *cs,
998 unsigned char *buffer, size_t len); 989 unsigned char *buffer, size_t len);
999 990
1000#endif 991#endif
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c
index e30275d4e148..cc1d3093e433 100644
--- a/drivers/isdn/gigaset/i4l.c
+++ b/drivers/isdn/gigaset/i4l.c
@@ -15,7 +15,7 @@
15 15
16#include "gigaset.h" 16#include "gigaset.h"
17 17
18/* == Handling of I4L IO ============================================================================*/ 18/* == Handling of I4L IO =====================================================*/
19 19
20/* writebuf_from_LL 20/* writebuf_from_LL
21 * called by LL to transmit data on an open channel 21 * called by LL to transmit data on an open channel
@@ -33,7 +33,8 @@
33 * 0 if temporarily unable to accept data (out of buffer space) 33 * 0 if temporarily unable to accept data (out of buffer space)
34 * <0 on error (eg. -EINVAL) 34 * <0 on error (eg. -EINVAL)
35 */ 35 */
36static int writebuf_from_LL(int driverID, int channel, int ack, struct sk_buff *skb) 36static int writebuf_from_LL(int driverID, int channel, int ack,
37 struct sk_buff *skb)
37{ 38{
38 struct cardstate *cs; 39 struct cardstate *cs;
39 struct bc_state *bcs; 40 struct bc_state *bcs;
@@ -51,28 +52,30 @@ static int writebuf_from_LL(int driverID, int channel, int ack, struct sk_buff *
51 bcs = &cs->bcs[channel]; 52 bcs = &cs->bcs[channel];
52 len = skb->len; 53 len = skb->len;
53 54
54 dbg(DEBUG_LLDATA, 55 gig_dbg(DEBUG_LLDATA,
55 "Receiving data from LL (id: %d, channel: %d, ack: %d, size: %d)", 56 "Receiving data from LL (id: %d, ch: %d, ack: %d, sz: %d)",
56 driverID, channel, ack, len); 57 driverID, channel, ack, len);
58
59 if (!atomic_read(&cs->connected)) {
60 err("%s: disconnected", __func__);
61 return -ENODEV;
62 }
57 63
58 if (!len) { 64 if (!len) {
59 if (ack) 65 if (ack)
60 warn("not ACKing empty packet from LL"); 66 notice("%s: not ACKing empty packet", __func__);
61 return 0; 67 return 0;
62 } 68 }
63 if (len > MAX_BUF_SIZE) { 69 if (len > MAX_BUF_SIZE) {
64 err("%s: packet too large (%d bytes)", __func__, channel); 70 err("%s: packet too large (%d bytes)", __func__, len);
65 return -EINVAL; 71 return -EINVAL;
66 } 72 }
67 73
68 if (!atomic_read(&cs->connected))
69 return -ENODEV;
70
71 skblen = ack ? len : 0; 74 skblen = ack ? len : 0;
72 skb->head[0] = skblen & 0xff; 75 skb->head[0] = skblen & 0xff;
73 skb->head[1] = skblen >> 8; 76 skb->head[1] = skblen >> 8;
74 dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x", len, skblen, 77 gig_dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x",
75 (unsigned) skb->head[0], (unsigned) skb->head[1]); 78 len, skblen, (unsigned) skb->head[0], (unsigned) skb->head[1]);
76 79
77 /* pass to device-specific module */ 80 /* pass to device-specific module */
78 return cs->ops->send_skb(bcs, skb); 81 return cs->ops->send_skb(bcs, skb);
@@ -86,14 +89,14 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb)
86 ++bcs->trans_up; 89 ++bcs->trans_up;
87 90
88 if (skb->len) 91 if (skb->len)
89 warn("%s: skb->len==%d", __func__, skb->len); 92 dev_warn(bcs->cs->dev, "%s: skb->len==%d\n",
93 __func__, skb->len);
90 94
91 len = (unsigned char) skb->head[0] | 95 len = (unsigned char) skb->head[0] |
92 (unsigned) (unsigned char) skb->head[1] << 8; 96 (unsigned) (unsigned char) skb->head[1] << 8;
93 if (len) { 97 if (len) {
94 dbg(DEBUG_MCMD, 98 gig_dbg(DEBUG_MCMD, "ACKing to LL (id: %d, ch: %d, sz: %u)",
95 "Acknowledge sending to LL (id: %d, channel: %d size: %u)", 99 bcs->cs->myid, bcs->channel, len);
96 bcs->cs->myid, bcs->channel, len);
97 100
98 response.driver = bcs->cs->myid; 101 response.driver = bcs->cs->myid;
99 response.command = ISDN_STAT_BSENT; 102 response.command = ISDN_STAT_BSENT;
@@ -117,7 +120,6 @@ static int command_from_LL(isdn_ctrl *cntrl)
117 int retval = 0; 120 int retval = 0;
118 struct setup_parm *sp; 121 struct setup_parm *sp;
119 122
120 //dbg(DEBUG_ANY, "Gigaset_HW: Receiving command");
121 gigaset_debugdrivers(); 123 gigaset_debugdrivers();
122 124
123 //FIXME "remove test for &connected" 125 //FIXME "remove test for &connected"
@@ -129,29 +131,30 @@ static int command_from_LL(isdn_ctrl *cntrl)
129 131
130 switch (cntrl->command) { 132 switch (cntrl->command) {
131 case ISDN_CMD_IOCTL: 133 case ISDN_CMD_IOCTL:
132 134 gig_dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver: %d, arg: %ld)",
133 dbg(DEBUG_ANY, "ISDN_CMD_IOCTL (driver:%d,arg: %ld)", 135 cntrl->driver, cntrl->arg);
134 cntrl->driver, cntrl->arg);
135 136
136 warn("ISDN_CMD_IOCTL is not supported."); 137 warn("ISDN_CMD_IOCTL is not supported.");
137 return -EINVAL; 138 return -EINVAL;
138 139
139 case ISDN_CMD_DIAL: 140 case ISDN_CMD_DIAL:
140 dbg(DEBUG_ANY, "ISDN_CMD_DIAL (driver: %d, channel: %ld, " 141 gig_dbg(DEBUG_ANY,
141 "phone: %s,ownmsn: %s, si1: %d, si2: %d)", 142 "ISDN_CMD_DIAL (driver: %d, ch: %ld, "
142 cntrl->driver, cntrl->arg, 143 "phone: %s, ownmsn: %s, si1: %d, si2: %d)",
143 cntrl->parm.setup.phone, cntrl->parm.setup.eazmsn, 144 cntrl->driver, cntrl->arg,
144 cntrl->parm.setup.si1, cntrl->parm.setup.si2); 145 cntrl->parm.setup.phone, cntrl->parm.setup.eazmsn,
146 cntrl->parm.setup.si1, cntrl->parm.setup.si2);
145 147
146 if (cntrl->arg >= cs->channels) { 148 if (cntrl->arg >= cs->channels) {
147 err("invalid channel (%d)", (int) cntrl->arg); 149 err("ISDN_CMD_DIAL: invalid channel (%d)",
150 (int) cntrl->arg);
148 return -EINVAL; 151 return -EINVAL;
149 } 152 }
150 153
151 bcs = cs->bcs + cntrl->arg; 154 bcs = cs->bcs + cntrl->arg;
152 155
153 if (!gigaset_get_channel(bcs)) { 156 if (!gigaset_get_channel(bcs)) {
154 err("channel not free"); 157 err("ISDN_CMD_DIAL: channel not free");
155 return -EBUSY; 158 return -EBUSY;
156 } 159 }
157 160
@@ -164,41 +167,42 @@ static int command_from_LL(isdn_ctrl *cntrl)
164 *sp = cntrl->parm.setup; 167 *sp = cntrl->parm.setup;
165 168
166 if (!gigaset_add_event(cs, &bcs->at_state, EV_DIAL, sp, 169 if (!gigaset_add_event(cs, &bcs->at_state, EV_DIAL, sp,
167 atomic_read(&bcs->at_state.seq_index), 170 atomic_read(&bcs->at_state.seq_index),
168 NULL)) { 171 NULL)) {
169 //FIXME what should we do? 172 //FIXME what should we do?
170 kfree(sp); 173 kfree(sp);
171 gigaset_free_channel(bcs); 174 gigaset_free_channel(bcs);
172 return -ENOMEM; 175 return -ENOMEM;
173 } 176 }
174 177
175 dbg(DEBUG_CMD, "scheduling DIAL"); 178 gig_dbg(DEBUG_CMD, "scheduling DIAL");
176 gigaset_schedule_event(cs); 179 gigaset_schedule_event(cs);
177 break; 180 break;
178 case ISDN_CMD_ACCEPTD: //FIXME 181 case ISDN_CMD_ACCEPTD: //FIXME
179 dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD"); 182 gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTD");
180 183
181 if (cntrl->arg >= cs->channels) { 184 if (cntrl->arg >= cs->channels) {
182 err("invalid channel (%d)", (int) cntrl->arg); 185 err("ISDN_CMD_ACCEPTD: invalid channel (%d)",
186 (int) cntrl->arg);
183 return -EINVAL; 187 return -EINVAL;
184 } 188 }
185 189
186 if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg].at_state, 190 if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg].at_state,
187 EV_ACCEPT, NULL, 0, NULL)) { 191 EV_ACCEPT, NULL, 0, NULL)) {
188 //FIXME what should we do? 192 //FIXME what should we do?
189 return -ENOMEM; 193 return -ENOMEM;
190 } 194 }
191 195
192 dbg(DEBUG_CMD, "scheduling ACCEPT"); 196 gig_dbg(DEBUG_CMD, "scheduling ACCEPT");
193 gigaset_schedule_event(cs); 197 gigaset_schedule_event(cs);
194 198
195 break; 199 break;
196 case ISDN_CMD_ACCEPTB: 200 case ISDN_CMD_ACCEPTB:
197 dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTB"); 201 gig_dbg(DEBUG_ANY, "ISDN_CMD_ACCEPTB");
198 break; 202 break;
199 case ISDN_CMD_HANGUP: 203 case ISDN_CMD_HANGUP:
200 dbg(DEBUG_ANY, 204 gig_dbg(DEBUG_ANY, "ISDN_CMD_HANGUP (ch: %d)",
201 "ISDN_CMD_HANGUP (channel: %d)", (int) cntrl->arg); 205 (int) cntrl->arg);
202 206
203 if (cntrl->arg >= cs->channels) { 207 if (cntrl->arg >= cs->channels) {
204 err("ISDN_CMD_HANGUP: invalid channel (%u)", 208 err("ISDN_CMD_HANGUP: invalid channel (%u)",
@@ -207,66 +211,68 @@ static int command_from_LL(isdn_ctrl *cntrl)
207 } 211 }
208 212
209 if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg].at_state, 213 if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg].at_state,
210 EV_HUP, NULL, 0, NULL)) { 214 EV_HUP, NULL, 0, NULL)) {
211 //FIXME what should we do? 215 //FIXME what should we do?
212 return -ENOMEM; 216 return -ENOMEM;
213 } 217 }
214 218
215 dbg(DEBUG_CMD, "scheduling HUP"); 219 gig_dbg(DEBUG_CMD, "scheduling HUP");
216 gigaset_schedule_event(cs); 220 gigaset_schedule_event(cs);
217 221
218 break; 222 break;
219 case ISDN_CMD_CLREAZ: /* Do not signal incoming signals */ //FIXME 223 case ISDN_CMD_CLREAZ: /* Do not signal incoming signals */ //FIXME
220 dbg(DEBUG_ANY, "ISDN_CMD_CLREAZ"); 224 gig_dbg(DEBUG_ANY, "ISDN_CMD_CLREAZ");
221 break; 225 break;
222 case ISDN_CMD_SETEAZ: /* Signal incoming calls for given MSN */ //FIXME 226 case ISDN_CMD_SETEAZ: /* Signal incoming calls for given MSN */ //FIXME
223 dbg(DEBUG_ANY, 227 gig_dbg(DEBUG_ANY,
224 "ISDN_CMD_SETEAZ (id:%d, channel: %ld, number: %s)", 228 "ISDN_CMD_SETEAZ (id: %d, ch: %ld, number: %s)",
225 cntrl->driver, cntrl->arg, cntrl->parm.num); 229 cntrl->driver, cntrl->arg, cntrl->parm.num);
226 break; 230 break;
227 case ISDN_CMD_SETL2: /* Set L2 to given protocol */ 231 case ISDN_CMD_SETL2: /* Set L2 to given protocol */
228 dbg(DEBUG_ANY, "ISDN_CMD_SETL2 (Channel: %ld, Proto: %lx)", 232 gig_dbg(DEBUG_ANY, "ISDN_CMD_SETL2 (ch: %ld, proto: %lx)",
229 cntrl->arg & 0xff, (cntrl->arg >> 8)); 233 cntrl->arg & 0xff, (cntrl->arg >> 8));
230 234
231 if ((cntrl->arg & 0xff) >= cs->channels) { 235 if ((cntrl->arg & 0xff) >= cs->channels) {
232 err("invalid channel (%u)", 236 err("ISDN_CMD_SETL2: invalid channel (%u)",
233 (unsigned) cntrl->arg & 0xff); 237 (unsigned) cntrl->arg & 0xff);
234 return -EINVAL; 238 return -EINVAL;
235 } 239 }
236 240
237 if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg & 0xff].at_state, 241 if (!gigaset_add_event(cs, &cs->bcs[cntrl->arg & 0xff].at_state,
238 EV_PROTO_L2, NULL, cntrl->arg >> 8, 242 EV_PROTO_L2, NULL, cntrl->arg >> 8,
239 NULL)) { 243 NULL)) {
240 //FIXME what should we do? 244 //FIXME what should we do?
241 return -ENOMEM; 245 return -ENOMEM;
242 } 246 }
243 247
244 dbg(DEBUG_CMD, "scheduling PROTO_L2"); 248 gig_dbg(DEBUG_CMD, "scheduling PROTO_L2");
245 gigaset_schedule_event(cs); 249 gigaset_schedule_event(cs);
246 break; 250 break;
247 case ISDN_CMD_SETL3: /* Set L3 to given protocol */ 251 case ISDN_CMD_SETL3: /* Set L3 to given protocol */
248 dbg(DEBUG_ANY, "ISDN_CMD_SETL3 (Channel: %ld, Proto: %lx)", 252 gig_dbg(DEBUG_ANY, "ISDN_CMD_SETL3 (ch: %ld, proto: %lx)",
249 cntrl->arg & 0xff, (cntrl->arg >> 8)); 253 cntrl->arg & 0xff, (cntrl->arg >> 8));
250 254
251 if ((cntrl->arg & 0xff) >= cs->channels) { 255 if ((cntrl->arg & 0xff) >= cs->channels) {
252 err("invalid channel (%u)", 256 err("ISDN_CMD_SETL3: invalid channel (%u)",
253 (unsigned) cntrl->arg & 0xff); 257 (unsigned) cntrl->arg & 0xff);
254 return -EINVAL; 258 return -EINVAL;
255 } 259 }
256 260
257 if (cntrl->arg >> 8 != ISDN_PROTO_L3_TRANS) { 261 if (cntrl->arg >> 8 != ISDN_PROTO_L3_TRANS) {
258 err("invalid protocol %lu", cntrl->arg >> 8); 262 err("ISDN_CMD_SETL3: invalid protocol %lu",
263 cntrl->arg >> 8);
259 return -EINVAL; 264 return -EINVAL;
260 } 265 }
261 266
262 break; 267 break;
263 case ISDN_CMD_PROCEED: 268 case ISDN_CMD_PROCEED:
264 dbg(DEBUG_ANY, "ISDN_CMD_PROCEED"); //FIXME 269 gig_dbg(DEBUG_ANY, "ISDN_CMD_PROCEED"); //FIXME
265 break; 270 break;
266 case ISDN_CMD_ALERT: 271 case ISDN_CMD_ALERT:
267 dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME 272 gig_dbg(DEBUG_ANY, "ISDN_CMD_ALERT"); //FIXME
268 if (cntrl->arg >= cs->channels) { 273 if (cntrl->arg >= cs->channels) {
269 err("invalid channel (%d)", (int) cntrl->arg); 274 err("ISDN_CMD_ALERT: invalid channel (%d)",
275 (int) cntrl->arg);
270 return -EINVAL; 276 return -EINVAL;
271 } 277 }
272 //bcs = cs->bcs + cntrl->arg; 278 //bcs = cs->bcs + cntrl->arg;
@@ -274,32 +280,31 @@ static int command_from_LL(isdn_ctrl *cntrl)
274 // FIXME 280 // FIXME
275 break; 281 break;
276 case ISDN_CMD_REDIR: 282 case ISDN_CMD_REDIR:
277 dbg(DEBUG_ANY, "ISDN_CMD_REDIR"); //FIXME 283 gig_dbg(DEBUG_ANY, "ISDN_CMD_REDIR"); //FIXME
278 break; 284 break;
279 case ISDN_CMD_PROT_IO: 285 case ISDN_CMD_PROT_IO:
280 dbg(DEBUG_ANY, "ISDN_CMD_PROT_IO"); 286 gig_dbg(DEBUG_ANY, "ISDN_CMD_PROT_IO");
281 break; 287 break;
282 case ISDN_CMD_FAXCMD: 288 case ISDN_CMD_FAXCMD:
283 dbg(DEBUG_ANY, "ISDN_CMD_FAXCMD"); 289 gig_dbg(DEBUG_ANY, "ISDN_CMD_FAXCMD");
284 break; 290 break;
285 case ISDN_CMD_GETL2: 291 case ISDN_CMD_GETL2:
286 dbg(DEBUG_ANY, "ISDN_CMD_GETL2"); 292 gig_dbg(DEBUG_ANY, "ISDN_CMD_GETL2");
287 break; 293 break;
288 case ISDN_CMD_GETL3: 294 case ISDN_CMD_GETL3:
289 dbg(DEBUG_ANY, "ISDN_CMD_GETL3"); 295 gig_dbg(DEBUG_ANY, "ISDN_CMD_GETL3");
290 break; 296 break;
291 case ISDN_CMD_GETEAZ: 297 case ISDN_CMD_GETEAZ:
292 dbg(DEBUG_ANY, "ISDN_CMD_GETEAZ"); 298 gig_dbg(DEBUG_ANY, "ISDN_CMD_GETEAZ");
293 break; 299 break;
294 case ISDN_CMD_SETSIL: 300 case ISDN_CMD_SETSIL:
295 dbg(DEBUG_ANY, "ISDN_CMD_SETSIL"); 301 gig_dbg(DEBUG_ANY, "ISDN_CMD_SETSIL");
296 break; 302 break;
297 case ISDN_CMD_GETSIL: 303 case ISDN_CMD_GETSIL:
298 dbg(DEBUG_ANY, "ISDN_CMD_GETSIL"); 304 gig_dbg(DEBUG_ANY, "ISDN_CMD_GETSIL");
299 break; 305 break;
300 default: 306 default:
301 err("unknown command %d from LL", 307 err("unknown command %d from LL", cntrl->command);
302 cntrl->command);
303 return -EINVAL; 308 return -EINVAL;
304 } 309 }
305 310
@@ -344,7 +349,8 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
344 proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */ 349 proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */
345 break; 350 break;
346 default: 351 default:
347 err("invalid protocol: %u", bcs->proto2); 352 dev_err(bcs->cs->dev, "%s: invalid L2 protocol: %u\n",
353 __func__, bcs->proto2);
348 return -EINVAL; 354 return -EINVAL;
349 } 355 }
350 356
@@ -372,7 +378,7 @@ int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data)
372 bcs->commands[i] = NULL; 378 bcs->commands[i] = NULL;
373 if (length[i] && 379 if (length[i] &&
374 !(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) { 380 !(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) {
375 err("out of memory"); 381 dev_err(bcs->cs->dev, "out of memory\n");
376 return -ENOMEM; 382 return -ENOMEM;
377 } 383 }
378 } 384 }
@@ -417,7 +423,8 @@ int gigaset_isdn_setup_accept(struct at_state_t *at_state)
417 proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */ 423 proto = 2; /* 0: Bitsynchron, 1: HDLC, 2: voice */
418 break; 424 break;
419 default: 425 default:
420 err("invalid protocol: %u", bcs->proto2); 426 dev_err(at_state->cs->dev, "%s: invalid protocol: %u\n",
427 __func__, bcs->proto2);
421 return -EINVAL; 428 return -EINVAL;
422 } 429 }
423 430
@@ -434,7 +441,7 @@ int gigaset_isdn_setup_accept(struct at_state_t *at_state)
434 bcs->commands[i] = NULL; 441 bcs->commands[i] = NULL;
435 if (length[i] && 442 if (length[i] &&
436 !(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) { 443 !(bcs->commands[i] = kmalloc(length[i], GFP_ATOMIC))) {
437 err("out of memory"); 444 dev_err(at_state->cs->dev, "out of memory\n");
438 return -ENOMEM; 445 return -ENOMEM;
439 } 446 }
440 } 447 }
@@ -473,7 +480,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
473 response.parm.setup.si1 = 1; 480 response.parm.setup.si1 = 1;
474 response.parm.setup.si2 = 2; 481 response.parm.setup.si2 = 2;
475 } else { 482 } else {
476 warn("RING ignored - unsupported BC %s", 483 dev_warn(cs->dev, "RING ignored - unsupported BC %s\n",
477 at_state->str_var[STR_ZBC]); 484 at_state->str_var[STR_ZBC]);
478 return ICALL_IGNORE; 485 return ICALL_IGNORE;
479 } 486 }
@@ -491,18 +498,17 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
491 response.parm.setup.eazmsn[0] = 0; 498 response.parm.setup.eazmsn[0] = 0;
492 499
493 if (!bcs) { 500 if (!bcs) {
494 notice("no channel for incoming call"); 501 dev_notice(cs->dev, "no channel for incoming call\n");
495 dbg(DEBUG_CMD, "Sending ICALLW");
496 response.command = ISDN_STAT_ICALLW; 502 response.command = ISDN_STAT_ICALLW;
497 response.arg = 0; //FIXME 503 response.arg = 0; //FIXME
498 } else { 504 } else {
499 dbg(DEBUG_CMD, "Sending ICALL"); 505 gig_dbg(DEBUG_CMD, "Sending ICALL");
500 response.command = ISDN_STAT_ICALL; 506 response.command = ISDN_STAT_ICALL;
501 response.arg = bcs->channel; //FIXME 507 response.arg = bcs->channel; //FIXME
502 } 508 }
503 response.driver = cs->myid; 509 response.driver = cs->myid;
504 retval = cs->iif.statcallb(&response); 510 retval = cs->iif.statcallb(&response);
505 dbg(DEBUG_CMD, "Response: %d", retval); 511 gig_dbg(DEBUG_CMD, "Response: %d", retval);
506 switch (retval) { 512 switch (retval) {
507 case 0: /* no takers */ 513 case 0: /* no takers */
508 return ICALL_IGNORE; 514 return ICALL_IGNORE;
@@ -512,7 +518,8 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
512 case 2: /* reject */ 518 case 2: /* reject */
513 return ICALL_REJECT; 519 return ICALL_REJECT;
514 case 3: /* incomplete */ 520 case 3: /* incomplete */
515 warn("LL requested unsupported feature: Incomplete Number"); 521 dev_warn(cs->dev,
522 "LL requested unsupported feature: Incomplete Number\n");
516 return ICALL_IGNORE; 523 return ICALL_IGNORE;
517 case 4: /* proceeding */ 524 case 4: /* proceeding */
518 /* Gigaset will send ALERTING anyway. 525 /* Gigaset will send ALERTING anyway.
@@ -520,10 +527,11 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
520 */ 527 */
521 return ICALL_ACCEPT; 528 return ICALL_ACCEPT;
522 case 5: /* deflect */ 529 case 5: /* deflect */
523 warn("LL requested unsupported feature: Call Deflection"); 530 dev_warn(cs->dev,
531 "LL requested unsupported feature: Call Deflection\n");
524 return ICALL_IGNORE; 532 return ICALL_IGNORE;
525 default: 533 default:
526 err("LL error %d on ICALL", retval); 534 dev_err(cs->dev, "LL error %d on ICALL\n", retval);
527 return ICALL_IGNORE; 535 return ICALL_IGNORE;
528 } 536 }
529} 537}
@@ -533,7 +541,7 @@ int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid)
533{ 541{
534 isdn_if *iif = &cs->iif; 542 isdn_if *iif = &cs->iif;
535 543
536 dbg(DEBUG_ANY, "Register driver capabilities to LL"); 544 gig_dbg(DEBUG_ANY, "Register driver capabilities to LL");
537 545
538 //iif->id[sizeof(iif->id) - 1]=0; 546 //iif->id[sizeof(iif->id) - 1]=0;
539 //strncpy(iif->id, isdnid, sizeof(iif->id) - 1); 547 //strncpy(iif->id, isdnid, sizeof(iif->id) - 1);
@@ -551,17 +559,17 @@ int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid)
551#endif 559#endif
552 ISDN_FEATURE_L3_TRANS | 560 ISDN_FEATURE_L3_TRANS |
553 ISDN_FEATURE_P_EURO; 561 ISDN_FEATURE_P_EURO;
554 iif->hl_hdrlen = HW_HDR_LEN; /* Area for storing ack */ 562 iif->hl_hdrlen = HW_HDR_LEN; /* Area for storing ack */
555 iif->command = command_from_LL; 563 iif->command = command_from_LL;
556 iif->writebuf_skb = writebuf_from_LL; 564 iif->writebuf_skb = writebuf_from_LL;
557 iif->writecmd = NULL; /* Don't support isdnctrl */ 565 iif->writecmd = NULL; /* Don't support isdnctrl */
558 iif->readstat = NULL; /* Don't support isdnctrl */ 566 iif->readstat = NULL; /* Don't support isdnctrl */
559 iif->rcvcallb_skb = NULL; /* Will be set by LL */ 567 iif->rcvcallb_skb = NULL; /* Will be set by LL */
560 iif->statcallb = NULL; /* Will be set by LL */ 568 iif->statcallb = NULL; /* Will be set by LL */
561 569
562 if (!register_isdn(iif)) 570 if (!register_isdn(iif))
563 return 0; 571 return 0;
564 572
565 cs->myid = iif->channels; /* Set my device id */ 573 cs->myid = iif->channels; /* Set my device id */
566 return 1; 574 return 1;
567} 575}
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index c225de9620b1..f3dce8c4831b 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -22,7 +22,7 @@ static int if_lock(struct cardstate *cs, int *arg)
22{ 22{
23 int cmd = *arg; 23 int cmd = *arg;
24 24
25 dbg(DEBUG_IF, "%u: if_lock (%d)", cs->minor_index, cmd); 25 gig_dbg(DEBUG_IF, "%u: if_lock (%d)", cs->minor_index, cmd);
26 26
27 if (cmd > 1) 27 if (cmd > 1)
28 return -EINVAL; 28 return -EINVAL;
@@ -42,12 +42,12 @@ static int if_lock(struct cardstate *cs, int *arg)
42 42
43 cs->waiting = 1; 43 cs->waiting = 1;
44 if (!gigaset_add_event(cs, &cs->at_state, EV_IF_LOCK, 44 if (!gigaset_add_event(cs, &cs->at_state, EV_IF_LOCK,
45 NULL, cmd, NULL)) { 45 NULL, cmd, NULL)) {
46 cs->waiting = 0; 46 cs->waiting = 0;
47 return -ENOMEM; 47 return -ENOMEM;
48 } 48 }
49 49
50 dbg(DEBUG_CMD, "scheduling IF_LOCK"); 50 gig_dbg(DEBUG_CMD, "scheduling IF_LOCK");
51 gigaset_schedule_event(cs); 51 gigaset_schedule_event(cs);
52 52
53 wait_event(cs->waitqueue, !cs->waiting); 53 wait_event(cs->waitqueue, !cs->waiting);
@@ -66,7 +66,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
66 static const unsigned compat[4] = GIG_COMPAT; 66 static const unsigned compat[4] = GIG_COMPAT;
67 unsigned cmd = arg[0]; 67 unsigned cmd = arg[0];
68 68
69 dbg(DEBUG_IF, "%u: if_version (%d)", cs->minor_index, cmd); 69 gig_dbg(DEBUG_IF, "%u: if_version (%d)", cs->minor_index, cmd);
70 70
71 switch (cmd) { 71 switch (cmd) {
72 case GIGVER_DRIVER: 72 case GIGVER_DRIVER:
@@ -78,12 +78,12 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
78 case GIGVER_FWBASE: 78 case GIGVER_FWBASE:
79 cs->waiting = 1; 79 cs->waiting = 1;
80 if (!gigaset_add_event(cs, &cs->at_state, EV_IF_VER, 80 if (!gigaset_add_event(cs, &cs->at_state, EV_IF_VER,
81 NULL, 0, arg)) { 81 NULL, 0, arg)) {
82 cs->waiting = 0; 82 cs->waiting = 0;
83 return -ENOMEM; 83 return -ENOMEM;
84 } 84 }
85 85
86 dbg(DEBUG_CMD, "scheduling IF_VER"); 86 gig_dbg(DEBUG_CMD, "scheduling IF_VER");
87 gigaset_schedule_event(cs); 87 gigaset_schedule_event(cs);
88 88
89 wait_event(cs->waitqueue, !cs->waiting); 89 wait_event(cs->waitqueue, !cs->waiting);
@@ -99,7 +99,7 @@ static int if_version(struct cardstate *cs, unsigned arg[4])
99 99
100static int if_config(struct cardstate *cs, int *arg) 100static int if_config(struct cardstate *cs, int *arg)
101{ 101{
102 dbg(DEBUG_IF, "%u: if_config (%d)", cs->minor_index, *arg); 102 gig_dbg(DEBUG_IF, "%u: if_config (%d)", cs->minor_index, *arg);
103 103
104 if (*arg != 1) 104 if (*arg != 1)
105 return -EINVAL; 105 return -EINVAL;
@@ -117,7 +117,7 @@ static int if_config(struct cardstate *cs, int *arg)
117static int if_open(struct tty_struct *tty, struct file *filp); 117static int if_open(struct tty_struct *tty, struct file *filp);
118static void if_close(struct tty_struct *tty, struct file *filp); 118static void if_close(struct tty_struct *tty, struct file *filp);
119static int if_ioctl(struct tty_struct *tty, struct file *file, 119static int if_ioctl(struct tty_struct *tty, struct file *file,
120 unsigned int cmd, unsigned long arg); 120 unsigned int cmd, unsigned long arg);
121static int if_write_room(struct tty_struct *tty); 121static int if_write_room(struct tty_struct *tty);
122static int if_chars_in_buffer(struct tty_struct *tty); 122static int if_chars_in_buffer(struct tty_struct *tty);
123static void if_throttle(struct tty_struct *tty); 123static void if_throttle(struct tty_struct *tty);
@@ -125,9 +125,9 @@ static void if_unthrottle(struct tty_struct *tty);
125static void if_set_termios(struct tty_struct *tty, struct termios *old); 125static void if_set_termios(struct tty_struct *tty, struct termios *old);
126static int if_tiocmget(struct tty_struct *tty, struct file *file); 126static int if_tiocmget(struct tty_struct *tty, struct file *file);
127static int if_tiocmset(struct tty_struct *tty, struct file *file, 127static int if_tiocmset(struct tty_struct *tty, struct file *file,
128 unsigned int set, unsigned int clear); 128 unsigned int set, unsigned int clear);
129static int if_write(struct tty_struct *tty, 129static int if_write(struct tty_struct *tty,
130 const unsigned char *buf, int count); 130 const unsigned char *buf, int count);
131 131
132static struct tty_operations if_ops = { 132static struct tty_operations if_ops = {
133 .open = if_open, 133 .open = if_open,
@@ -151,8 +151,8 @@ static int if_open(struct tty_struct *tty, struct file *filp)
151 struct cardstate *cs; 151 struct cardstate *cs;
152 unsigned long flags; 152 unsigned long flags;
153 153
154 dbg(DEBUG_IF, "%d+%d: %s()", tty->driver->minor_start, tty->index, 154 gig_dbg(DEBUG_IF, "%d+%d: %s()",
155 __FUNCTION__); 155 tty->driver->minor_start, tty->index, __func__);
156 156
157 tty->driver_data = NULL; 157 tty->driver_data = NULL;
158 158
@@ -184,16 +184,16 @@ static void if_close(struct tty_struct *tty, struct file *filp)
184 184
185 cs = (struct cardstate *) tty->driver_data; 185 cs = (struct cardstate *) tty->driver_data;
186 if (!cs) { 186 if (!cs) {
187 err("cs==NULL in %s", __FUNCTION__); 187 err("cs==NULL in %s", __func__);
188 return; 188 return;
189 } 189 }
190 190
191 dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); 191 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
192 192
193 down(&cs->sem); 193 down(&cs->sem);
194 194
195 if (!cs->open_count) 195 if (!cs->open_count)
196 warn("%s: device not opened", __FUNCTION__); 196 warn("%s: device not opened", __func__);
197 else { 197 else {
198 if (!--cs->open_count) { 198 if (!--cs->open_count) {
199 spin_lock_irqsave(&cs->lock, flags); 199 spin_lock_irqsave(&cs->lock, flags);
@@ -206,7 +206,7 @@ static void if_close(struct tty_struct *tty, struct file *filp)
206} 206}
207 207
208static int if_ioctl(struct tty_struct *tty, struct file *file, 208static int if_ioctl(struct tty_struct *tty, struct file *file,
209 unsigned int cmd, unsigned long arg) 209 unsigned int cmd, unsigned long arg)
210{ 210{
211 struct cardstate *cs; 211 struct cardstate *cs;
212 int retval = -ENODEV; 212 int retval = -ENODEV;
@@ -216,17 +216,17 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
216 216
217 cs = (struct cardstate *) tty->driver_data; 217 cs = (struct cardstate *) tty->driver_data;
218 if (!cs) { 218 if (!cs) {
219 err("cs==NULL in %s", __FUNCTION__); 219 err("cs==NULL in %s", __func__);
220 return -ENODEV; 220 return -ENODEV;
221 } 221 }
222 222
223 dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __FUNCTION__, cmd); 223 gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd);
224 224
225 if (down_interruptible(&cs->sem)) 225 if (down_interruptible(&cs->sem))
226 return -ERESTARTSYS; // FIXME -EINTR? 226 return -ERESTARTSYS; // FIXME -EINTR?
227 227
228 if (!cs->open_count) 228 if (!cs->open_count)
229 warn("%s: device not opened", __FUNCTION__); 229 warn("%s: device not opened", __func__);
230 else { 230 else {
231 retval = 0; 231 retval = 0;
232 switch (cmd) { 232 switch (cmd) {
@@ -247,33 +247,33 @@ static int if_ioctl(struct tty_struct *tty, struct file *file,
247 case GIGASET_BRKCHARS: 247 case GIGASET_BRKCHARS:
248 //FIXME test if MS_LOCKED 248 //FIXME test if MS_LOCKED
249 gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", 249 gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS",
250 6, (const unsigned char *) arg, 1); 250 6, (const unsigned char *) arg, 1);
251 if (!atomic_read(&cs->connected)) { 251 if (!atomic_read(&cs->connected)) {
252 dbg(DEBUG_ANY, 252 gig_dbg(DEBUG_ANY,
253 "can't communicate with unplugged device"); 253 "can't communicate with unplugged device");
254 retval = -ENODEV; 254 retval = -ENODEV;
255 break; 255 break;
256 } 256 }
257 retval = copy_from_user(&buf, 257 retval = copy_from_user(&buf,
258 (const unsigned char __user *) arg, 6) 258 (const unsigned char __user *) arg, 6)
259 ? -EFAULT : 0; 259 ? -EFAULT : 0;
260 if (retval >= 0) 260 if (retval >= 0)
261 retval = cs->ops->brkchars(cs, buf); 261 retval = cs->ops->brkchars(cs, buf);
262 break; 262 break;
263 case GIGASET_VERSION: 263 case GIGASET_VERSION:
264 retval = copy_from_user(version, 264 retval = copy_from_user(version,
265 (unsigned __user *) arg, 265 (unsigned __user *) arg, sizeof version)
266 sizeof version) ? -EFAULT : 0; 266 ? -EFAULT : 0;
267 if (retval >= 0) 267 if (retval >= 0)
268 retval = if_version(cs, version); 268 retval = if_version(cs, version);
269 if (retval >= 0) 269 if (retval >= 0)
270 retval = copy_to_user((unsigned __user *) arg, 270 retval = copy_to_user((unsigned __user *) arg,
271 version, sizeof version) 271 version, sizeof version)
272 ? -EFAULT : 0; 272 ? -EFAULT : 0;
273 break; 273 break;
274 default: 274 default:
275 dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x", 275 gig_dbg(DEBUG_ANY, "%s: arg not supported - 0x%04x",
276 __FUNCTION__, cmd); 276 __func__, cmd);
277 retval = -ENOIOCTLCMD; 277 retval = -ENOIOCTLCMD;
278 } 278 }
279 } 279 }
@@ -290,11 +290,11 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file)
290 290
291 cs = (struct cardstate *) tty->driver_data; 291 cs = (struct cardstate *) tty->driver_data;
292 if (!cs) { 292 if (!cs) {
293 err("cs==NULL in %s", __FUNCTION__); 293 err("cs==NULL in %s", __func__);
294 return -ENODEV; 294 return -ENODEV;
295 } 295 }
296 296
297 dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); 297 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
298 298
299 if (down_interruptible(&cs->sem)) 299 if (down_interruptible(&cs->sem))
300 return -ERESTARTSYS; // FIXME -EINTR? 300 return -ERESTARTSYS; // FIXME -EINTR?
@@ -308,7 +308,7 @@ static int if_tiocmget(struct tty_struct *tty, struct file *file)
308} 308}
309 309
310static int if_tiocmset(struct tty_struct *tty, struct file *file, 310static int if_tiocmset(struct tty_struct *tty, struct file *file,
311 unsigned int set, unsigned int clear) 311 unsigned int set, unsigned int clear)
312{ 312{
313 struct cardstate *cs; 313 struct cardstate *cs;
314 int retval; 314 int retval;
@@ -316,18 +316,18 @@ static int if_tiocmset(struct tty_struct *tty, struct file *file,
316 316
317 cs = (struct cardstate *) tty->driver_data; 317 cs = (struct cardstate *) tty->driver_data;
318 if (!cs) { 318 if (!cs) {
319 err("cs==NULL in %s", __FUNCTION__); 319 err("cs==NULL in %s", __func__);
320 return -ENODEV; 320 return -ENODEV;
321 } 321 }
322 322
323 dbg(DEBUG_IF, 323 gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)",
324 "%u: %s(0x%x, 0x%x)", cs->minor_index, __FUNCTION__, set, clear); 324 cs->minor_index, __func__, set, clear);
325 325
326 if (down_interruptible(&cs->sem)) 326 if (down_interruptible(&cs->sem))
327 return -ERESTARTSYS; // FIXME -EINTR? 327 return -ERESTARTSYS; // FIXME -EINTR?
328 328
329 if (!atomic_read(&cs->connected)) { 329 if (!atomic_read(&cs->connected)) {
330 dbg(DEBUG_ANY, "can't communicate with unplugged device"); 330 gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
331 retval = -ENODEV; 331 retval = -ENODEV;
332 } else { 332 } else {
333 mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR); 333 mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR);
@@ -347,26 +347,26 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
347 347
348 cs = (struct cardstate *) tty->driver_data; 348 cs = (struct cardstate *) tty->driver_data;
349 if (!cs) { 349 if (!cs) {
350 err("cs==NULL in %s", __FUNCTION__); 350 err("cs==NULL in %s", __func__);
351 return -ENODEV; 351 return -ENODEV;
352 } 352 }
353 353
354 dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); 354 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
355 355
356 if (down_interruptible(&cs->sem)) 356 if (down_interruptible(&cs->sem))
357 return -ERESTARTSYS; // FIXME -EINTR? 357 return -ERESTARTSYS; // FIXME -EINTR?
358 358
359 if (!cs->open_count) 359 if (!cs->open_count)
360 warn("%s: device not opened", __FUNCTION__); 360 warn("%s: device not opened", __func__);
361 else if (atomic_read(&cs->mstate) != MS_LOCKED) { 361 else if (atomic_read(&cs->mstate) != MS_LOCKED) {
362 warn("can't write to unlocked device"); 362 warn("can't write to unlocked device");
363 retval = -EBUSY; 363 retval = -EBUSY;
364 } else if (!atomic_read(&cs->connected)) { 364 } else if (!atomic_read(&cs->connected)) {
365 dbg(DEBUG_ANY, "can't write to unplugged device"); 365 gig_dbg(DEBUG_ANY, "can't write to unplugged device");
366 retval = -EBUSY; //FIXME 366 retval = -EBUSY; //FIXME
367 } else { 367 } else {
368 retval = cs->ops->write_cmd(cs, buf, count, 368 retval = cs->ops->write_cmd(cs, buf, count,
369 &cs->if_wake_tasklet); 369 &cs->if_wake_tasklet);
370 } 370 }
371 371
372 up(&cs->sem); 372 up(&cs->sem);
@@ -381,22 +381,22 @@ static int if_write_room(struct tty_struct *tty)
381 381
382 cs = (struct cardstate *) tty->driver_data; 382 cs = (struct cardstate *) tty->driver_data;
383 if (!cs) { 383 if (!cs) {
384 err("cs==NULL in %s", __FUNCTION__); 384 err("cs==NULL in %s", __func__);
385 return -ENODEV; 385 return -ENODEV;
386 } 386 }
387 387
388 dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); 388 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
389 389
390 if (down_interruptible(&cs->sem)) 390 if (down_interruptible(&cs->sem))
391 return -ERESTARTSYS; // FIXME -EINTR? 391 return -ERESTARTSYS; // FIXME -EINTR?
392 392
393 if (!cs->open_count) 393 if (!cs->open_count)
394 warn("%s: device not opened", __FUNCTION__); 394 warn("%s: device not opened", __func__);
395 else if (atomic_read(&cs->mstate) != MS_LOCKED) { 395 else if (atomic_read(&cs->mstate) != MS_LOCKED) {
396 warn("can't write to unlocked device"); 396 warn("can't write to unlocked device");
397 retval = -EBUSY; //FIXME 397 retval = -EBUSY; //FIXME
398 } else if (!atomic_read(&cs->connected)) { 398 } else if (!atomic_read(&cs->connected)) {
399 dbg(DEBUG_ANY, "can't write to unplugged device"); 399 gig_dbg(DEBUG_ANY, "can't write to unplugged device");
400 retval = -EBUSY; //FIXME 400 retval = -EBUSY; //FIXME
401 } else 401 } else
402 retval = cs->ops->write_room(cs); 402 retval = cs->ops->write_room(cs);
@@ -413,22 +413,22 @@ static int if_chars_in_buffer(struct tty_struct *tty)
413 413
414 cs = (struct cardstate *) tty->driver_data; 414 cs = (struct cardstate *) tty->driver_data;
415 if (!cs) { 415 if (!cs) {
416 err("cs==NULL in %s", __FUNCTION__); 416 err("cs==NULL in %s", __func__);
417 return -ENODEV; 417 return -ENODEV;
418 } 418 }
419 419
420 dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); 420 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
421 421
422 if (down_interruptible(&cs->sem)) 422 if (down_interruptible(&cs->sem))
423 return -ERESTARTSYS; // FIXME -EINTR? 423 return -ERESTARTSYS; // FIXME -EINTR?
424 424
425 if (!cs->open_count) 425 if (!cs->open_count)
426 warn("%s: device not opened", __FUNCTION__); 426 warn("%s: device not opened", __func__);
427 else if (atomic_read(&cs->mstate) != MS_LOCKED) { 427 else if (atomic_read(&cs->mstate) != MS_LOCKED) {
428 warn("can't write to unlocked device"); 428 warn("can't write to unlocked device");
429 retval = -EBUSY; 429 retval = -EBUSY;
430 } else if (!atomic_read(&cs->connected)) { 430 } else if (!atomic_read(&cs->connected)) {
431 dbg(DEBUG_ANY, "can't write to unplugged device"); 431 gig_dbg(DEBUG_ANY, "can't write to unplugged device");
432 retval = -EBUSY; //FIXME 432 retval = -EBUSY; //FIXME
433 } else 433 } else
434 retval = cs->ops->chars_in_buffer(cs); 434 retval = cs->ops->chars_in_buffer(cs);
@@ -444,16 +444,16 @@ static void if_throttle(struct tty_struct *tty)
444 444
445 cs = (struct cardstate *) tty->driver_data; 445 cs = (struct cardstate *) tty->driver_data;
446 if (!cs) { 446 if (!cs) {
447 err("cs==NULL in %s", __FUNCTION__); 447 err("cs==NULL in %s", __func__);
448 return; 448 return;
449 } 449 }
450 450
451 dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); 451 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
452 452
453 down(&cs->sem); 453 down(&cs->sem);
454 454
455 if (!cs->open_count) 455 if (!cs->open_count)
456 warn("%s: device not opened", __FUNCTION__); 456 warn("%s: device not opened", __func__);
457 else { 457 else {
458 //FIXME 458 //FIXME
459 } 459 }
@@ -467,16 +467,16 @@ static void if_unthrottle(struct tty_struct *tty)
467 467
468 cs = (struct cardstate *) tty->driver_data; 468 cs = (struct cardstate *) tty->driver_data;
469 if (!cs) { 469 if (!cs) {
470 err("cs==NULL in %s", __FUNCTION__); 470 err("cs==NULL in %s", __func__);
471 return; 471 return;
472 } 472 }
473 473
474 dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); 474 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
475 475
476 down(&cs->sem); 476 down(&cs->sem);
477 477
478 if (!cs->open_count) 478 if (!cs->open_count)
479 warn("%s: device not opened", __FUNCTION__); 479 warn("%s: device not opened", __func__);
480 else { 480 else {
481 //FIXME 481 //FIXME
482 } 482 }
@@ -494,21 +494,21 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
494 494
495 cs = (struct cardstate *) tty->driver_data; 495 cs = (struct cardstate *) tty->driver_data;
496 if (!cs) { 496 if (!cs) {
497 err("cs==NULL in %s", __FUNCTION__); 497 err("cs==NULL in %s", __func__);
498 return; 498 return;
499 } 499 }
500 500
501 dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __FUNCTION__); 501 gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
502 502
503 down(&cs->sem); 503 down(&cs->sem);
504 504
505 if (!cs->open_count) { 505 if (!cs->open_count) {
506 warn("%s: device not opened", __FUNCTION__); 506 warn("%s: device not opened", __func__);
507 goto out; 507 goto out;
508 } 508 }
509 509
510 if (!atomic_read(&cs->connected)) { 510 if (!atomic_read(&cs->connected)) {
511 dbg(DEBUG_ANY, "can't communicate with unplugged device"); 511 gig_dbg(DEBUG_ANY, "can't communicate with unplugged device");
512 goto out; 512 goto out;
513 } 513 }
514 514
@@ -516,8 +516,8 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
516 iflag = tty->termios->c_iflag; 516 iflag = tty->termios->c_iflag;
517 cflag = tty->termios->c_cflag; 517 cflag = tty->termios->c_cflag;
518 old_cflag = old ? old->c_cflag : cflag; //FIXME? 518 old_cflag = old ? old->c_cflag : cflag; //FIXME?
519 dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x", cs->minor_index, 519 gig_dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x",
520 iflag, cflag, old_cflag); 520 cs->minor_index, iflag, cflag, old_cflag);
521 521
522 /* get a local copy of the current port settings */ 522 /* get a local copy of the current port settings */
523 control_state = cs->control_state; 523 control_state = cs->control_state;
@@ -529,14 +529,15 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
529 * Premature optimization is the root of all evil. 529 * Premature optimization is the root of all evil.
530 */ 530 */
531 531
532 /* reassert DTR and (maybe) RTS on transition from B0 */ 532 /* reassert DTR and (maybe) RTS on transition from B0 */
533 if ((old_cflag & CBAUD) == B0) { 533 if ((old_cflag & CBAUD) == B0) {
534 new_state = control_state | TIOCM_DTR; 534 new_state = control_state | TIOCM_DTR;
535 /* don't set RTS if using hardware flow control */ 535 /* don't set RTS if using hardware flow control */
536 if (!(old_cflag & CRTSCTS)) 536 if (!(old_cflag & CRTSCTS))
537 new_state |= TIOCM_RTS; 537 new_state |= TIOCM_RTS;
538 dbg(DEBUG_IF, "%u: from B0 - set DTR%s", cs->minor_index, 538 gig_dbg(DEBUG_IF, "%u: from B0 - set DTR%s",
539 (new_state & TIOCM_RTS) ? " only" : "/RTS"); 539 cs->minor_index,
540 (new_state & TIOCM_RTS) ? " only" : "/RTS");
540 cs->ops->set_modem_ctrl(cs, control_state, new_state); 541 cs->ops->set_modem_ctrl(cs, control_state, new_state);
541 control_state = new_state; 542 control_state = new_state;
542 } 543 }
@@ -545,7 +546,7 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
545 546
546 if ((cflag & CBAUD) == B0) { 547 if ((cflag & CBAUD) == B0) {
547 /* Drop RTS and DTR */ 548 /* Drop RTS and DTR */
548 dbg(DEBUG_IF, "%u: to B0 - drop DTR/RTS", cs->minor_index); 549 gig_dbg(DEBUG_IF, "%u: to B0 - drop DTR/RTS", cs->minor_index);
549 new_state = control_state & ~(TIOCM_DTR | TIOCM_RTS); 550 new_state = control_state & ~(TIOCM_DTR | TIOCM_RTS);
550 cs->ops->set_modem_ctrl(cs, control_state, new_state); 551 cs->ops->set_modem_ctrl(cs, control_state, new_state);
551 control_state = new_state; 552 control_state = new_state;
@@ -565,14 +566,16 @@ static void if_set_termios(struct tty_struct *tty, struct termios *old)
565 * Just do what we have seen with SniffUSB on Win98. 566 * Just do what we have seen with SniffUSB on Win98.
566 */ 567 */
567 /* Drop DTR/RTS if no flow control otherwise assert */ 568 /* Drop DTR/RTS if no flow control otherwise assert */
568 dbg(DEBUG_IF, "%u: control_state %x", cs->minor_index, control_state); 569 gig_dbg(DEBUG_IF, "%u: control_state %x",
570 cs->minor_index, control_state);
569 new_state = control_state; 571 new_state = control_state;
570 if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS)) 572 if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS))
571 new_state |= TIOCM_DTR | TIOCM_RTS; 573 new_state |= TIOCM_DTR | TIOCM_RTS;
572 else 574 else
573 new_state &= ~(TIOCM_DTR | TIOCM_RTS); 575 new_state &= ~(TIOCM_DTR | TIOCM_RTS);
574 if (new_state != control_state) { 576 if (new_state != control_state) {
575 dbg(DEBUG_IF, "%u: new_state %x", cs->minor_index, new_state); 577 gig_dbg(DEBUG_IF, "%u: new_state %x",
578 cs->minor_index, new_state);
576 gigaset_set_modem_ctrl(cs, control_state, new_state); 579 gigaset_set_modem_ctrl(cs, control_state, new_state);
577 control_state = new_state; 580 control_state = new_state;
578 } 581 }
@@ -598,7 +601,7 @@ static void if_wake(unsigned long data)
598 601
599 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 602 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
600 tty->ldisc.write_wakeup) { 603 tty->ldisc.write_wakeup) {
601 dbg(DEBUG_IF, "write wakeup call"); 604 gig_dbg(DEBUG_IF, "write wakeup call");
602 tty->ldisc.write_wakeup(tty); 605 tty->ldisc.write_wakeup(tty);
603 } 606 }
604 607
@@ -633,14 +636,14 @@ void gigaset_if_free(struct cardstate *cs)
633} 636}
634 637
635void gigaset_if_receive(struct cardstate *cs, 638void gigaset_if_receive(struct cardstate *cs,
636 unsigned char *buffer, size_t len) 639 unsigned char *buffer, size_t len)
637{ 640{
638 unsigned long flags; 641 unsigned long flags;
639 struct tty_struct *tty; 642 struct tty_struct *tty;
640 643
641 spin_lock_irqsave(&cs->lock, flags); 644 spin_lock_irqsave(&cs->lock, flags);
642 if ((tty = cs->tty) == NULL) 645 if ((tty = cs->tty) == NULL)
643 dbg(DEBUG_ANY, "receive on closed device"); 646 gig_dbg(DEBUG_ANY, "receive on closed device");
644 else { 647 else {
645 tty_buffer_request_room(tty, len); 648 tty_buffer_request_room(tty, len);
646 tty_insert_flip_string(tty, buffer, len); 649 tty_insert_flip_string(tty, buffer, len);
@@ -653,13 +656,13 @@ EXPORT_SYMBOL_GPL(gigaset_if_receive);
653/* gigaset_if_initdriver 656/* gigaset_if_initdriver
654 * Initialize tty interface. 657 * Initialize tty interface.
655 * parameters: 658 * parameters:
656 * drv Driver 659 * drv Driver
657 * procname Name of the driver (e.g. for /proc/tty/drivers) 660 * procname Name of the driver (e.g. for /proc/tty/drivers)
658 * devname Name of the device files (prefix without minor number) 661 * devname Name of the device files (prefix without minor number)
659 * devfsname Devfs name of the device files without %d 662 * devfsname Devfs name of the device files without %d
660 */ 663 */
661void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, 664void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
662 const char *devname, const char *devfsname) 665 const char *devname, const char *devfsname)
663{ 666{
664 unsigned minors = drv->minors; 667 unsigned minors = drv->minors;
665 int ret; 668 int ret;
@@ -694,7 +697,7 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
694 warn("failed to register tty driver (error %d)", ret); 697 warn("failed to register tty driver (error %d)", ret);
695 goto error; 698 goto error;
696 } 699 }
697 dbg(DEBUG_IF, "tty driver initialized"); 700 gig_dbg(DEBUG_IF, "tty driver initialized");
698 drv->have_tty = 1; 701 drv->have_tty = 1;
699 return; 702 return;
700 703
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index e2d93e935530..4a00d22c496e 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -83,14 +83,14 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
83{ 83{
84 if (!atomic_dec_and_test(&iwb->writesem)) { 84 if (!atomic_dec_and_test(&iwb->writesem)) {
85 atomic_inc(&iwb->writesem); 85 atomic_inc(&iwb->writesem);
86 dbg(DEBUG_ISO, 86 gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore",
87 "%s: couldn't acquire iso write semaphore", __func__); 87 __func__);
88 return 0; 88 return 0;
89 } 89 }
90#ifdef CONFIG_GIGASET_DEBUG 90#ifdef CONFIG_GIGASET_DEBUG
91 dbg(DEBUG_ISO, 91 gig_dbg(DEBUG_ISO,
92 "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d", 92 "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
93 __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits); 93 __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits);
94#endif 94#endif
95 return 1; 95 return 1;
96} 96}
@@ -143,7 +143,7 @@ static inline void isowbuf_putflag(struct isowbuf_t *iwb)
143 /* recover the idle flag byte */ 143 /* recover the idle flag byte */
144 write = atomic_read(&iwb->write); 144 write = atomic_read(&iwb->write);
145 iwb->idle = iwb->data[write]; 145 iwb->idle = iwb->data[write];
146 dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle); 146 gig_dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle);
147 /* mask extraneous bits in buffer */ 147 /* mask extraneous bits in buffer */
148 iwb->data[write] &= (1 << iwb->wbits) - 1; 148 iwb->data[write] &= (1 << iwb->wbits) - 1;
149} 149}
@@ -162,15 +162,14 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
162 read = atomic_read(&iwb->nextread); 162 read = atomic_read(&iwb->nextread);
163 write = atomic_read(&iwb->write); 163 write = atomic_read(&iwb->write);
164 if (likely(read == write)) { 164 if (likely(read == write)) {
165 //dbg(DEBUG_STREAM, "%s: send buffer empty", __func__);
166 /* return idle frame */ 165 /* return idle frame */
167 return read < BAS_OUTBUFPAD ? 166 return read < BAS_OUTBUFPAD ?
168 BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD; 167 BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD;
169 } 168 }
170 169
171 limit = read + size; 170 limit = read + size;
172 dbg(DEBUG_STREAM, 171 gig_dbg(DEBUG_STREAM, "%s: read=%d write=%d limit=%d",
173 "%s: read=%d write=%d limit=%d", __func__, read, write, limit); 172 __func__, read, write, limit);
174#ifdef CONFIG_GIGASET_DEBUG 173#ifdef CONFIG_GIGASET_DEBUG
175 if (unlikely(size < 0 || size > BAS_OUTBUFPAD)) { 174 if (unlikely(size < 0 || size > BAS_OUTBUFPAD)) {
176 err("invalid size %d", size); 175 err("invalid size %d", size);
@@ -195,9 +194,9 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
195 pbyte = iwb->data[write]; /* save 194 pbyte = iwb->data[write]; /* save
196 partial byte */ 195 partial byte */
197 limit = write + BAS_OUTBUFPAD; 196 limit = write + BAS_OUTBUFPAD;
198 dbg(DEBUG_STREAM, 197 gig_dbg(DEBUG_STREAM,
199 "%s: filling %d->%d with %02x", 198 "%s: filling %d->%d with %02x",
200 __func__, write, limit, iwb->idle); 199 __func__, write, limit, iwb->idle);
201 if (write + BAS_OUTBUFPAD < BAS_OUTBUFSIZE) 200 if (write + BAS_OUTBUFPAD < BAS_OUTBUFSIZE)
202 memset(iwb->data + write, iwb->idle, 201 memset(iwb->data + write, iwb->idle,
203 BAS_OUTBUFPAD); 202 BAS_OUTBUFPAD);
@@ -208,8 +207,9 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
208 - write); 207 - write);
209 limit = 0; 208 limit = 0;
210 } 209 }
211 dbg(DEBUG_STREAM, "%s: restoring %02x at %d", 210 gig_dbg(DEBUG_STREAM,
212 __func__, pbyte, limit); 211 "%s: restoring %02x at %d",
212 __func__, pbyte, limit);
213 iwb->data[limit] = pbyte; /* restore 213 iwb->data[limit] = pbyte; /* restore
214 partial byte */ 214 partial byte */
215 atomic_set(&iwb->write, limit); 215 atomic_set(&iwb->write, limit);
@@ -240,7 +240,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
240 * write hex bytes to syslog for debugging 240 * write hex bytes to syslog for debugging
241 */ 241 */
242static inline void dump_bytes(enum debuglevel level, const char *tag, 242static inline void dump_bytes(enum debuglevel level, const char *tag,
243 unsigned char *bytes, int count) 243 unsigned char *bytes, int count)
244{ 244{
245#ifdef CONFIG_GIGASET_DEBUG 245#ifdef CONFIG_GIGASET_DEBUG
246 unsigned char c; 246 unsigned char c;
@@ -252,7 +252,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
252 while (count-- > 0) { 252 while (count-- > 0) {
253 if (i > sizeof(dbgline) - 4) { 253 if (i > sizeof(dbgline) - 4) {
254 dbgline[i] = '\0'; 254 dbgline[i] = '\0';
255 dbg(level, "%s:%s", tag, dbgline); 255 gig_dbg(level, "%s:%s", tag, dbgline);
256 i = 0; 256 i = 0;
257 } 257 }
258 c = *bytes++; 258 c = *bytes++;
@@ -262,7 +262,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
262 dbgline[i++] = hexdigit[c & 0x0f]; 262 dbgline[i++] = hexdigit[c & 0x0f];
263 } 263 }
264 dbgline[i] = '\0'; 264 dbgline[i] = '\0';
265 dbg(level, "%s:%s", tag, dbgline); 265 gig_dbg(level, "%s:%s", tag, dbgline);
266#endif 266#endif
267} 267}
268 268
@@ -378,7 +378,7 @@ static u16 stufftab[5 * 256] = {
378 */ 378 */
379 379
380static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin, 380static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin,
381 int ones) 381 int ones)
382{ 382{
383 u16 stuff; 383 u16 stuff;
384 int shiftinc, newones; 384 int shiftinc, newones;
@@ -420,7 +420,7 @@ static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin,
420 */ 420 */
421 421
422static inline int hdlc_buildframe(struct isowbuf_t *iwb, 422static inline int hdlc_buildframe(struct isowbuf_t *iwb,
423 unsigned char *in, int count) 423 unsigned char *in, int count)
424{ 424{
425 int ones; 425 int ones;
426 u16 fcs; 426 u16 fcs;
@@ -429,8 +429,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
429 429
430 if (isowbuf_freebytes(iwb) < count + count / 5 + 6 || 430 if (isowbuf_freebytes(iwb) < count + count / 5 + 6 ||
431 !isowbuf_startwrite(iwb)) { 431 !isowbuf_startwrite(iwb)) {
432 dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN", 432 gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
433 __func__, isowbuf_freebytes(iwb)); 433 __func__, isowbuf_freebytes(iwb));
434 return -EAGAIN; 434 return -EAGAIN;
435 } 435 }
436 436
@@ -482,11 +482,11 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
482 482
483 if (isowbuf_freebytes(iwb) < count || 483 if (isowbuf_freebytes(iwb) < count ||
484 !isowbuf_startwrite(iwb)) { 484 !isowbuf_startwrite(iwb)) {
485 dbg(DEBUG_ISO, "can't put %d bytes", count); 485 gig_dbg(DEBUG_ISO, "can't put %d bytes", count);
486 return -EAGAIN; 486 return -EAGAIN;
487 } 487 }
488 488
489 dbg(DEBUG_STREAM, "put %d bytes", count); 489 gig_dbg(DEBUG_STREAM, "put %d bytes", count);
490 write = atomic_read(&iwb->write); 490 write = atomic_read(&iwb->write);
491 do { 491 do {
492 c = gigaset_invtab[*in++]; 492 c = gigaset_invtab[*in++];
@@ -506,13 +506,13 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len)
506 switch (bcs->proto2) { 506 switch (bcs->proto2) {
507 case ISDN_PROTO_L2_HDLC: 507 case ISDN_PROTO_L2_HDLC:
508 result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len); 508 result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len);
509 dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d", 509 gig_dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d",
510 __func__, len, result); 510 __func__, len, result);
511 break; 511 break;
512 default: /* assume transparent */ 512 default: /* assume transparent */
513 result = trans_buildframe(bcs->hw.bas->isooutbuf, in, len); 513 result = trans_buildframe(bcs->hw.bas->isooutbuf, in, len);
514 dbg(DEBUG_ISO, "%s: %d bytes trans -> %d", 514 gig_dbg(DEBUG_ISO, "%s: %d bytes trans -> %d",
515 __func__, len, result); 515 __func__, len, result);
516 } 516 }
517 return result; 517 return result;
518} 518}
@@ -528,7 +528,7 @@ static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
528 return; 528 return;
529 } 529 }
530 if (unlikely(bcs->skb->len == SBUFSIZE)) { 530 if (unlikely(bcs->skb->len == SBUFSIZE)) {
531 warn("received oversized packet discarded"); 531 dev_warn(bcs->cs->dev, "received oversized packet discarded\n");
532 bcs->hw.bas->giants++; 532 bcs->hw.bas->giants++;
533 dev_kfree_skb_any(bcs->skb); 533 dev_kfree_skb_any(bcs->skb);
534 bcs->skb = NULL; 534 bcs->skb = NULL;
@@ -549,7 +549,7 @@ static inline void hdlc_flush(struct bc_state *bcs)
549 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 549 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
550 skb_reserve(bcs->skb, HW_HDR_LEN); 550 skb_reserve(bcs->skb, HW_HDR_LEN);
551 else 551 else
552 err("could not allocate skb"); 552 dev_err(bcs->cs->dev, "could not allocate skb\n");
553 } 553 }
554 554
555 /* reset packet state */ 555 /* reset packet state */
@@ -571,23 +571,25 @@ static inline void hdlc_done(struct bc_state *bcs)
571 571
572 if ((procskb = bcs->skb) == NULL) { 572 if ((procskb = bcs->skb) == NULL) {
573 /* previous error */ 573 /* previous error */
574 dbg(DEBUG_ISO, "%s: skb=NULL", __func__); 574 gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
575 gigaset_rcv_error(NULL, bcs->cs, bcs); 575 gigaset_rcv_error(NULL, bcs->cs, bcs);
576 } else if (procskb->len < 2) { 576 } else if (procskb->len < 2) {
577 notice("received short frame (%d octets)", procskb->len); 577 dev_notice(bcs->cs->dev, "received short frame (%d octets)\n",
578 procskb->len);
578 bcs->hw.bas->runts++; 579 bcs->hw.bas->runts++;
579 gigaset_rcv_error(procskb, bcs->cs, bcs); 580 gigaset_rcv_error(procskb, bcs->cs, bcs);
580 } else if (bcs->fcs != PPP_GOODFCS) { 581 } else if (bcs->fcs != PPP_GOODFCS) {
581 notice("frame check error (0x%04x)", bcs->fcs); 582 dev_notice(bcs->cs->dev, "frame check error (0x%04x)\n",
583 bcs->fcs);
582 bcs->hw.bas->fcserrs++; 584 bcs->hw.bas->fcserrs++;
583 gigaset_rcv_error(procskb, bcs->cs, bcs); 585 gigaset_rcv_error(procskb, bcs->cs, bcs);
584 } else { 586 } else {
585 procskb->len -= 2; /* subtract FCS */ 587 procskb->len -= 2; /* subtract FCS */
586 procskb->tail -= 2; 588 procskb->tail -= 2;
587 dbg(DEBUG_ISO, 589 gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)",
588 "%s: good frame (%d octets)", __func__, procskb->len); 590 __func__, procskb->len);
589 dump_bytes(DEBUG_STREAM, 591 dump_bytes(DEBUG_STREAM,
590 "rcv data", procskb->data, procskb->len); 592 "rcv data", procskb->data, procskb->len);
591 bcs->hw.bas->goodbytes += procskb->len; 593 bcs->hw.bas->goodbytes += procskb->len;
592 gigaset_rcv_skb(procskb, bcs->cs, bcs); 594 gigaset_rcv_skb(procskb, bcs->cs, bcs);
593 } 595 }
@@ -595,7 +597,7 @@ static inline void hdlc_done(struct bc_state *bcs)
595 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 597 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
596 skb_reserve(bcs->skb, HW_HDR_LEN); 598 skb_reserve(bcs->skb, HW_HDR_LEN);
597 else 599 else
598 err("could not allocate skb"); 600 dev_err(bcs->cs->dev, "could not allocate skb\n");
599 bcs->fcs = PPP_INITFCS; 601 bcs->fcs = PPP_INITFCS;
600} 602}
601 603
@@ -610,14 +612,14 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
610 return; 612 return;
611 } 613 }
612 614
613 notice("received partial byte (%d bits)", inbits); 615 dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits);
614 bcs->hw.bas->alignerrs++; 616 bcs->hw.bas->alignerrs++;
615 gigaset_rcv_error(bcs->skb, bcs->cs, bcs); 617 gigaset_rcv_error(bcs->skb, bcs->cs, bcs);
616 618
617 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 619 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
618 skb_reserve(bcs->skb, HW_HDR_LEN); 620 skb_reserve(bcs->skb, HW_HDR_LEN);
619 else 621 else
620 err("could not allocate skb"); 622 dev_err(bcs->cs->dev, "could not allocate skb\n");
621 bcs->fcs = PPP_INITFCS; 623 bcs->fcs = PPP_INITFCS;
622} 624}
623 625
@@ -659,7 +661,7 @@ static unsigned char bitcounts[256] = {
659 * bcs receiving B channel structure 661 * bcs receiving B channel structure
660 */ 662 */
661static inline void hdlc_unpack(unsigned char *src, unsigned count, 663static inline void hdlc_unpack(unsigned char *src, unsigned count,
662 struct bc_state *bcs) 664 struct bc_state *bcs)
663{ 665{
664 struct bas_bc_state *ubc; 666 struct bas_bc_state *ubc;
665 int inputstate; 667 int inputstate;
@@ -856,7 +858,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
856 * bcs receiving B channel structure 858 * bcs receiving B channel structure
857 */ 859 */
858static inline void trans_receive(unsigned char *src, unsigned count, 860static inline void trans_receive(unsigned char *src, unsigned count,
859 struct bc_state *bcs) 861 struct bc_state *bcs)
860{ 862{
861 struct sk_buff *skb; 863 struct sk_buff *skb;
862 int dobytes; 864 int dobytes;
@@ -870,7 +872,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
870 if (unlikely((skb = bcs->skb) == NULL)) { 872 if (unlikely((skb = bcs->skb) == NULL)) {
871 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); 873 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
872 if (!skb) { 874 if (!skb) {
873 err("could not allocate skb"); 875 dev_err(bcs->cs->dev, "could not allocate skb\n");
874 return; 876 return;
875 } 877 }
876 skb_reserve(skb, HW_HDR_LEN); 878 skb_reserve(skb, HW_HDR_LEN);
@@ -888,7 +890,8 @@ static inline void trans_receive(unsigned char *src, unsigned count,
888 gigaset_rcv_skb(skb, bcs->cs, bcs); 890 gigaset_rcv_skb(skb, bcs->cs, bcs);
889 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); 891 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
890 if (!skb) { 892 if (!skb) {
891 err("could not allocate skb"); 893 dev_err(bcs->cs->dev,
894 "could not allocate skb\n");
892 return; 895 return;
893 } 896 }
894 skb_reserve(bcs->skb, HW_HDR_LEN); 897 skb_reserve(bcs->skb, HW_HDR_LEN);
@@ -921,8 +924,8 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
921 case '\r': 924 case '\r':
922 case '\n': 925 case '\n':
923 /* end of line */ 926 /* end of line */
924 dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)", 927 gig_dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
925 __func__, cbytes); 928 __func__, cbytes);
926 cs->cbytes = cbytes; 929 cs->cbytes = cbytes;
927 gigaset_handle_modem_response(cs); 930 gigaset_handle_modem_response(cs);
928 cbytes = 0; 931 cbytes = 0;
@@ -932,7 +935,7 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
932 if (cbytes < MAX_RESP_SIZE - 1) 935 if (cbytes < MAX_RESP_SIZE - 1)
933 cbytes++; 936 cbytes++;
934 else 937 else
935 warn("response too large"); 938 dev_warn(cs->dev, "response too large\n");
936 } 939 }
937 } 940 }
938 941
@@ -951,27 +954,27 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
951 954
952 head = atomic_read(&inbuf->head); 955 head = atomic_read(&inbuf->head);
953 while (head != (tail = atomic_read(&inbuf->tail))) { 956 while (head != (tail = atomic_read(&inbuf->tail))) {
954 dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); 957 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
955 if (head > tail) 958 if (head > tail)
956 tail = RBUFSIZE; 959 tail = RBUFSIZE;
957 src = inbuf->data + head; 960 src = inbuf->data + head;
958 numbytes = tail - head; 961 numbytes = tail - head;
959 dbg(DEBUG_INTR, "processing %u bytes", numbytes); 962 gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
960 963
961 if (atomic_read(&cs->mstate) == MS_LOCKED) { 964 if (atomic_read(&cs->mstate) == MS_LOCKED) {
962 gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response", 965 gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response",
963 numbytes, src, 0); 966 numbytes, src, 0);
964 gigaset_if_receive(inbuf->cs, src, numbytes); 967 gigaset_if_receive(inbuf->cs, src, numbytes);
965 } else { 968 } else {
966 gigaset_dbg_buffer(DEBUG_CMD, "received response", 969 gigaset_dbg_buffer(DEBUG_CMD, "received response",
967 numbytes, src, 0); 970 numbytes, src, 0);
968 cmd_loop(src, numbytes, inbuf); 971 cmd_loop(src, numbytes, inbuf);
969 } 972 }
970 973
971 head += numbytes; 974 head += numbytes;
972 if (head == RBUFSIZE) 975 if (head == RBUFSIZE)
973 head = 0; 976 head = 0;
974 dbg(DEBUG_INTR, "setting head to %u", head); 977 gig_dbg(DEBUG_INTR, "setting head to %u", head);
975 atomic_set(&inbuf->head, head); 978 atomic_set(&inbuf->head, head);
976 } 979 }
977} 980}
@@ -999,8 +1002,8 @@ int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb)
999 len = skb->len; 1002 len = skb->len;
1000 1003
1001 skb_queue_tail(&bcs->squeue, skb); 1004 skb_queue_tail(&bcs->squeue, skb);
1002 dbg(DEBUG_ISO, 1005 gig_dbg(DEBUG_ISO, "%s: skb queued, qlen=%d",
1003 "%s: skb queued, qlen=%d", __func__, skb_queue_len(&bcs->squeue)); 1006 __func__, skb_queue_len(&bcs->squeue));
1004 1007
1005 /* tasklet submits URB if necessary */ 1008 /* tasklet submits URB if necessary */
1006 tasklet_schedule(&bcs->hw.bas->sent_tasklet); 1009 tasklet_schedule(&bcs->hw.bas->sent_tasklet);
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c
index c30ea80d517a..695495ad0668 100644
--- a/drivers/isdn/gigaset/proc.c
+++ b/drivers/isdn/gigaset/proc.c
@@ -44,13 +44,13 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
44 44
45 cs->waiting = 1; 45 cs->waiting = 1;
46 if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE, 46 if (!gigaset_add_event(cs, &cs->at_state, EV_PROC_CIDMODE,
47 NULL, value, NULL)) { 47 NULL, value, NULL)) {
48 cs->waiting = 0; 48 cs->waiting = 0;
49 up(&cs->sem); 49 up(&cs->sem);
50 return -ENOMEM; 50 return -ENOMEM;
51 } 51 }
52 52
53 dbg(DEBUG_CMD, "scheduling PROC_CIDMODE"); 53 gig_dbg(DEBUG_CMD, "scheduling PROC_CIDMODE");
54 gigaset_schedule_event(cs); 54 gigaset_schedule_event(cs);
55 55
56 wait_event(cs->waitqueue, !cs->waiting); 56 wait_event(cs->waitqueue, !cs->waiting);
@@ -65,7 +65,7 @@ static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
65/* free sysfs for device */ 65/* free sysfs for device */
66void gigaset_free_dev_sysfs(struct usb_interface *interface) 66void gigaset_free_dev_sysfs(struct usb_interface *interface)
67{ 67{
68 dbg(DEBUG_INIT, "removing sysfs entries"); 68 gig_dbg(DEBUG_INIT, "removing sysfs entries");
69 device_remove_file(&interface->dev, &dev_attr_cidmode); 69 device_remove_file(&interface->dev, &dev_attr_cidmode);
70} 70}
71EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs); 71EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs);
@@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(gigaset_free_dev_sysfs);
73/* initialize sysfs for device */ 73/* initialize sysfs for device */
74void gigaset_init_dev_sysfs(struct usb_interface *interface) 74void gigaset_init_dev_sysfs(struct usb_interface *interface)
75{ 75{
76 dbg(DEBUG_INIT, "setting up sysfs"); 76 gig_dbg(DEBUG_INIT, "setting up sysfs");
77 device_create_file(&interface->dev, &dev_attr_cidmode); 77 device_create_file(&interface->dev, &dev_attr_cidmode);
78} 78}
79EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs); 79EXPORT_SYMBOL_GPL(gigaset_init_dev_sysfs);
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 0f5aa46cf8f3..f09d821b6e89 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -106,7 +106,7 @@ MODULE_DEVICE_TABLE(usb, gigaset_table);
106 */ 106 */
107 107
108static int gigaset_probe(struct usb_interface *interface, 108static int gigaset_probe(struct usb_interface *interface,
109 const struct usb_device_id *id); 109 const struct usb_device_id *id);
110static void gigaset_disconnect(struct usb_interface *interface); 110static void gigaset_disconnect(struct usb_interface *interface);
111 111
112static struct gigaset_driver *driver = NULL; 112static struct gigaset_driver *driver = NULL;
@@ -126,17 +126,17 @@ struct usb_cardstate {
126 atomic_t busy; /* bulk output in progress */ 126 atomic_t busy; /* bulk output in progress */
127 127
128 /* Output buffer */ 128 /* Output buffer */
129 unsigned char *bulk_out_buffer; /* send buffer */ 129 unsigned char *bulk_out_buffer;
130 int bulk_out_size; /* send buffer size */ 130 int bulk_out_size;
131 __u8 bulk_out_endpointAddr; /* bulk out endpoint */ 131 __u8 bulk_out_endpointAddr;
132 struct urb *bulk_out_urb; /* bulk out urb */ 132 struct urb *bulk_out_urb;
133 133
134 /* Input buffer */ 134 /* Input buffer */
135 int rcvbuf_size; /* rcv buffer */ 135 int rcvbuf_size;
136 struct urb *read_urb; /* rcv buffer size */ 136 struct urb *read_urb;
137 __u8 int_in_endpointAddr; /* int in endpoint */ 137 __u8 int_in_endpointAddr;
138 138
139 char bchars[6]; /* request 0x19 */ 139 char bchars[6]; /* for request 0x19 */
140}; 140};
141 141
142struct usb_bc_state {}; 142struct usb_bc_state {};
@@ -149,20 +149,20 @@ static inline unsigned tiocm_to_gigaset(unsigned state)
149#ifdef CONFIG_GIGASET_UNDOCREQ 149#ifdef CONFIG_GIGASET_UNDOCREQ
150/* WARNING: EXPERIMENTAL! */ 150/* WARNING: EXPERIMENTAL! */
151static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, 151static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
152 unsigned new_state) 152 unsigned new_state)
153{ 153{
154 struct usb_device *udev = cs->hw.usb->udev;
154 unsigned mask, val; 155 unsigned mask, val;
155 int r; 156 int r;
156 157
157 mask = tiocm_to_gigaset(old_state ^ new_state); 158 mask = tiocm_to_gigaset(old_state ^ new_state);
158 val = tiocm_to_gigaset(new_state); 159 val = tiocm_to_gigaset(new_state);
159 160
160 dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask); 161 gig_dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask);
161 // don't use this in an interrupt/BH 162 // don't use this in an interrupt/BH
162 r = usb_control_msg(cs->hw.usb->udev, 163 r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 7, 0x41,
163 usb_sndctrlpipe(cs->hw.usb->udev, 0), 7, 0x41, 164 (val & 0xff) | ((mask & 0xff) << 8), 0,
164 (val & 0xff) | ((mask & 0xff) << 8), 0, 165 NULL, 0, 2000 /* timeout? */);
165 NULL, 0, 2000 /* timeout? */);
166 if (r < 0) 166 if (r < 0)
167 return r; 167 return r;
168 //.. 168 //..
@@ -171,30 +171,29 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
171 171
172static int set_value(struct cardstate *cs, u8 req, u16 val) 172static int set_value(struct cardstate *cs, u8 req, u16 val)
173{ 173{
174 struct usb_device *udev = cs->hw.usb->udev;
174 int r, r2; 175 int r, r2;
175 176
176 dbg(DEBUG_USBREQ, "request %02x (%04x)", (unsigned)req, (unsigned)val); 177 gig_dbg(DEBUG_USBREQ, "request %02x (%04x)",
177 r = usb_control_msg(cs->hw.usb->udev, 178 (unsigned)req, (unsigned)val);
178 usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x12, 0x41, 179 r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x12, 0x41,
179 0xf /*?*/, 0, 180 0xf /*?*/, 0, NULL, 0, 2000 /*?*/);
180 NULL, 0, 2000 /*?*/); /* no idea, what this does */ 181 /* no idea what this does */
181 if (r < 0) { 182 if (r < 0) {
182 err("error %d on request 0x12", -r); 183 dev_err(&udev->dev, "error %d on request 0x12\n", -r);
183 return r; 184 return r;
184 } 185 }
185 186
186 r = usb_control_msg(cs->hw.usb->udev, 187 r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), req, 0x41,
187 usb_sndctrlpipe(cs->hw.usb->udev, 0), req, 0x41, 188 val, 0, NULL, 0, 2000 /*?*/);
188 val, 0,
189 NULL, 0, 2000 /*?*/);
190 if (r < 0) 189 if (r < 0)
191 err("error %d on request 0x%02x", -r, (unsigned)req); 190 dev_err(&udev->dev, "error %d on request 0x%02x\n",
191 -r, (unsigned)req);
192 192
193 r2 = usb_control_msg(cs->hw.usb->udev, 193 r2 = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
194 usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x19, 0x41, 194 0, 0, cs->hw.usb->bchars, 6, 2000 /*?*/);
195 0, 0, cs->hw.usb->bchars, 6, 2000 /*?*/);
196 if (r2 < 0) 195 if (r2 < 0)
197 err("error %d on request 0x19", -r2); 196 dev_err(&udev->dev, "error %d on request 0x19\n", -r2);
198 197
199 return r < 0 ? r : (r2 < 0 ? r2 : 0); 198 return r < 0 ? r : (r2 < 0 ? r2 : 0);
200} 199}
@@ -222,8 +221,8 @@ static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag)
222 case B115200: rate = 115200; break; 221 case B115200: rate = 115200; break;
223 default: 222 default:
224 rate = 9600; 223 rate = 9600;
225 err("unsupported baudrate request 0x%x," 224 dev_err(cs->dev, "unsupported baudrate request 0x%x,"
226 " using default of B9600", cflag); 225 " using default of B9600\n", cflag);
227 } 226 }
228 227
229 val = 0x383fff / rate + 1; 228 val = 0x383fff / rate + 1;
@@ -252,7 +251,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
252 case CS8: 251 case CS8:
253 val |= 8 << 8; break; 252 val |= 8 << 8; break;
254 default: 253 default:
255 err("CSIZE was not CS5-CS8, using default of 8"); 254 dev_err(cs->dev, "CSIZE was not CS5-CS8, using default of 8\n");
256 val |= 8 << 8; 255 val |= 8 << 8;
257 break; 256 break;
258 } 257 }
@@ -270,7 +269,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
270 269
271#else 270#else
272static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, 271static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
273 unsigned new_state) 272 unsigned new_state)
274{ 273{
275 return -EINVAL; 274 return -EINVAL;
276} 275}
@@ -317,10 +316,10 @@ static void gigaset_modem_fill(unsigned long data)
317 unsigned long flags; 316 unsigned long flags;
318 int again; 317 int again;
319 318
320 dbg(DEBUG_OUTPUT, "modem_fill"); 319 gig_dbg(DEBUG_OUTPUT, "modem_fill");
321 320
322 if (atomic_read(&cs->hw.usb->busy)) { 321 if (atomic_read(&cs->hw.usb->busy)) {
323 dbg(DEBUG_OUTPUT, "modem_fill: busy"); 322 gig_dbg(DEBUG_OUTPUT, "modem_fill: busy");
324 return; 323 return;
325 } 324 }
326 325
@@ -331,27 +330,27 @@ static void gigaset_modem_fill(unsigned long data)
331 cb = cs->cmdbuf; 330 cb = cs->cmdbuf;
332 spin_unlock_irqrestore(&cs->cmdlock, flags); 331 spin_unlock_irqrestore(&cs->cmdlock, flags);
333 if (cb) { /* commands to send? */ 332 if (cb) { /* commands to send? */
334 dbg(DEBUG_OUTPUT, "modem_fill: cb"); 333 gig_dbg(DEBUG_OUTPUT, "modem_fill: cb");
335 if (send_cb(cs, cb) < 0) { 334 if (send_cb(cs, cb) < 0) {
336 dbg(DEBUG_OUTPUT, 335 gig_dbg(DEBUG_OUTPUT,
337 "modem_fill: send_cb failed"); 336 "modem_fill: send_cb failed");
338 again = 1; /* no callback will be 337 again = 1; /* no callback will be
339 called! */ 338 called! */
340 } 339 }
341 } else { /* skbs to send? */ 340 } else { /* skbs to send? */
342 bcs->tx_skb = skb_dequeue(&bcs->squeue); 341 bcs->tx_skb = skb_dequeue(&bcs->squeue);
343 if (bcs->tx_skb) 342 if (bcs->tx_skb)
344 dbg(DEBUG_INTR, 343 gig_dbg(DEBUG_INTR,
345 "Dequeued skb (Adr: %lx)!", 344 "Dequeued skb (Adr: %lx)!",
346 (unsigned long) bcs->tx_skb); 345 (unsigned long) bcs->tx_skb);
347 } 346 }
348 } 347 }
349 348
350 if (bcs->tx_skb) { 349 if (bcs->tx_skb) {
351 dbg(DEBUG_OUTPUT, "modem_fill: tx_skb"); 350 gig_dbg(DEBUG_OUTPUT, "modem_fill: tx_skb");
352 if (write_modem(cs) < 0) { 351 if (write_modem(cs) < 0) {
353 dbg(DEBUG_OUTPUT, 352 gig_dbg(DEBUG_OUTPUT,
354 "modem_fill: write_modem failed"); 353 "modem_fill: write_modem failed");
355 // FIXME should we tell the LL? 354 // FIXME should we tell the LL?
356 again = 1; /* no callback will be called! */ 355 again = 1; /* no callback will be called! */
357 } 356 }
@@ -362,7 +361,7 @@ static void gigaset_modem_fill(unsigned long data)
362/** 361/**
363 * gigaset_read_int_callback 362 * gigaset_read_int_callback
364 * 363 *
365 * It is called if the data was received from the device. 364 * It is called if the data was received from the device.
366 */ 365 */
367static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs) 366static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
368{ 367{
@@ -377,12 +376,11 @@ static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
377 inbuf = (struct inbuf_t *) urb->context; 376 inbuf = (struct inbuf_t *) urb->context;
378 IFNULLRET(inbuf); 377 IFNULLRET(inbuf);
379 cs = inbuf->cs; 378 cs = inbuf->cs;
380 IFNULLGOTO(cs, exit); 379 IFNULLRET(cs);
381 IFNULLGOTO(cardstate, exit);
382 380
383 if (!atomic_read(&cs->connected)) { 381 if (!atomic_read(&cs->connected)) {
384 err("%s: disconnected", __func__); 382 err("%s: disconnected", __func__);
385 goto exit; 383 return;
386 } 384 }
387 385
388 if (!urb->status) { 386 if (!urb->status) {
@@ -391,29 +389,31 @@ static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
391 if (numbytes) { 389 if (numbytes) {
392 src = inbuf->rcvbuf; 390 src = inbuf->rcvbuf;
393 if (unlikely(*src)) 391 if (unlikely(*src))
394 warn("%s: There was no leading 0, but 0x%02x!", 392 dev_warn(cs->dev,
395 __func__, (unsigned) *src); 393 "%s: There was no leading 0, but 0x%02x!\n",
394 __func__, (unsigned) *src);
396 ++src; /* skip leading 0x00 */ 395 ++src; /* skip leading 0x00 */
397 --numbytes; 396 --numbytes;
398 if (gigaset_fill_inbuf(inbuf, src, numbytes)) { 397 if (gigaset_fill_inbuf(inbuf, src, numbytes)) {
399 dbg(DEBUG_INTR, "%s-->BH", __func__); 398 gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
400 gigaset_schedule_event(inbuf->cs); 399 gigaset_schedule_event(inbuf->cs);
401 } 400 }
402 } else 401 } else
403 dbg(DEBUG_INTR, "Received zero block length"); 402 gig_dbg(DEBUG_INTR, "Received zero block length");
404 resubmit = 1; 403 resubmit = 1;
405 } else { 404 } else {
406 /* The urb might have been killed. */ 405 /* The urb might have been killed. */
407 dbg(DEBUG_ANY, "%s - nonzero read bulk status received: %d", 406 gig_dbg(DEBUG_ANY, "%s - nonzero read bulk status received: %d",
408 __func__, urb->status); 407 __func__, urb->status);
409 if (urb->status != -ENOENT) /* not killed */ 408 if (urb->status != -ENOENT) /* not killed */
410 resubmit = 1; 409 resubmit = 1;
411 } 410 }
412exit: 411
413 if (resubmit) { 412 if (resubmit) {
414 r = usb_submit_urb(urb, SLAB_ATOMIC); 413 r = usb_submit_urb(urb, SLAB_ATOMIC);
415 if (r) 414 if (r)
416 err("error %d when resubmitting urb.", -r); 415 dev_err(cs->dev, "error %d when resubmitting urb.\n",
416 -r);
417 } 417 }
418} 418}
419 419
@@ -426,14 +426,15 @@ static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
426 IFNULLRET(cs); 426 IFNULLRET(cs);
427#ifdef CONFIG_GIGASET_DEBUG 427#ifdef CONFIG_GIGASET_DEBUG
428 if (!atomic_read(&cs->connected)) { 428 if (!atomic_read(&cs->connected)) {
429 err("%s:not connected", __func__); 429 err("%s: not connected", __func__);
430 return; 430 return;
431 } 431 }
432#endif 432#endif
433 if (urb->status) 433 if (urb->status)
434 err("bulk transfer failed (status %d)", -urb->status); 434 dev_err(cs->dev, "bulk transfer failed (status %d)\n",
435 -urb->status);
435 /* That's all we can do. Communication problems 436 /* That's all we can do. Communication problems
436 are handeled by timeouts or network protocols */ 437 are handled by timeouts or network protocols. */
437 438
438 atomic_set(&cs->hw.usb->busy, 0); 439 atomic_set(&cs->hw.usb->busy, 0);
439 tasklet_schedule(&cs->write_tasklet); 440 tasklet_schedule(&cs->write_tasklet);
@@ -453,8 +454,8 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
453 454
454 spin_lock_irqsave(&cs->cmdlock, flags); 455 spin_lock_irqsave(&cs->cmdlock, flags);
455 cs->cmdbytes -= cs->curlen; 456 cs->cmdbytes -= cs->curlen;
456 dbg(DEBUG_OUTPUT, "send_cb: sent %u bytes, %u left", 457 gig_dbg(DEBUG_OUTPUT, "send_cb: sent %u bytes, %u left",
457 cs->curlen, cs->cmdbytes); 458 cs->curlen, cs->cmdbytes);
458 cs->cmdbuf = cb = cb->next; 459 cs->cmdbuf = cb = cb->next;
459 if (cb) { 460 if (cb) {
460 cb->prev = NULL; 461 cb->prev = NULL;
@@ -472,21 +473,22 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
472 if (cb) { 473 if (cb) {
473 count = min(cb->len, ucs->bulk_out_size); 474 count = min(cb->len, ucs->bulk_out_size);
474 usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev, 475 usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev,
475 usb_sndbulkpipe(ucs->udev, 476 usb_sndbulkpipe(ucs->udev,
476 ucs->bulk_out_endpointAddr & 0x0f), 477 ucs->bulk_out_endpointAddr & 0x0f),
477 cb->buf + cb->offset, count, 478 cb->buf + cb->offset, count,
478 gigaset_write_bulk_callback, cs); 479 gigaset_write_bulk_callback, cs);
479 480
480 cb->offset += count; 481 cb->offset += count;
481 cb->len -= count; 482 cb->len -= count;
482 atomic_set(&ucs->busy, 1); 483 atomic_set(&ucs->busy, 1);
483 dbg(DEBUG_OUTPUT, "send_cb: send %d bytes", count); 484 gig_dbg(DEBUG_OUTPUT, "send_cb: send %d bytes", count);
484 485
485 status = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC); 486 status = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC);
486 if (status) { 487 if (status) {
487 atomic_set(&ucs->busy, 0); 488 atomic_set(&ucs->busy, 0);
488 err("could not submit urb (error %d).", 489 dev_err(cs->dev,
489 -status); 490 "could not submit urb (error %d)\n",
491 -status);
490 cb->len = 0; /* skip urb => remove cb+wakeup 492 cb->len = 0; /* skip urb => remove cb+wakeup
491 in next loop cycle */ 493 in next loop cycle */
492 } 494 }
@@ -498,14 +500,14 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
498 500
499/* Send command to device. */ 501/* Send command to device. */
500static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf, 502static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
501 int len, struct tasklet_struct *wake_tasklet) 503 int len, struct tasklet_struct *wake_tasklet)
502{ 504{
503 struct cmdbuf_t *cb; 505 struct cmdbuf_t *cb;
504 unsigned long flags; 506 unsigned long flags;
505 507
506 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? 508 gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ?
507 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 509 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
508 "CMD Transmit", len, buf, 0); 510 "CMD Transmit", len, buf, 0);
509 511
510 if (!atomic_read(&cs->connected)) { 512 if (!atomic_read(&cs->connected)) {
511 err("%s: not connected", __func__); 513 err("%s: not connected", __func__);
@@ -516,7 +518,7 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
516 return 0; 518 return 0;
517 519
518 if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { 520 if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) {
519 err("%s: out of memory", __func__); 521 dev_err(cs->dev, "%s: out of memory\n", __func__);
520 return -ENOMEM; 522 return -ENOMEM;
521 } 523 }
522 524
@@ -562,11 +564,12 @@ static int gigaset_chars_in_buffer(struct cardstate *cs)
562static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) 564static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
563{ 565{
564#ifdef CONFIG_GIGASET_UNDOCREQ 566#ifdef CONFIG_GIGASET_UNDOCREQ
567 struct usb_device *udev = cs->hw.usb->udev;
568
565 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf, 0); 569 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf, 0);
566 memcpy(cs->hw.usb->bchars, buf, 6); 570 memcpy(cs->hw.usb->bchars, buf, 6);
567 return usb_control_msg(cs->hw.usb->udev, 571 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
568 usb_sndctrlpipe(cs->hw.usb->udev, 0), 0x19, 0x41, 572 0, 0, &buf, 6, 2000);
569 0, 0, &buf, 6, 2000);
570#else 573#else
571 return -EINVAL; 574 return -EINVAL;
572#endif 575#endif
@@ -621,7 +624,7 @@ static int gigaset_initcshw(struct cardstate *cs)
621 //ucs->urb_cmd_out = NULL; 624 //ucs->urb_cmd_out = NULL;
622 ucs->read_urb = NULL; 625 ucs->read_urb = NULL;
623 tasklet_init(&cs->write_tasklet, 626 tasklet_init(&cs->write_tasklet,
624 &gigaset_modem_fill, (unsigned long) cs); 627 &gigaset_modem_fill, (unsigned long) cs);
625 628
626 return 1; 629 return 1;
627} 630}
@@ -636,7 +639,7 @@ static int write_modem(struct cardstate *cs)
636 639
637 IFNULLRETVAL(bcs->tx_skb, -EINVAL); 640 IFNULLRETVAL(bcs->tx_skb, -EINVAL);
638 641
639 dbg(DEBUG_WRITE, "len: %d...", bcs->tx_skb->len); 642 gig_dbg(DEBUG_WRITE, "len: %d...", bcs->tx_skb->len);
640 643
641 ret = -ENODEV; 644 ret = -ENODEV;
642 IFNULLGOTO(ucs->bulk_out_buffer, error); 645 IFNULLGOTO(ucs->bulk_out_buffer, error);
@@ -657,24 +660,24 @@ static int write_modem(struct cardstate *cs)
657 skb_pull(bcs->tx_skb, count); 660 skb_pull(bcs->tx_skb, count);
658 661
659 usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev, 662 usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev,
660 usb_sndbulkpipe(ucs->udev, 663 usb_sndbulkpipe(ucs->udev,
661 ucs->bulk_out_endpointAddr & 0x0f), 664 ucs->bulk_out_endpointAddr & 0x0f),
662 ucs->bulk_out_buffer, count, 665 ucs->bulk_out_buffer, count,
663 gigaset_write_bulk_callback, cs); 666 gigaset_write_bulk_callback, cs);
664 atomic_set(&ucs->busy, 1); 667 atomic_set(&ucs->busy, 1);
665 dbg(DEBUG_OUTPUT, "write_modem: send %d bytes", count); 668 gig_dbg(DEBUG_OUTPUT, "write_modem: send %d bytes", count);
666 669
667 ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC); 670 ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC);
668 if (ret) { 671 if (ret) {
669 err("could not submit urb (error %d).", -ret); 672 dev_err(cs->dev, "could not submit urb (error %d)\n", -ret);
670 atomic_set(&ucs->busy, 0); 673 atomic_set(&ucs->busy, 0);
671 } 674 }
672 if (!bcs->tx_skb->len) { 675 if (!bcs->tx_skb->len) {
673 /* skb sent completely */ 676 /* skb sent completely */
674 gigaset_skb_sent(bcs, bcs->tx_skb); //FIXME also, when ret<0? 677 gigaset_skb_sent(bcs, bcs->tx_skb); //FIXME also, when ret<0?
675 678
676 dbg(DEBUG_INTR, 679 gig_dbg(DEBUG_INTR, "kfree skb (Adr: %lx)!",
677 "kfree skb (Adr: %lx)!", (unsigned long) bcs->tx_skb); 680 (unsigned long) bcs->tx_skb);
678 dev_kfree_skb_any(bcs->tx_skb); 681 dev_kfree_skb_any(bcs->tx_skb);
679 bcs->tx_skb = NULL; 682 bcs->tx_skb = NULL;
680 } 683 }
@@ -688,7 +691,7 @@ error:
688} 691}
689 692
690static int gigaset_probe(struct usb_interface *interface, 693static int gigaset_probe(struct usb_interface *interface,
691 const struct usb_device_id *id) 694 const struct usb_device_id *id)
692{ 695{
693 int retval; 696 int retval;
694 struct usb_device *udev = interface_to_usbdev(interface); 697 struct usb_device *udev = interface_to_usbdev(interface);
@@ -700,9 +703,10 @@ static int gigaset_probe(struct usb_interface *interface,
700 int buffer_size; 703 int buffer_size;
701 int alt; 704 int alt;
702 705
703 info("%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)", 706 gig_dbg(DEBUG_ANY,
704 __func__, le16_to_cpu(udev->descriptor.idVendor), 707 "%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)",
705 le16_to_cpu(udev->descriptor.idProduct)); 708 __func__, le16_to_cpu(udev->descriptor.idVendor),
709 le16_to_cpu(udev->descriptor.idProduct));
706 710
707 retval = -ENODEV; //FIXME 711 retval = -ENODEV; //FIXME
708 712
@@ -717,7 +721,7 @@ static int gigaset_probe(struct usb_interface *interface,
717 ifnum = hostif->desc.bInterfaceNumber; // FIXME ? 721 ifnum = hostif->desc.bInterfaceNumber; // FIXME ?
718 722
719 if (alt != 0 || ifnum != 0) { 723 if (alt != 0 || ifnum != 0) {
720 warn("ifnum %d, alt %d", ifnum, alt); 724 dev_warn(&udev->dev, "ifnum %d, alt %d\n", ifnum, alt);
721 return -ENODEV; 725 return -ENODEV;
722 } 726 }
723 727
@@ -725,20 +729,27 @@ static int gigaset_probe(struct usb_interface *interface,
725 * 729 *
726 */ 730 */
727 if (hostif->desc.bInterfaceClass != 255) { 731 if (hostif->desc.bInterfaceClass != 255) {
728 info("%s: Device matched, but iface_desc[%d]->bInterfaceClass==%d !", 732 dev_info(&udev->dev,
729 __func__, ifnum, hostif->desc.bInterfaceClass); 733 "%s: Device matched but iface_desc[%d]->bInterfaceClass==%d!\n",
734 __func__, ifnum, hostif->desc.bInterfaceClass);
730 return -ENODEV; 735 return -ENODEV;
731 } 736 }
732 737
733 info("%s: Device matched ... !", __func__); 738 dev_info(&udev->dev, "%s: Device matched ... !\n", __func__);
734 739
735 cs = gigaset_getunassignedcs(driver); 740 cs = gigaset_getunassignedcs(driver);
736 if (!cs) { 741 if (!cs) {
737 warn("No free cardstate!"); 742 dev_warn(&udev->dev, "no free cardstate\n");
738 return -ENODEV; 743 return -ENODEV;
739 } 744 }
740 ucs = cs->hw.usb; 745 ucs = cs->hw.usb;
741 746
747 /* save off device structure ptrs for later use */
748 usb_get_dev(udev);
749 ucs->udev = udev;
750 ucs->interface = interface;
751 cs->dev = &udev->dev;
752
742 endpoint = &hostif->endpoint[0].desc; 753 endpoint = &hostif->endpoint[0].desc;
743 754
744 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 755 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
@@ -746,14 +757,14 @@ static int gigaset_probe(struct usb_interface *interface,
746 ucs->bulk_out_endpointAddr = endpoint->bEndpointAddress; 757 ucs->bulk_out_endpointAddr = endpoint->bEndpointAddress;
747 ucs->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); 758 ucs->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
748 if (!ucs->bulk_out_buffer) { 759 if (!ucs->bulk_out_buffer) {
749 err("Couldn't allocate bulk_out_buffer"); 760 dev_err(cs->dev, "Couldn't allocate bulk_out_buffer\n");
750 retval = -ENOMEM; 761 retval = -ENOMEM;
751 goto error; 762 goto error;
752 } 763 }
753 764
754 ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL); 765 ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL);
755 if (!ucs->bulk_out_urb) { 766 if (!ucs->bulk_out_urb) {
756 err("Couldn't allocate bulk_out_buffer"); 767 dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n");
757 retval = -ENOMEM; 768 retval = -ENOMEM;
758 goto error; 769 goto error;
759 } 770 }
@@ -761,12 +772,10 @@ static int gigaset_probe(struct usb_interface *interface,
761 endpoint = &hostif->endpoint[1].desc; 772 endpoint = &hostif->endpoint[1].desc;
762 773
763 atomic_set(&ucs->busy, 0); 774 atomic_set(&ucs->busy, 0);
764 ucs->udev = udev;
765 ucs->interface = interface;
766 775
767 ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL); 776 ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL);
768 if (!ucs->read_urb) { 777 if (!ucs->read_urb) {
769 err("No free urbs available"); 778 dev_err(cs->dev, "No free urbs available\n");
770 retval = -ENOMEM; 779 retval = -ENOMEM;
771 goto error; 780 goto error;
772 } 781 }
@@ -775,21 +784,21 @@ static int gigaset_probe(struct usb_interface *interface,
775 ucs->int_in_endpointAddr = endpoint->bEndpointAddress; 784 ucs->int_in_endpointAddr = endpoint->bEndpointAddress;
776 cs->inbuf[0].rcvbuf = kmalloc(buffer_size, GFP_KERNEL); 785 cs->inbuf[0].rcvbuf = kmalloc(buffer_size, GFP_KERNEL);
777 if (!cs->inbuf[0].rcvbuf) { 786 if (!cs->inbuf[0].rcvbuf) {
778 err("Couldn't allocate rcvbuf"); 787 dev_err(cs->dev, "Couldn't allocate rcvbuf\n");
779 retval = -ENOMEM; 788 retval = -ENOMEM;
780 goto error; 789 goto error;
781 } 790 }
782 /* Fill the interrupt urb and send it to the core */ 791 /* Fill the interrupt urb and send it to the core */
783 usb_fill_int_urb(ucs->read_urb, udev, 792 usb_fill_int_urb(ucs->read_urb, udev,
784 usb_rcvintpipe(udev, 793 usb_rcvintpipe(udev,
785 endpoint->bEndpointAddress & 0x0f), 794 endpoint->bEndpointAddress & 0x0f),
786 cs->inbuf[0].rcvbuf, buffer_size, 795 cs->inbuf[0].rcvbuf, buffer_size,
787 gigaset_read_int_callback, 796 gigaset_read_int_callback,
788 cs->inbuf + 0, endpoint->bInterval); 797 cs->inbuf + 0, endpoint->bInterval);
789 798
790 retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL); 799 retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL);
791 if (retval) { 800 if (retval) {
792 err("Could not submit URB!"); 801 dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval);
793 goto error; 802 goto error;
794 } 803 }
795 804
@@ -820,6 +829,9 @@ error:
820 usb_free_urb(ucs->read_urb); 829 usb_free_urb(ucs->read_urb);
821 ucs->read_urb = ucs->bulk_out_urb = NULL; 830 ucs->read_urb = ucs->bulk_out_urb = NULL;
822 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; 831 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
832 usb_put_dev(ucs->udev);
833 ucs->udev = NULL;
834 ucs->interface = NULL;
823 gigaset_unassign(cs); 835 gigaset_unassign(cs);
824 return retval; 836 return retval;
825} 837}
@@ -840,13 +852,12 @@ static void gigaset_disconnect(struct usb_interface *interface)
840 usb_set_intfdata(interface, NULL); 852 usb_set_intfdata(interface, NULL);
841 ucs = cs->hw.usb; 853 ucs = cs->hw.usb;
842 usb_kill_urb(ucs->read_urb); 854 usb_kill_urb(ucs->read_urb);
843 //info("GigaSet USB device #%d will be disconnected", minor);
844 855
845 gigaset_stop(cs); 856 gigaset_stop(cs);
846 857
847 tasklet_kill(&cs->write_tasklet); 858 tasklet_kill(&cs->write_tasklet);
848 859
849 usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */ 860 usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */
850 861
851 kfree(ucs->bulk_out_buffer); 862 kfree(ucs->bulk_out_buffer);
852 if (ucs->bulk_out_urb != NULL) 863 if (ucs->bulk_out_urb != NULL)
@@ -889,9 +900,9 @@ static int __init usb_gigaset_init(void)
889 900
890 /* allocate memory for our driver state and intialize it */ 901 /* allocate memory for our driver state and intialize it */
891 if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, 902 if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
892 GIGASET_MODULENAME, GIGASET_DEVNAME, 903 GIGASET_MODULENAME, GIGASET_DEVNAME,
893 GIGASET_DEVFSNAME, &ops, 904 GIGASET_DEVFSNAME, &ops,
894 THIS_MODULE)) == NULL) 905 THIS_MODULE)) == NULL)
895 goto error; 906 goto error;
896 907
897 /* allocate memory for our device state and intialize it */ 908 /* allocate memory for our device state and intialize it */
@@ -928,8 +939,8 @@ error: if (cardstate)
928static void __exit usb_gigaset_exit(void) 939static void __exit usb_gigaset_exit(void)
929{ 940{
930 gigaset_blockdriver(driver); /* => probe will fail 941 gigaset_blockdriver(driver); /* => probe will fail
931 * => no gigaset_start any more 942 * => no gigaset_start any more
932 */ 943 */
933 944
934 gigaset_shutdown(cardstate); 945 gigaset_shutdown(cardstate);
935 /* from now on, no isdn callback should be possible */ 946 /* from now on, no isdn callback should be possible */