aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorKalle Valo <kvalo@qca.qualcomm.com>2011-10-27 11:49:00 -0400
committerKalle Valo <kvalo@qca.qualcomm.com>2011-11-11 05:58:58 -0500
commit8a8109169bcb3390a46c81a45fbfdd4801fb1adc (patch)
treeb3b5de6b410e7426118585acd5081a188f3440b0 /drivers/net
parentd60e8ab6b9bcbbb5eb7591c1989f8c79d6b3d964 (diff)
ath6kl: create ath6kl_htc_reset()
When rebooting hardware we need to reset the htc state in ath6kl_htc_stop(). Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath/ath6kl/htc.c91
1 files changed, 49 insertions, 42 deletions
diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c
index d03456bcb8ba..04b4070240aa 100644
--- a/drivers/net/wireless/ath/ath6kl/htc.c
+++ b/drivers/net/wireless/ath/ath6kl/htc.c
@@ -2656,6 +2656,44 @@ int ath6kl_htc_start(struct htc_target *target)
2656 return status; 2656 return status;
2657} 2657}
2658 2658
2659static int ath6kl_htc_reset(struct htc_target *target)
2660{
2661 u32 block_size, ctrl_bufsz;
2662 struct htc_packet *packet;
2663 int i;
2664
2665 reset_ep_state(target);
2666
2667 block_size = target->dev->ar->mbox_info.block_size;
2668
2669 ctrl_bufsz = (block_size > HTC_MAX_CTRL_MSG_LEN) ?
2670 (block_size + HTC_HDR_LENGTH) :
2671 (HTC_MAX_CTRL_MSG_LEN + HTC_HDR_LENGTH);
2672
2673 for (i = 0; i < NUM_CONTROL_BUFFERS; i++) {
2674 packet = kzalloc(sizeof(*packet), GFP_KERNEL);
2675 if (!packet)
2676 return -ENOMEM;
2677
2678 packet->buf_start = kzalloc(ctrl_bufsz, GFP_KERNEL);
2679 if (!packet->buf_start) {
2680 kfree(packet);
2681 return -ENOMEM;
2682 }
2683
2684 packet->buf_len = ctrl_bufsz;
2685 if (i < NUM_CONTROL_RX_BUFFERS) {
2686 packet->act_len = 0;
2687 packet->buf = packet->buf_start;
2688 packet->endpoint = ENDPOINT_0;
2689 list_add_tail(&packet->list, &target->free_ctrl_rxbuf);
2690 } else
2691 list_add_tail(&packet->list, &target->free_ctrl_txbuf);
2692 }
2693
2694 return 0;
2695}
2696
2659/* htc_stop: stop interrupt reception, and flush all queued buffers */ 2697/* htc_stop: stop interrupt reception, and flush all queued buffers */
2660void ath6kl_htc_stop(struct htc_target *target) 2698void ath6kl_htc_stop(struct htc_target *target)
2661{ 2699{
@@ -2674,15 +2712,13 @@ void ath6kl_htc_stop(struct htc_target *target)
2674 2712
2675 ath6kl_htc_flush_rx_buf(target); 2713 ath6kl_htc_flush_rx_buf(target);
2676 2714
2677 reset_ep_state(target); 2715 ath6kl_htc_reset(target);
2678} 2716}
2679 2717
2680void *ath6kl_htc_create(struct ath6kl *ar) 2718void *ath6kl_htc_create(struct ath6kl *ar)
2681{ 2719{
2682 struct htc_target *target = NULL; 2720 struct htc_target *target = NULL;
2683 struct htc_packet *packet; 2721 int status = 0;
2684 int status = 0, i = 0;
2685 u32 block_size, ctrl_bufsz;
2686 2722
2687 target = kzalloc(sizeof(*target), GFP_KERNEL); 2723 target = kzalloc(sizeof(*target), GFP_KERNEL);
2688 if (!target) { 2724 if (!target) {
@@ -2694,7 +2730,7 @@ void *ath6kl_htc_create(struct ath6kl *ar)
2694 if (!target->dev) { 2730 if (!target->dev) {
2695 ath6kl_err("unable to allocate memory\n"); 2731 ath6kl_err("unable to allocate memory\n");
2696 status = -ENOMEM; 2732 status = -ENOMEM;
2697 goto fail_create_htc; 2733 goto err_htc_cleanup;
2698 } 2734 }
2699 2735
2700 spin_lock_init(&target->htc_lock); 2736 spin_lock_init(&target->htc_lock);
@@ -2709,49 +2745,20 @@ void *ath6kl_htc_create(struct ath6kl *ar)
2709 target->dev->htc_cnxt = target; 2745 target->dev->htc_cnxt = target;
2710 target->ep_waiting = ENDPOINT_MAX; 2746 target->ep_waiting = ENDPOINT_MAX;
2711 2747
2712 reset_ep_state(target);
2713
2714 status = ath6kl_hif_setup(target->dev); 2748 status = ath6kl_hif_setup(target->dev);
2715
2716 if (status) 2749 if (status)
2717 goto fail_create_htc; 2750 goto err_htc_cleanup;
2718
2719 block_size = ar->mbox_info.block_size;
2720
2721 ctrl_bufsz = (block_size > HTC_MAX_CTRL_MSG_LEN) ?
2722 (block_size + HTC_HDR_LENGTH) :
2723 (HTC_MAX_CTRL_MSG_LEN + HTC_HDR_LENGTH);
2724 2751
2725 for (i = 0; i < NUM_CONTROL_BUFFERS; i++) { 2752 status = ath6kl_htc_reset(target);
2726 packet = kzalloc(sizeof(*packet), GFP_KERNEL); 2753 if (status)
2727 if (!packet) 2754 goto err_htc_cleanup;
2728 break;
2729
2730 packet->buf_start = kzalloc(ctrl_bufsz, GFP_KERNEL);
2731 if (!packet->buf_start) {
2732 kfree(packet);
2733 break;
2734 }
2735 2755
2736 packet->buf_len = ctrl_bufsz; 2756 return target;
2737 if (i < NUM_CONTROL_RX_BUFFERS) {
2738 packet->act_len = 0;
2739 packet->buf = packet->buf_start;
2740 packet->endpoint = ENDPOINT_0;
2741 list_add_tail(&packet->list, &target->free_ctrl_rxbuf);
2742 } else
2743 list_add_tail(&packet->list, &target->free_ctrl_txbuf);
2744 }
2745 2757
2746fail_create_htc: 2758err_htc_cleanup:
2747 if (i != NUM_CONTROL_BUFFERS || status) { 2759 ath6kl_htc_cleanup(target);
2748 if (target) {
2749 ath6kl_htc_cleanup(target);
2750 target = NULL;
2751 }
2752 }
2753 2760
2754 return target; 2761 return NULL;
2755} 2762}
2756 2763
2757/* cleanup the HTC instance */ 2764/* cleanup the HTC instance */