aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/hif_usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/hif_usb.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c119
1 files changed, 58 insertions, 61 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index ae842dbf9b50..8946e8ad1b85 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -363,9 +363,9 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
363 struct sk_buff *skb) 363 struct sk_buff *skb)
364{ 364{
365 struct sk_buff *nskb, *skb_pool[MAX_PKT_NUM_IN_TRANSFER]; 365 struct sk_buff *nskb, *skb_pool[MAX_PKT_NUM_IN_TRANSFER];
366 int index = 0, i = 0, chk_idx, len = skb->len; 366 int index = 0, i = 0, len = skb->len;
367 int rx_remain_len = 0, rx_pkt_len = 0; 367 int rx_remain_len, rx_pkt_len;
368 u16 pkt_len, pkt_tag, pool_index = 0; 368 u16 pool_index = 0;
369 u8 *ptr; 369 u8 *ptr;
370 370
371 spin_lock(&hif_dev->rx_lock); 371 spin_lock(&hif_dev->rx_lock);
@@ -399,64 +399,64 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
399 spin_unlock(&hif_dev->rx_lock); 399 spin_unlock(&hif_dev->rx_lock);
400 400
401 while (index < len) { 401 while (index < len) {
402 u16 pkt_len;
403 u16 pkt_tag;
404 u16 pad_len;
405 int chk_idx;
406
402 ptr = (u8 *) skb->data; 407 ptr = (u8 *) skb->data;
403 408
404 pkt_len = ptr[index] + (ptr[index+1] << 8); 409 pkt_len = ptr[index] + (ptr[index+1] << 8);
405 pkt_tag = ptr[index+2] + (ptr[index+3] << 8); 410 pkt_tag = ptr[index+2] + (ptr[index+3] << 8);
406 411
407 if (pkt_tag == ATH_USB_RX_STREAM_MODE_TAG) { 412 if (pkt_tag != ATH_USB_RX_STREAM_MODE_TAG) {
408 u16 pad_len; 413 RX_STAT_INC(skb_dropped);
409 414 return;
410 pad_len = 4 - (pkt_len & 0x3); 415 }
411 if (pad_len == 4) 416
412 pad_len = 0; 417 pad_len = 4 - (pkt_len & 0x3);
413 418 if (pad_len == 4)
414 chk_idx = index; 419 pad_len = 0;
415 index = index + 4 + pkt_len + pad_len; 420
416 421 chk_idx = index;
417 if (index > MAX_RX_BUF_SIZE) { 422 index = index + 4 + pkt_len + pad_len;
418 spin_lock(&hif_dev->rx_lock); 423
419 hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE; 424 if (index > MAX_RX_BUF_SIZE) {
420 hif_dev->rx_transfer_len = 425 spin_lock(&hif_dev->rx_lock);
421 MAX_RX_BUF_SIZE - chk_idx - 4; 426 hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE;
422 hif_dev->rx_pad_len = pad_len; 427 hif_dev->rx_transfer_len =
423 428 MAX_RX_BUF_SIZE - chk_idx - 4;
424 nskb = __dev_alloc_skb(pkt_len + 32, 429 hif_dev->rx_pad_len = pad_len;
425 GFP_ATOMIC); 430
426 if (!nskb) { 431 nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
427 dev_err(&hif_dev->udev->dev, 432 if (!nskb) {
428 "ath9k_htc: RX memory allocation" 433 dev_err(&hif_dev->udev->dev,
429 " error\n"); 434 "ath9k_htc: RX memory allocation error\n");
430 spin_unlock(&hif_dev->rx_lock);
431 goto err;
432 }
433 skb_reserve(nskb, 32);
434 RX_STAT_INC(skb_allocated);
435
436 memcpy(nskb->data, &(skb->data[chk_idx+4]),
437 hif_dev->rx_transfer_len);
438
439 /* Record the buffer pointer */
440 hif_dev->remain_skb = nskb;
441 spin_unlock(&hif_dev->rx_lock); 435 spin_unlock(&hif_dev->rx_lock);
442 } else { 436 goto err;
443 nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
444 if (!nskb) {
445 dev_err(&hif_dev->udev->dev,
446 "ath9k_htc: RX memory allocation"
447 " error\n");
448 goto err;
449 }
450 skb_reserve(nskb, 32);
451 RX_STAT_INC(skb_allocated);
452
453 memcpy(nskb->data, &(skb->data[chk_idx+4]), pkt_len);
454 skb_put(nskb, pkt_len);
455 skb_pool[pool_index++] = nskb;
456 } 437 }
438 skb_reserve(nskb, 32);
439 RX_STAT_INC(skb_allocated);
440
441 memcpy(nskb->data, &(skb->data[chk_idx+4]),
442 hif_dev->rx_transfer_len);
443
444 /* Record the buffer pointer */
445 hif_dev->remain_skb = nskb;
446 spin_unlock(&hif_dev->rx_lock);
457 } else { 447 } else {
458 RX_STAT_INC(skb_dropped); 448 nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
459 return; 449 if (!nskb) {
450 dev_err(&hif_dev->udev->dev,
451 "ath9k_htc: RX memory allocation error\n");
452 goto err;
453 }
454 skb_reserve(nskb, 32);
455 RX_STAT_INC(skb_allocated);
456
457 memcpy(nskb->data, &(skb->data[chk_idx+4]), pkt_len);
458 skb_put(nskb, pkt_len);
459 skb_pool[pool_index++] = nskb;
460 } 460 }
461 } 461 }
462 462
@@ -471,7 +471,7 @@ err:
471static void ath9k_hif_usb_rx_cb(struct urb *urb) 471static void ath9k_hif_usb_rx_cb(struct urb *urb)
472{ 472{
473 struct sk_buff *skb = (struct sk_buff *) urb->context; 473 struct sk_buff *skb = (struct sk_buff *) urb->context;
474 struct hif_device_usb *hif_dev = (struct hif_device_usb *) 474 struct hif_device_usb *hif_dev =
475 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); 475 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
476 int ret; 476 int ret;
477 477
@@ -518,7 +518,7 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
518{ 518{
519 struct sk_buff *skb = (struct sk_buff *) urb->context; 519 struct sk_buff *skb = (struct sk_buff *) urb->context;
520 struct sk_buff *nskb; 520 struct sk_buff *nskb;
521 struct hif_device_usb *hif_dev = (struct hif_device_usb *) 521 struct hif_device_usb *hif_dev =
522 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); 522 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
523 int ret; 523 int ret;
524 524
@@ -993,8 +993,7 @@ static void ath9k_hif_usb_reboot(struct usb_device *udev)
993static void ath9k_hif_usb_disconnect(struct usb_interface *interface) 993static void ath9k_hif_usb_disconnect(struct usb_interface *interface)
994{ 994{
995 struct usb_device *udev = interface_to_usbdev(interface); 995 struct usb_device *udev = interface_to_usbdev(interface);
996 struct hif_device_usb *hif_dev = 996 struct hif_device_usb *hif_dev = usb_get_intfdata(interface);
997 (struct hif_device_usb *) usb_get_intfdata(interface);
998 997
999 if (hif_dev) { 998 if (hif_dev) {
1000 ath9k_htc_hw_deinit(hif_dev->htc_handle, 999 ath9k_htc_hw_deinit(hif_dev->htc_handle,
@@ -1016,8 +1015,7 @@ static void ath9k_hif_usb_disconnect(struct usb_interface *interface)
1016static int ath9k_hif_usb_suspend(struct usb_interface *interface, 1015static int ath9k_hif_usb_suspend(struct usb_interface *interface,
1017 pm_message_t message) 1016 pm_message_t message)
1018{ 1017{
1019 struct hif_device_usb *hif_dev = 1018 struct hif_device_usb *hif_dev = usb_get_intfdata(interface);
1020 (struct hif_device_usb *) usb_get_intfdata(interface);
1021 1019
1022 ath9k_hif_usb_dealloc_urbs(hif_dev); 1020 ath9k_hif_usb_dealloc_urbs(hif_dev);
1023 1021
@@ -1026,8 +1024,7 @@ static int ath9k_hif_usb_suspend(struct usb_interface *interface,
1026 1024
1027static int ath9k_hif_usb_resume(struct usb_interface *interface) 1025static int ath9k_hif_usb_resume(struct usb_interface *interface)
1028{ 1026{
1029 struct hif_device_usb *hif_dev = 1027 struct hif_device_usb *hif_dev = usb_get_intfdata(interface);
1030 (struct hif_device_usb *) usb_get_intfdata(interface);
1031 struct htc_target *htc_handle = hif_dev->htc_handle; 1028 struct htc_target *htc_handle = hif_dev->htc_handle;
1032 int ret; 1029 int ret;
1033 1030