diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/htc_hst.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/htc_hst.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c index 7bf6ce1e7e2..064397fd738 100644 --- a/drivers/net/wireless/ath/ath9k/htc_hst.c +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c | |||
@@ -39,7 +39,7 @@ static struct htc_endpoint *get_next_avail_ep(struct htc_endpoint *endpoint) | |||
39 | { | 39 | { |
40 | enum htc_endpoint_id avail_epid; | 40 | enum htc_endpoint_id avail_epid; |
41 | 41 | ||
42 | for (avail_epid = ENDPOINT_MAX; avail_epid > ENDPOINT0; avail_epid--) | 42 | for (avail_epid = (ENDPOINT_MAX - 1); avail_epid > ENDPOINT0; avail_epid--) |
43 | if (endpoint[avail_epid].service_id == 0) | 43 | if (endpoint[avail_epid].service_id == 0) |
44 | return &endpoint[avail_epid]; | 44 | return &endpoint[avail_epid]; |
45 | return NULL; | 45 | return NULL; |
@@ -95,6 +95,7 @@ static void htc_process_target_rdy(struct htc_target *target, | |||
95 | endpoint = &target->endpoint[ENDPOINT0]; | 95 | endpoint = &target->endpoint[ENDPOINT0]; |
96 | endpoint->service_id = HTC_CTRL_RSVD_SVC; | 96 | endpoint->service_id = HTC_CTRL_RSVD_SVC; |
97 | endpoint->max_msglen = HTC_MAX_CONTROL_MESSAGE_LENGTH; | 97 | endpoint->max_msglen = HTC_MAX_CONTROL_MESSAGE_LENGTH; |
98 | atomic_inc(&target->tgt_ready); | ||
98 | complete(&target->target_wait); | 99 | complete(&target->target_wait); |
99 | } | 100 | } |
100 | 101 | ||
@@ -116,7 +117,7 @@ static void htc_process_conn_rsp(struct htc_target *target, | |||
116 | max_msglen = be16_to_cpu(svc_rspmsg->max_msg_len); | 117 | max_msglen = be16_to_cpu(svc_rspmsg->max_msg_len); |
117 | endpoint = &target->endpoint[epid]; | 118 | endpoint = &target->endpoint[epid]; |
118 | 119 | ||
119 | for (tepid = ENDPOINT_MAX; tepid > ENDPOINT0; tepid--) { | 120 | for (tepid = (ENDPOINT_MAX - 1); tepid > ENDPOINT0; tepid--) { |
120 | tmp_endpoint = &target->endpoint[tepid]; | 121 | tmp_endpoint = &target->endpoint[tepid]; |
121 | if (tmp_endpoint->service_id == service_id) { | 122 | if (tmp_endpoint->service_id == service_id) { |
122 | tmp_endpoint->service_id = 0; | 123 | tmp_endpoint->service_id = 0; |
@@ -124,7 +125,7 @@ static void htc_process_conn_rsp(struct htc_target *target, | |||
124 | } | 125 | } |
125 | } | 126 | } |
126 | 127 | ||
127 | if (!tmp_endpoint) | 128 | if (tepid == ENDPOINT0) |
128 | return; | 129 | return; |
129 | 130 | ||
130 | endpoint->service_id = service_id; | 131 | endpoint->service_id = service_id; |
@@ -297,7 +298,7 @@ void htc_stop(struct htc_target *target) | |||
297 | enum htc_endpoint_id epid; | 298 | enum htc_endpoint_id epid; |
298 | struct htc_endpoint *endpoint; | 299 | struct htc_endpoint *endpoint; |
299 | 300 | ||
300 | for (epid = ENDPOINT0; epid <= ENDPOINT_MAX; epid++) { | 301 | for (epid = ENDPOINT0; epid < ENDPOINT_MAX; epid++) { |
301 | endpoint = &target->endpoint[epid]; | 302 | endpoint = &target->endpoint[epid]; |
302 | if (endpoint->service_id != 0) | 303 | if (endpoint->service_id != 0) |
303 | target->hif->stop(target->hif_dev, endpoint->ul_pipeid); | 304 | target->hif->stop(target->hif_dev, endpoint->ul_pipeid); |
@@ -309,7 +310,7 @@ void htc_start(struct htc_target *target) | |||
309 | enum htc_endpoint_id epid; | 310 | enum htc_endpoint_id epid; |
310 | struct htc_endpoint *endpoint; | 311 | struct htc_endpoint *endpoint; |
311 | 312 | ||
312 | for (epid = ENDPOINT0; epid <= ENDPOINT_MAX; epid++) { | 313 | for (epid = ENDPOINT0; epid < ENDPOINT_MAX; epid++) { |
313 | endpoint = &target->endpoint[epid]; | 314 | endpoint = &target->endpoint[epid]; |
314 | if (endpoint->service_id != 0) | 315 | if (endpoint->service_id != 0) |
315 | target->hif->start(target->hif_dev, | 316 | target->hif->start(target->hif_dev, |
@@ -425,29 +426,19 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle, | |||
425 | } | 426 | } |
426 | } | 427 | } |
427 | 428 | ||
428 | struct htc_target *ath9k_htc_hw_alloc(void *hif_handle) | 429 | struct htc_target *ath9k_htc_hw_alloc(void *hif_handle, |
430 | struct ath9k_htc_hif *hif, | ||
431 | struct device *dev) | ||
429 | { | 432 | { |
433 | struct htc_endpoint *endpoint; | ||
430 | struct htc_target *target; | 434 | struct htc_target *target; |
431 | 435 | ||
432 | target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); | 436 | target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); |
433 | if (!target) | 437 | if (!target) { |
434 | printk(KERN_ERR "Unable to allocate memory for" | 438 | printk(KERN_ERR "Unable to allocate memory for" |
435 | "target device\n"); | 439 | "target device\n"); |
436 | 440 | return NULL; | |
437 | return target; | 441 | } |
438 | } | ||
439 | |||
440 | void ath9k_htc_hw_free(struct htc_target *htc) | ||
441 | { | ||
442 | kfree(htc); | ||
443 | } | ||
444 | |||
445 | int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target, | ||
446 | void *hif_handle, struct device *dev, u16 devid, | ||
447 | enum ath9k_hif_transports transport) | ||
448 | { | ||
449 | struct htc_endpoint *endpoint; | ||
450 | int err = 0; | ||
451 | 442 | ||
452 | init_completion(&target->target_wait); | 443 | init_completion(&target->target_wait); |
453 | init_completion(&target->cmd_wait); | 444 | init_completion(&target->cmd_wait); |
@@ -461,8 +452,20 @@ int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target, | |||
461 | endpoint->ul_pipeid = hif->control_ul_pipe; | 452 | endpoint->ul_pipeid = hif->control_ul_pipe; |
462 | endpoint->dl_pipeid = hif->control_dl_pipe; | 453 | endpoint->dl_pipeid = hif->control_dl_pipe; |
463 | 454 | ||
464 | err = ath9k_htc_probe_device(target, dev, devid); | 455 | atomic_set(&target->tgt_ready, 0); |
465 | if (err) { | 456 | |
457 | return target; | ||
458 | } | ||
459 | |||
460 | void ath9k_htc_hw_free(struct htc_target *htc) | ||
461 | { | ||
462 | kfree(htc); | ||
463 | } | ||
464 | |||
465 | int ath9k_htc_hw_init(struct htc_target *target, | ||
466 | struct device *dev, u16 devid) | ||
467 | { | ||
468 | if (ath9k_htc_probe_device(target, dev, devid)) { | ||
466 | printk(KERN_ERR "Failed to initialize the device\n"); | 469 | printk(KERN_ERR "Failed to initialize the device\n"); |
467 | return -ENODEV; | 470 | return -ENODEV; |
468 | } | 471 | } |