isdn/gigaset: avoid copying AT commands twice
[linux-2.6-microblaze.git] / drivers / isdn / gigaset / usb-gigaset.c
index f65cf7d..4a66338 100644 (file)
@@ -494,29 +494,13 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
 }
 
 /* Send command to device. */
-static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
-                            int len, struct tasklet_struct *wake_tasklet)
+static int gigaset_write_cmd(struct cardstate *cs, struct cmdbuf_t *cb)
 {
-       struct cmdbuf_t *cb;
        unsigned long flags;
 
        gigaset_dbg_buffer(cs->mstate != MS_LOCKED ?
                             DEBUG_TRANSCMD : DEBUG_LOCKCMD,
-                          "CMD Transmit", len, buf);
-
-       if (len <= 0)
-               return 0;
-       cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC);
-       if (!cb) {
-               dev_err(cs->dev, "%s: out of memory\n", __func__);
-               return -ENOMEM;
-       }
-
-       memcpy(cb->buf, buf, len);
-       cb->len = len;
-       cb->offset = 0;
-       cb->next = NULL;
-       cb->wake_tasklet = wake_tasklet;
+                          "CMD Transmit", cb->len, cb->buf);
 
        spin_lock_irqsave(&cs->cmdlock, flags);
        cb->prev = cs->lastcmdbuf;
@@ -524,9 +508,9 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
                cs->lastcmdbuf->next = cb;
        else {
                cs->cmdbuf = cb;
-               cs->curlen = len;
+               cs->curlen = cb->len;
        }
-       cs->cmdbytes += len;
+       cs->cmdbytes += cb->len;
        cs->lastcmdbuf = cb;
        spin_unlock_irqrestore(&cs->cmdlock, flags);
 
@@ -534,7 +518,7 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
        if (cs->connected)
                tasklet_schedule(&cs->write_tasklet);
        spin_unlock_irqrestore(&cs->lock, flags);
-       return len;
+       return cb->len;
 }
 
 static int gigaset_write_room(struct cardstate *cs)