diff options
Diffstat (limited to 'sound/pci/asihpi/hpimsgx.c')
-rw-r--r-- | sound/pci/asihpi/hpimsgx.c | 218 |
1 files changed, 56 insertions, 162 deletions
diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c index f01ab964f602..7352a5f7b4f7 100644 --- a/sound/pci/asihpi/hpimsgx.c +++ b/sound/pci/asihpi/hpimsgx.c | |||
@@ -23,6 +23,7 @@ Extended Message Function With Response Cacheing | |||
23 | #define SOURCEFILE_NAME "hpimsgx.c" | 23 | #define SOURCEFILE_NAME "hpimsgx.c" |
24 | #include "hpi_internal.h" | 24 | #include "hpi_internal.h" |
25 | #include "hpimsginit.h" | 25 | #include "hpimsginit.h" |
26 | #include "hpicmn.h" | ||
26 | #include "hpimsgx.h" | 27 | #include "hpimsgx.h" |
27 | #include "hpidebug.h" | 28 | #include "hpidebug.h" |
28 | 29 | ||
@@ -42,22 +43,24 @@ static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci | |||
42 | 43 | ||
43 | for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) { | 44 | for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) { |
44 | if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID | 45 | if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID |
45 | && asihpi_pci_tbl[i].vendor != pci_info->vendor_id) | 46 | && asihpi_pci_tbl[i].vendor != |
47 | pci_info->pci_dev->vendor) | ||
46 | continue; | 48 | continue; |
47 | if (asihpi_pci_tbl[i].device != PCI_ANY_ID | 49 | if (asihpi_pci_tbl[i].device != PCI_ANY_ID |
48 | && asihpi_pci_tbl[i].device != pci_info->device_id) | 50 | && asihpi_pci_tbl[i].device != |
51 | pci_info->pci_dev->device) | ||
49 | continue; | 52 | continue; |
50 | if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID | 53 | if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID |
51 | && asihpi_pci_tbl[i].subvendor != | 54 | && asihpi_pci_tbl[i].subvendor != |
52 | pci_info->subsys_vendor_id) | 55 | pci_info->pci_dev->subsystem_vendor) |
53 | continue; | 56 | continue; |
54 | if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID | 57 | if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID |
55 | && asihpi_pci_tbl[i].subdevice != | 58 | && asihpi_pci_tbl[i].subdevice != |
56 | pci_info->subsys_device_id) | 59 | pci_info->pci_dev->subsystem_device) |
57 | continue; | 60 | continue; |
58 | 61 | ||
59 | HPI_DEBUG_LOG(DEBUG, " %x,%lu\n", i, | 62 | /* HPI_DEBUG_LOG(DEBUG, " %x,%lx\n", i, |
60 | asihpi_pci_tbl[i].driver_data); | 63 | asihpi_pci_tbl[i].driver_data); */ |
61 | return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data; | 64 | return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data; |
62 | } | 65 | } |
63 | 66 | ||
@@ -67,21 +70,12 @@ static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci | |||
67 | static inline void hw_entry_point(struct hpi_message *phm, | 70 | static inline void hw_entry_point(struct hpi_message *phm, |
68 | struct hpi_response *phr) | 71 | struct hpi_response *phr) |
69 | { | 72 | { |
70 | 73 | if ((phm->adapter_index < HPI_MAX_ADAPTERS) | |
71 | hpi_handler_func *ep; | 74 | && hpi_entry_points[phm->adapter_index]) |
72 | 75 | hpi_entry_points[phm->adapter_index] (phm, phr); | |
73 | if (phm->adapter_index < HPI_MAX_ADAPTERS) { | 76 | else |
74 | ep = (hpi_handler_func *) hpi_entry_points[phm-> | 77 | hpi_init_response(phr, phm->object, phm->function, |
75 | adapter_index]; | 78 | HPI_ERROR_PROCESSING_MESSAGE); |
76 | if (ep) { | ||
77 | HPI_DEBUG_MESSAGE(DEBUG, phm); | ||
78 | ep(phm, phr); | ||
79 | HPI_DEBUG_RESPONSE(phr); | ||
80 | return; | ||
81 | } | ||
82 | } | ||
83 | hpi_init_response(phr, phm->object, phm->function, | ||
84 | HPI_ERROR_PROCESSING_MESSAGE); | ||
85 | } | 79 | } |
86 | 80 | ||
87 | static void adapter_open(struct hpi_message *phm, struct hpi_response *phr); | 81 | static void adapter_open(struct hpi_message *phm, struct hpi_response *phr); |
@@ -100,6 +94,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr, | |||
100 | void *h_owner); | 94 | void *h_owner); |
101 | 95 | ||
102 | static void HPIMSGX__reset(u16 adapter_index); | 96 | static void HPIMSGX__reset(u16 adapter_index); |
97 | |||
103 | static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr); | 98 | static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr); |
104 | static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner); | 99 | static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner); |
105 | 100 | ||
@@ -153,8 +148,6 @@ static struct hpi_stream_response | |||
153 | 148 | ||
154 | static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS]; | 149 | static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS]; |
155 | 150 | ||
156 | static struct hpi_subsys_response gRESP_HPI_SUBSYS_FIND_ADAPTERS; | ||
157 | |||
158 | static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS]; | 151 | static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS]; |
159 | 152 | ||
160 | /* use these to keep track of opens from user mode apps/DLLs */ | 153 | /* use these to keep track of opens from user mode apps/DLLs */ |
@@ -167,6 +160,11 @@ static struct asi_open_state | |||
167 | static void subsys_message(struct hpi_message *phm, struct hpi_response *phr, | 160 | static void subsys_message(struct hpi_message *phm, struct hpi_response *phr, |
168 | void *h_owner) | 161 | void *h_owner) |
169 | { | 162 | { |
163 | if (phm->adapter_index != HPI_ADAPTER_INDEX_INVALID) | ||
164 | HPI_DEBUG_LOG(WARNING, | ||
165 | "suspicious adapter index %d in subsys message 0x%x.\n", | ||
166 | phm->adapter_index, phm->function); | ||
167 | |||
170 | switch (phm->function) { | 168 | switch (phm->function) { |
171 | case HPI_SUBSYS_GET_VERSION: | 169 | case HPI_SUBSYS_GET_VERSION: |
172 | hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, | 170 | hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, |
@@ -204,85 +202,19 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr, | |||
204 | HPI_SUBSYS_DRIVER_UNLOAD, 0); | 202 | HPI_SUBSYS_DRIVER_UNLOAD, 0); |
205 | return; | 203 | return; |
206 | 204 | ||
207 | case HPI_SUBSYS_GET_INFO: | ||
208 | HPI_COMMON(phm, phr); | ||
209 | break; | ||
210 | |||
211 | case HPI_SUBSYS_FIND_ADAPTERS: | ||
212 | memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS, | ||
213 | sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS)); | ||
214 | break; | ||
215 | case HPI_SUBSYS_GET_NUM_ADAPTERS: | 205 | case HPI_SUBSYS_GET_NUM_ADAPTERS: |
216 | memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS, | ||
217 | sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS)); | ||
218 | phr->function = HPI_SUBSYS_GET_NUM_ADAPTERS; | ||
219 | break; | ||
220 | case HPI_SUBSYS_GET_ADAPTER: | 206 | case HPI_SUBSYS_GET_ADAPTER: |
221 | { | 207 | HPI_COMMON(phm, phr); |
222 | int count = phm->adapter_index; | 208 | break; |
223 | int index = 0; | ||
224 | hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, | ||
225 | HPI_SUBSYS_GET_ADAPTER, 0); | ||
226 | |||
227 | /* This is complicated by the fact that we want to | ||
228 | * "skip" 0's in the adapter list. | ||
229 | * First, make sure we are pointing to a | ||
230 | * non-zero adapter type. | ||
231 | */ | ||
232 | while (gRESP_HPI_SUBSYS_FIND_ADAPTERS. | ||
233 | s.aw_adapter_list[index] == 0) { | ||
234 | index++; | ||
235 | if (index >= HPI_MAX_ADAPTERS) | ||
236 | break; | ||
237 | } | ||
238 | while (count) { | ||
239 | /* move on to the next adapter */ | ||
240 | index++; | ||
241 | if (index >= HPI_MAX_ADAPTERS) | ||
242 | break; | ||
243 | while (gRESP_HPI_SUBSYS_FIND_ADAPTERS. | ||
244 | s.aw_adapter_list[index] == 0) { | ||
245 | index++; | ||
246 | if (index >= HPI_MAX_ADAPTERS) | ||
247 | break; | ||
248 | } | ||
249 | count--; | ||
250 | } | ||
251 | 209 | ||
252 | if (index < HPI_MAX_ADAPTERS) { | ||
253 | phr->u.s.adapter_index = (u16)index; | ||
254 | phr->u.s.aw_adapter_list[0] = | ||
255 | gRESP_HPI_SUBSYS_FIND_ADAPTERS. | ||
256 | s.aw_adapter_list[index]; | ||
257 | } else { | ||
258 | phr->u.s.adapter_index = 0; | ||
259 | phr->u.s.aw_adapter_list[0] = 0; | ||
260 | phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER; | ||
261 | } | ||
262 | break; | ||
263 | } | ||
264 | case HPI_SUBSYS_CREATE_ADAPTER: | 210 | case HPI_SUBSYS_CREATE_ADAPTER: |
265 | HPIMSGX__init(phm, phr); | 211 | HPIMSGX__init(phm, phr); |
266 | break; | 212 | break; |
267 | case HPI_SUBSYS_DELETE_ADAPTER: | 213 | |
268 | HPIMSGX__cleanup(phm->adapter_index, h_owner); | ||
269 | { | ||
270 | struct hpi_message hm; | ||
271 | struct hpi_response hr; | ||
272 | /* call to HPI_ADAPTER_CLOSE */ | ||
273 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, | ||
274 | HPI_ADAPTER_CLOSE); | ||
275 | hm.adapter_index = phm->adapter_index; | ||
276 | hw_entry_point(&hm, &hr); | ||
277 | } | ||
278 | hw_entry_point(phm, phr); | ||
279 | gRESP_HPI_SUBSYS_FIND_ADAPTERS.s. | ||
280 | aw_adapter_list[phm->adapter_index] | ||
281 | = 0; | ||
282 | hpi_entry_points[phm->adapter_index] = NULL; | ||
283 | break; | ||
284 | default: | 214 | default: |
285 | hw_entry_point(phm, phr); | 215 | /* Must explicitly handle every subsys message in this switch */ |
216 | hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function, | ||
217 | HPI_ERROR_INVALID_FUNC); | ||
286 | break; | 218 | break; |
287 | } | 219 | } |
288 | } | 220 | } |
@@ -297,6 +229,19 @@ static void adapter_message(struct hpi_message *phm, struct hpi_response *phr, | |||
297 | case HPI_ADAPTER_CLOSE: | 229 | case HPI_ADAPTER_CLOSE: |
298 | adapter_close(phm, phr); | 230 | adapter_close(phm, phr); |
299 | break; | 231 | break; |
232 | case HPI_ADAPTER_DELETE: | ||
233 | HPIMSGX__cleanup(phm->adapter_index, h_owner); | ||
234 | { | ||
235 | struct hpi_message hm; | ||
236 | struct hpi_response hr; | ||
237 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, | ||
238 | HPI_ADAPTER_CLOSE); | ||
239 | hm.adapter_index = phm->adapter_index; | ||
240 | hw_entry_point(&hm, &hr); | ||
241 | } | ||
242 | hw_entry_point(phm, phr); | ||
243 | break; | ||
244 | |||
300 | default: | 245 | default: |
301 | hw_entry_point(phm, phr); | 246 | hw_entry_point(phm, phr); |
302 | break; | 247 | break; |
@@ -409,33 +354,7 @@ void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr, | |||
409 | break; | 354 | break; |
410 | } | 355 | } |
411 | HPI_DEBUG_RESPONSE(phr); | 356 | HPI_DEBUG_RESPONSE(phr); |
412 | #if 1 | 357 | |
413 | if (phr->error >= HPI_ERROR_BACKEND_BASE) { | ||
414 | void *ep = NULL; | ||
415 | char *ep_name; | ||
416 | |||
417 | HPI_DEBUG_MESSAGE(ERROR, phm); | ||
418 | |||
419 | if (phm->adapter_index < HPI_MAX_ADAPTERS) | ||
420 | ep = hpi_entry_points[phm->adapter_index]; | ||
421 | |||
422 | /* Don't need this? Have adapter index in debug info | ||
423 | Know at driver load time index->backend mapping */ | ||
424 | if (ep == HPI_6000) | ||
425 | ep_name = "HPI_6000"; | ||
426 | else if (ep == HPI_6205) | ||
427 | ep_name = "HPI_6205"; | ||
428 | else | ||
429 | ep_name = "unknown"; | ||
430 | |||
431 | HPI_DEBUG_LOG(ERROR, "HPI %s response - error# %d\n", ep_name, | ||
432 | phr->error); | ||
433 | |||
434 | if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) | ||
435 | hpi_debug_data((u16 *)phm, | ||
436 | sizeof(*phm) / sizeof(u16)); | ||
437 | } | ||
438 | #endif | ||
439 | } | 358 | } |
440 | 359 | ||
441 | static void adapter_open(struct hpi_message *phm, struct hpi_response *phr) | 360 | static void adapter_open(struct hpi_message *phm, struct hpi_response *phr) |
@@ -484,7 +403,7 @@ static void instream_open(struct hpi_message *phm, struct hpi_response *phr, | |||
484 | else { | 403 | else { |
485 | instream_user_open[phm->adapter_index][phm-> | 404 | instream_user_open[phm->adapter_index][phm-> |
486 | obj_index].open_flag = 1; | 405 | obj_index].open_flag = 1; |
487 | hpios_msgxlock_un_lock(&msgx_lock); | 406 | hpios_msgxlock_unlock(&msgx_lock); |
488 | 407 | ||
489 | /* issue a reset */ | 408 | /* issue a reset */ |
490 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, | 409 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, |
@@ -509,7 +428,7 @@ static void instream_open(struct hpi_message *phm, struct hpi_response *phr, | |||
509 | sizeof(rESP_HPI_ISTREAM_OPEN[0][0])); | 428 | sizeof(rESP_HPI_ISTREAM_OPEN[0][0])); |
510 | } | 429 | } |
511 | } | 430 | } |
512 | hpios_msgxlock_un_lock(&msgx_lock); | 431 | hpios_msgxlock_unlock(&msgx_lock); |
513 | } | 432 | } |
514 | 433 | ||
515 | static void instream_close(struct hpi_message *phm, struct hpi_response *phr, | 434 | static void instream_close(struct hpi_message *phm, struct hpi_response *phr, |
@@ -530,7 +449,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr, | |||
530 | phm->wAdapterIndex, phm->wObjIndex, hOwner); */ | 449 | phm->wAdapterIndex, phm->wObjIndex, hOwner); */ |
531 | instream_user_open[phm->adapter_index][phm-> | 450 | instream_user_open[phm->adapter_index][phm-> |
532 | obj_index].h_owner = NULL; | 451 | obj_index].h_owner = NULL; |
533 | hpios_msgxlock_un_lock(&msgx_lock); | 452 | hpios_msgxlock_unlock(&msgx_lock); |
534 | /* issue a reset */ | 453 | /* issue a reset */ |
535 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, | 454 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM, |
536 | HPI_ISTREAM_RESET); | 455 | HPI_ISTREAM_RESET); |
@@ -556,7 +475,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr, | |||
556 | obj_index].h_owner); | 475 | obj_index].h_owner); |
557 | phr->error = HPI_ERROR_OBJ_NOT_OPEN; | 476 | phr->error = HPI_ERROR_OBJ_NOT_OPEN; |
558 | } | 477 | } |
559 | hpios_msgxlock_un_lock(&msgx_lock); | 478 | hpios_msgxlock_unlock(&msgx_lock); |
560 | } | 479 | } |
561 | 480 | ||
562 | static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, | 481 | static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, |
@@ -581,7 +500,7 @@ static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, | |||
581 | else { | 500 | else { |
582 | outstream_user_open[phm->adapter_index][phm-> | 501 | outstream_user_open[phm->adapter_index][phm-> |
583 | obj_index].open_flag = 1; | 502 | obj_index].open_flag = 1; |
584 | hpios_msgxlock_un_lock(&msgx_lock); | 503 | hpios_msgxlock_unlock(&msgx_lock); |
585 | 504 | ||
586 | /* issue a reset */ | 505 | /* issue a reset */ |
587 | hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, | 506 | hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, |
@@ -606,7 +525,7 @@ static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, | |||
606 | sizeof(rESP_HPI_OSTREAM_OPEN[0][0])); | 525 | sizeof(rESP_HPI_OSTREAM_OPEN[0][0])); |
607 | } | 526 | } |
608 | } | 527 | } |
609 | hpios_msgxlock_un_lock(&msgx_lock); | 528 | hpios_msgxlock_unlock(&msgx_lock); |
610 | } | 529 | } |
611 | 530 | ||
612 | static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, | 531 | static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, |
@@ -628,7 +547,7 @@ static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, | |||
628 | phm->wAdapterIndex, phm->wObjIndex, hOwner); */ | 547 | phm->wAdapterIndex, phm->wObjIndex, hOwner); */ |
629 | outstream_user_open[phm->adapter_index][phm-> | 548 | outstream_user_open[phm->adapter_index][phm-> |
630 | obj_index].h_owner = NULL; | 549 | obj_index].h_owner = NULL; |
631 | hpios_msgxlock_un_lock(&msgx_lock); | 550 | hpios_msgxlock_unlock(&msgx_lock); |
632 | /* issue a reset */ | 551 | /* issue a reset */ |
633 | hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, | 552 | hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, |
634 | HPI_OSTREAM_RESET); | 553 | HPI_OSTREAM_RESET); |
@@ -654,7 +573,7 @@ static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, | |||
654 | obj_index].h_owner); | 573 | obj_index].h_owner); |
655 | phr->error = HPI_ERROR_OBJ_NOT_OPEN; | 574 | phr->error = HPI_ERROR_OBJ_NOT_OPEN; |
656 | } | 575 | } |
657 | hpios_msgxlock_un_lock(&msgx_lock); | 576 | hpios_msgxlock_unlock(&msgx_lock); |
658 | } | 577 | } |
659 | 578 | ||
660 | static u16 adapter_prepare(u16 adapter) | 579 | static u16 adapter_prepare(u16 adapter) |
@@ -683,16 +602,9 @@ static u16 adapter_prepare(u16 adapter) | |||
683 | if (hr.error) | 602 | if (hr.error) |
684 | return hr.error; | 603 | return hr.error; |
685 | 604 | ||
686 | aDAPTER_INFO[adapter].num_outstreams = hr.u.a.num_outstreams; | 605 | aDAPTER_INFO[adapter].num_outstreams = hr.u.ax.info.num_outstreams; |
687 | aDAPTER_INFO[adapter].num_instreams = hr.u.a.num_instreams; | 606 | aDAPTER_INFO[adapter].num_instreams = hr.u.ax.info.num_instreams; |
688 | aDAPTER_INFO[adapter].type = hr.u.a.adapter_type; | 607 | aDAPTER_INFO[adapter].type = hr.u.ax.info.adapter_type; |
689 | |||
690 | gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list[adapter] = | ||
691 | hr.u.a.adapter_type; | ||
692 | gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters++; | ||
693 | if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters > HPI_MAX_ADAPTERS) | ||
694 | gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters = | ||
695 | HPI_MAX_ADAPTERS; | ||
696 | 608 | ||
697 | /* call to HPI_OSTREAM_OPEN */ | 609 | /* call to HPI_OSTREAM_OPEN */ |
698 | for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) { | 610 | for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) { |
@@ -727,7 +639,7 @@ static u16 adapter_prepare(u16 adapter) | |||
727 | memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr, | 639 | memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr, |
728 | sizeof(rESP_HPI_MIXER_OPEN[0])); | 640 | sizeof(rESP_HPI_MIXER_OPEN[0])); |
729 | 641 | ||
730 | return gRESP_HPI_SUBSYS_FIND_ADAPTERS.h.error; | 642 | return 0; |
731 | } | 643 | } |
732 | 644 | ||
733 | static void HPIMSGX__reset(u16 adapter_index) | 645 | static void HPIMSGX__reset(u16 adapter_index) |
@@ -737,12 +649,6 @@ static void HPIMSGX__reset(u16 adapter_index) | |||
737 | struct hpi_response hr; | 649 | struct hpi_response hr; |
738 | 650 | ||
739 | if (adapter_index == HPIMSGX_ALLADAPTERS) { | 651 | if (adapter_index == HPIMSGX_ALLADAPTERS) { |
740 | /* reset all responses to contain errors */ | ||
741 | hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, | ||
742 | HPI_SUBSYS_FIND_ADAPTERS, 0); | ||
743 | memcpy(&gRESP_HPI_SUBSYS_FIND_ADAPTERS, &hr, | ||
744 | sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS)); | ||
745 | |||
746 | for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) { | 652 | for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) { |
747 | 653 | ||
748 | hpi_init_response(&hr, HPI_OBJ_ADAPTER, | 654 | hpi_init_response(&hr, HPI_OBJ_ADAPTER, |
@@ -783,12 +689,6 @@ static void HPIMSGX__reset(u16 adapter_index) | |||
783 | rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error = | 689 | rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error = |
784 | HPI_ERROR_INVALID_OBJ; | 690 | HPI_ERROR_INVALID_OBJ; |
785 | } | 691 | } |
786 | if (gRESP_HPI_SUBSYS_FIND_ADAPTERS. | ||
787 | s.aw_adapter_list[adapter_index]) { | ||
788 | gRESP_HPI_SUBSYS_FIND_ADAPTERS. | ||
789 | s.aw_adapter_list[adapter_index] = 0; | ||
790 | gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters--; | ||
791 | } | ||
792 | } | 692 | } |
793 | } | 693 | } |
794 | 694 | ||
@@ -802,15 +702,9 @@ static u16 HPIMSGX__init(struct hpi_message *phm, | |||
802 | hpi_handler_func *entry_point_func; | 702 | hpi_handler_func *entry_point_func; |
803 | struct hpi_response hr; | 703 | struct hpi_response hr; |
804 | 704 | ||
805 | if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters >= HPI_MAX_ADAPTERS) | ||
806 | return HPI_ERROR_BAD_ADAPTER_NUMBER; | ||
807 | |||
808 | /* Init response here so we can pass in previous adapter list */ | 705 | /* Init response here so we can pass in previous adapter list */ |
809 | hpi_init_response(&hr, phm->object, phm->function, | 706 | hpi_init_response(&hr, phm->object, phm->function, |
810 | HPI_ERROR_INVALID_OBJ); | 707 | HPI_ERROR_INVALID_OBJ); |
811 | memcpy(hr.u.s.aw_adapter_list, | ||
812 | gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list, | ||
813 | sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list)); | ||
814 | 708 | ||
815 | entry_point_func = | 709 | entry_point_func = |
816 | hpi_lookup_entry_point_function(phm->u.s.resource.r.pci); | 710 | hpi_lookup_entry_point_function(phm->u.s.resource.r.pci); |
@@ -823,7 +717,7 @@ static u16 HPIMSGX__init(struct hpi_message *phm, | |||
823 | return phr->error; | 717 | return phr->error; |
824 | } | 718 | } |
825 | if (hr.error == 0) { | 719 | if (hr.error == 0) { |
826 | /* the adapter was created succesfully | 720 | /* the adapter was created successfully |
827 | save the mapping for future use */ | 721 | save the mapping for future use */ |
828 | hpi_entry_points[hr.u.s.adapter_index] = entry_point_func; | 722 | hpi_entry_points[hr.u.s.adapter_index] = entry_point_func; |
829 | /* prepare adapter (pre-open streams etc.) */ | 723 | /* prepare adapter (pre-open streams etc.) */ |
@@ -860,7 +754,7 @@ static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner) | |||
860 | struct hpi_response hr; | 754 | struct hpi_response hr; |
861 | 755 | ||
862 | HPI_DEBUG_LOG(DEBUG, | 756 | HPI_DEBUG_LOG(DEBUG, |
863 | "close adapter %d ostream %d\n", | 757 | "Close adapter %d ostream %d\n", |
864 | adapter, i); | 758 | adapter, i); |
865 | 759 | ||
866 | hpi_init_message_response(&hm, &hr, | 760 | hpi_init_message_response(&hm, &hr, |
@@ -884,7 +778,7 @@ static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner) | |||
884 | struct hpi_response hr; | 778 | struct hpi_response hr; |
885 | 779 | ||
886 | HPI_DEBUG_LOG(DEBUG, | 780 | HPI_DEBUG_LOG(DEBUG, |
887 | "close adapter %d istream %d\n", | 781 | "Close adapter %d istream %d\n", |
888 | adapter, i); | 782 | adapter, i); |
889 | 783 | ||
890 | hpi_init_message_response(&hm, &hr, | 784 | hpi_init_message_response(&hm, &hr, |