diff options
Diffstat (limited to 'drivers/isdn/gigaset/usb-gigaset.c')
-rw-r--r-- | drivers/isdn/gigaset/usb-gigaset.c | 239 |
1 files changed, 125 insertions, 114 deletions
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 | ||
108 | static int gigaset_probe(struct usb_interface *interface, | 108 | static int gigaset_probe(struct usb_interface *interface, |
109 | const struct usb_device_id *id); | 109 | const struct usb_device_id *id); |
110 | static void gigaset_disconnect(struct usb_interface *interface); | 110 | static void gigaset_disconnect(struct usb_interface *interface); |
111 | 111 | ||
112 | static struct gigaset_driver *driver = NULL; | 112 | static 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 | ||
142 | struct usb_bc_state {}; | 142 | struct 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! */ |
151 | static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, | 151 | static 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 | ||
172 | static int set_value(struct cardstate *cs, u8 req, u16 val) | 172 | static 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 |
272 | static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, | 271 | static 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 | */ |
367 | static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs) | 366 | static 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 | } |
412 | exit: | 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. */ |
500 | static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf, | 502 | static 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) | |||
562 | static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) | 564 | static 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 | ||
690 | static int gigaset_probe(struct usb_interface *interface, | 693 | static 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) | |||
928 | static void __exit usb_gigaset_exit(void) | 939 | static 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 */ |