aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/usb-gigaset.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/usb-gigaset.c')
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index f65cf7db216b..4a66338f4e7d 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -494,29 +494,13 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
494} 494}
495 495
496/* Send command to device. */ 496/* Send command to device. */
497static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf, 497static int gigaset_write_cmd(struct cardstate *cs, struct cmdbuf_t *cb)
498 int len, struct tasklet_struct *wake_tasklet)
499{ 498{
500 struct cmdbuf_t *cb;
501 unsigned long flags; 499 unsigned long flags;
502 500
503 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ? 501 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ?
504 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 502 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
505 "CMD Transmit", len, buf); 503 "CMD Transmit", cb->len, cb->buf);
506
507 if (len <= 0)
508 return 0;
509 cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC);
510 if (!cb) {
511 dev_err(cs->dev, "%s: out of memory\n", __func__);
512 return -ENOMEM;
513 }
514
515 memcpy(cb->buf, buf, len);
516 cb->len = len;
517 cb->offset = 0;
518 cb->next = NULL;
519 cb->wake_tasklet = wake_tasklet;
520 504
521 spin_lock_irqsave(&cs->cmdlock, flags); 505 spin_lock_irqsave(&cs->cmdlock, flags);
522 cb->prev = cs->lastcmdbuf; 506 cb->prev = cs->lastcmdbuf;
@@ -524,9 +508,9 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
524 cs->lastcmdbuf->next = cb; 508 cs->lastcmdbuf->next = cb;
525 else { 509 else {
526 cs->cmdbuf = cb; 510 cs->cmdbuf = cb;
527 cs->curlen = len; 511 cs->curlen = cb->len;
528 } 512 }
529 cs->cmdbytes += len; 513 cs->cmdbytes += cb->len;
530 cs->lastcmdbuf = cb; 514 cs->lastcmdbuf = cb;
531 spin_unlock_irqrestore(&cs->cmdlock, flags); 515 spin_unlock_irqrestore(&cs->cmdlock, flags);
532 516
@@ -534,7 +518,7 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
534 if (cs->connected) 518 if (cs->connected)
535 tasklet_schedule(&cs->write_tasklet); 519 tasklet_schedule(&cs->write_tasklet);
536 spin_unlock_irqrestore(&cs->lock, flags); 520 spin_unlock_irqrestore(&cs->lock, flags);
537 return len; 521 return cb->len;
538} 522}
539 523
540static int gigaset_write_room(struct cardstate *cs) 524static int gigaset_write_room(struct cardstate *cs)