aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/ser-gigaset.c
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2010-07-05 10:18:43 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-07 19:57:51 -0400
commite3628dd176ba3ed329991ef042c29aae60617630 (patch)
tree77e47e95ba38276557702a5bfc8e319bc9100b7c /drivers/isdn/gigaset/ser-gigaset.c
parentb3251d8045f87eec5d565603345d262cee134fa6 (diff)
isdn/gigaset: avoid copying AT commands twice
Change the Gigaset driver's internal write_cmd interface to accept a cmdbuf structure instead of a string. This avoids copying formatted AT commands a second time. Impact: optimization Signed-off-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/gigaset/ser-gigaset.c')
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index e96c0586886c..d151dcbf770d 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -241,30 +241,13 @@ static void flush_send_queue(struct cardstate *cs)
241 * return value: 241 * return value:
242 * number of bytes queued, or error code < 0 242 * number of bytes queued, or error code < 0
243 */ 243 */
244static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf, 244static int gigaset_write_cmd(struct cardstate *cs, struct cmdbuf_t *cb)
245 int len, struct tasklet_struct *wake_tasklet)
246{ 245{
247 struct cmdbuf_t *cb;
248 unsigned long flags; 246 unsigned long flags;
249 247
250 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ? 248 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ?
251 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 249 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
252 "CMD Transmit", len, buf); 250 "CMD Transmit", cb->len, cb->buf);
253
254 if (len <= 0)
255 return 0;
256
257 cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC);
258 if (!cb) {
259 dev_err(cs->dev, "%s: out of memory!\n", __func__);
260 return -ENOMEM;
261 }
262
263 memcpy(cb->buf, buf, len);
264 cb->len = len;
265 cb->offset = 0;
266 cb->next = NULL;
267 cb->wake_tasklet = wake_tasklet;
268 251
269 spin_lock_irqsave(&cs->cmdlock, flags); 252 spin_lock_irqsave(&cs->cmdlock, flags);
270 cb->prev = cs->lastcmdbuf; 253 cb->prev = cs->lastcmdbuf;
@@ -272,9 +255,9 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
272 cs->lastcmdbuf->next = cb; 255 cs->lastcmdbuf->next = cb;
273 else { 256 else {
274 cs->cmdbuf = cb; 257 cs->cmdbuf = cb;
275 cs->curlen = len; 258 cs->curlen = cb->len;
276 } 259 }
277 cs->cmdbytes += len; 260 cs->cmdbytes += cb->len;
278 cs->lastcmdbuf = cb; 261 cs->lastcmdbuf = cb;
279 spin_unlock_irqrestore(&cs->cmdlock, flags); 262 spin_unlock_irqrestore(&cs->cmdlock, flags);
280 263
@@ -282,7 +265,7 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
282 if (cs->connected) 265 if (cs->connected)
283 tasklet_schedule(&cs->write_tasklet); 266 tasklet_schedule(&cs->write_tasklet);
284 spin_unlock_irqrestore(&cs->lock, flags); 267 spin_unlock_irqrestore(&cs->lock, flags);
285 return len; 268 return cb->len;
286} 269}
287 270
288/* 271/*