aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/asyncdata.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/asyncdata.c')
-rw-r--r--drivers/isdn/gigaset/asyncdata.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c
index a25216bf475e..256fc4809c81 100644
--- a/drivers/isdn/gigaset/asyncdata.c
+++ b/drivers/isdn/gigaset/asyncdata.c
@@ -156,7 +156,7 @@ byte_stuff:
156 156
157 /* end of frame */ 157 /* end of frame */
158 gigaset_isdn_rcv_err(bcs); 158 gigaset_isdn_rcv_err(bcs);
159 dev_kfree_skb(skb); 159 dev_kfree_skb_any(skb);
160 } else if (!(inputstate & INS_have_data)) { /* 7E 7E */ 160 } else if (!(inputstate & INS_have_data)) { /* 7E 7E */
161#ifdef CONFIG_GIGASET_DEBUG 161#ifdef CONFIG_GIGASET_DEBUG
162 ++bcs->emptycount; 162 ++bcs->emptycount;
@@ -172,7 +172,7 @@ byte_stuff:
172 "Checksum failed, %u bytes corrupted!\n", 172 "Checksum failed, %u bytes corrupted!\n",
173 skb->len); 173 skb->len);
174 gigaset_isdn_rcv_err(bcs); 174 gigaset_isdn_rcv_err(bcs);
175 dev_kfree_skb(skb); 175 dev_kfree_skb_any(skb);
176 } else if (likely(skb->len > 2)) { 176 } else if (likely(skb->len > 2)) {
177 __skb_trim(skb, skb->len - 2); 177 __skb_trim(skb, skb->len - 2);
178 gigaset_skb_rcvd(bcs, skb); 178 gigaset_skb_rcvd(bcs, skb);
@@ -182,7 +182,7 @@ byte_stuff:
182 "invalid packet size (%d)\n", skb->len); 182 "invalid packet size (%d)\n", skb->len);
183 gigaset_isdn_rcv_err(bcs); 183 gigaset_isdn_rcv_err(bcs);
184 } 184 }
185 dev_kfree_skb(skb); 185 dev_kfree_skb_any(skb);
186 } 186 }
187 } 187 }
188 188
@@ -430,11 +430,11 @@ EXPORT_SYMBOL_GPL(gigaset_m10x_input);
430 * opening and closing flags, preserving headroom data. 430 * opening and closing flags, preserving headroom data.
431 * parameters: 431 * parameters:
432 * skb skb containing original packet (freed upon return) 432 * skb skb containing original packet (freed upon return)
433 * headroom number of headroom bytes to preserve
434 * Return value: 433 * Return value:
435 * pointer to newly allocated skb containing the result frame 434 * pointer to newly allocated skb containing the result frame
435 * and the original link layer header, NULL on error
436 */ 436 */
437static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom) 437static struct sk_buff *HDLC_Encode(struct sk_buff *skb)
438{ 438{
439 struct sk_buff *hdlc_skb; 439 struct sk_buff *hdlc_skb;
440 __u16 fcs; 440 __u16 fcs;
@@ -456,17 +456,19 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom)
456 456
457 /* size of new buffer: original size + number of stuffing bytes 457 /* size of new buffer: original size + number of stuffing bytes
458 * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes 458 * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes
459 * + room for acknowledgement header 459 * + room for link layer header
460 */ 460 */
461 hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + headroom); 461 hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + skb->mac_len);
462 if (!hdlc_skb) { 462 if (!hdlc_skb) {
463 dev_kfree_skb(skb); 463 dev_kfree_skb_any(skb);
464 return NULL; 464 return NULL;
465 } 465 }
466 466
467 /* Copy acknowledgement header into new skb */ 467 /* Copy link layer header into new skb */
468 skb_reserve(hdlc_skb, headroom); 468 skb_reset_mac_header(hdlc_skb);
469 memcpy(hdlc_skb->head, skb->head, headroom); 469 skb_reserve(hdlc_skb, skb->mac_len);
470 memcpy(skb_mac_header(hdlc_skb), skb_mac_header(skb), skb->mac_len);
471 hdlc_skb->mac_len = skb->mac_len;
470 472
471 /* Add flag sequence in front of everything.. */ 473 /* Add flag sequence in front of everything.. */
472 *(skb_put(hdlc_skb, 1)) = PPP_FLAG; 474 *(skb_put(hdlc_skb, 1)) = PPP_FLAG;
@@ -497,7 +499,7 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom)
497 499
498 *(skb_put(hdlc_skb, 1)) = PPP_FLAG; 500 *(skb_put(hdlc_skb, 1)) = PPP_FLAG;
499 501
500 dev_kfree_skb(skb); 502 dev_kfree_skb_any(skb);
501 return hdlc_skb; 503 return hdlc_skb;
502} 504}
503 505
@@ -506,28 +508,33 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom)
506 * preserving headroom data. 508 * preserving headroom data.
507 * parameters: 509 * parameters:
508 * skb skb containing original packet (freed upon return) 510 * skb skb containing original packet (freed upon return)
509 * headroom number of headroom bytes to preserve
510 * Return value: 511 * Return value:
511 * pointer to newly allocated skb containing the result frame 512 * pointer to newly allocated skb containing the result frame
513 * and the original link layer header, NULL on error
512 */ 514 */
513static struct sk_buff *iraw_encode(struct sk_buff *skb, int headroom) 515static struct sk_buff *iraw_encode(struct sk_buff *skb)
514{ 516{
515 struct sk_buff *iraw_skb; 517 struct sk_buff *iraw_skb;
516 unsigned char c; 518 unsigned char c;
517 unsigned char *cp; 519 unsigned char *cp;
518 int len; 520 int len;
519 521
520 /* worst case: every byte must be stuffed */ 522 /* size of new buffer (worst case = every byte must be stuffed):
521 iraw_skb = dev_alloc_skb(2*skb->len + headroom); 523 * 2 * original size + room for link layer header
524 */
525 iraw_skb = dev_alloc_skb(2*skb->len + skb->mac_len);
522 if (!iraw_skb) { 526 if (!iraw_skb) {
523 dev_kfree_skb(skb); 527 dev_kfree_skb_any(skb);
524 return NULL; 528 return NULL;
525 } 529 }
526 530
527 /* Copy acknowledgement header into new skb */ 531 /* copy link layer header into new skb */
528 skb_reserve(iraw_skb, headroom); 532 skb_reset_mac_header(iraw_skb);
529 memcpy(iraw_skb->head, skb->head, headroom); 533 skb_reserve(iraw_skb, skb->mac_len);
534 memcpy(skb_mac_header(iraw_skb), skb_mac_header(skb), skb->mac_len);
535 iraw_skb->mac_len = skb->mac_len;
530 536
537 /* copy and stuff data */
531 cp = skb->data; 538 cp = skb->data;
532 len = skb->len; 539 len = skb->len;
533 while (len--) { 540 while (len--) {
@@ -536,7 +543,7 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int headroom)
536 *(skb_put(iraw_skb, 1)) = c; 543 *(skb_put(iraw_skb, 1)) = c;
537 *(skb_put(iraw_skb, 1)) = c; 544 *(skb_put(iraw_skb, 1)) = c;
538 } 545 }
539 dev_kfree_skb(skb); 546 dev_kfree_skb_any(skb);
540 return iraw_skb; 547 return iraw_skb;
541} 548}
542 549
@@ -548,7 +555,7 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int headroom)
548 * Called by LL to encode and queue an skb for sending, and start 555 * Called by LL to encode and queue an skb for sending, and start
549 * transmission if necessary. 556 * transmission if necessary.
550 * Once the payload data has been transmitted completely, gigaset_skb_sent() 557 * Once the payload data has been transmitted completely, gigaset_skb_sent()
551 * will be called with the first cs->hw_hdr_len bytes of skb->head preserved. 558 * will be called with the skb's link layer header preserved.
552 * 559 *
553 * Return value: 560 * Return value:
554 * number of bytes accepted for sending (skb->len) if ok, 561 * number of bytes accepted for sending (skb->len) if ok,
@@ -560,9 +567,9 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
560 unsigned long flags; 567 unsigned long flags;
561 568
562 if (bcs->proto2 == L2_HDLC) 569 if (bcs->proto2 == L2_HDLC)
563 skb = HDLC_Encode(skb, bcs->cs->hw_hdr_len); 570 skb = HDLC_Encode(skb);
564 else 571 else
565 skb = iraw_encode(skb, bcs->cs->hw_hdr_len); 572 skb = iraw_encode(skb);
566 if (!skb) { 573 if (!skb) {
567 dev_err(bcs->cs->dev, 574 dev_err(bcs->cs->dev,
568 "unable to allocate memory for encoding!\n"); 575 "unable to allocate memory for encoding!\n");