aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@localhost.localdomain>2007-01-26 00:38:13 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-03-09 16:02:46 -0500
commit36bfe49d076404fcdf5766098de21724635a1816 (patch)
tree6b7fdeec717ddf47abfe2e3052951bcfc47f7905 /drivers/firewire
parente636fe2576be552252a5b63e9287915e810b37d8 (diff)
firewire: Clean up response handling.
Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/fw-transaction.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 4ca39f09f58a..a116ffa9bf45 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -107,9 +107,9 @@ transmit_complete_callback(struct fw_packet *packet,
107} 107}
108 108
109static void 109static void
110fw_fill_packet(struct fw_packet *packet, int tcode, int tlabel, 110fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
111 int node_id, int generation, int speed, 111 int node_id, int generation, int speed,
112 unsigned long long offset, void *payload, size_t length) 112 unsigned long long offset, void *payload, size_t length)
113{ 113{
114 int ext_tcode; 114 int ext_tcode;
115 115
@@ -240,8 +240,8 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
240 t->callback = callback; 240 t->callback = callback;
241 t->callback_data = callback_data; 241 t->callback_data = callback_data;
242 242
243 fw_fill_packet(&t->packet, tcode, t->tlabel, 243 fw_fill_request(&t->packet, tcode, t->tlabel,
244 node_id, generation, speed, offset, payload, length); 244 node_id, generation, speed, offset, payload, length);
245 t->packet.callback = transmit_complete_callback; 245 t->packet.callback = transmit_complete_callback;
246 246
247 card->driver->send_request(card, &t->packet); 247 card->driver->send_request(card, &t->packet);
@@ -409,6 +409,7 @@ EXPORT_SYMBOL(fw_core_remove_address_handler);
409 409
410struct fw_request { 410struct fw_request {
411 struct fw_packet response; 411 struct fw_packet response;
412 u32 request_header[4];
412 int ack; 413 int ack;
413 u32 length; 414 u32 length;
414 u32 data[0]; 415 u32 data[0];
@@ -425,22 +426,24 @@ free_response_callback(struct fw_packet *packet,
425} 426}
426 427
427static void 428static void
428fw_fill_response(struct fw_packet *response, 429fw_fill_response(struct fw_packet *response, u32 *request_header,
429 struct fw_packet *request, void *data) 430 int rcode, void *payload, size_t length)
430{ 431{
431 int tcode, tlabel, extended_tcode, source, destination; 432 int tcode, tlabel, extended_tcode, source, destination;
432 433
433 tcode = header_get_tcode(request->header[0]); 434 tcode = header_get_tcode(request_header[0]);
434 tlabel = header_get_tlabel(request->header[0]); 435 tlabel = header_get_tlabel(request_header[0]);
435 source = header_get_destination(request->header[0]); 436 source = header_get_destination(request_header[0]);
436 destination = header_get_source(request->header[1]); 437 destination = header_get_source(request_header[1]);
437 extended_tcode = header_get_extended_tcode(request->header[3]); 438 extended_tcode = header_get_extended_tcode(request_header[3]);
438 439
439 response->header[0] = 440 response->header[0] =
440 header_retry(RETRY_1) | 441 header_retry(RETRY_1) |
441 header_tlabel(tlabel) | 442 header_tlabel(tlabel) |
442 header_destination(destination); 443 header_destination(destination);
443 response->header[1] = header_source(source); 444 response->header[1] =
445 header_source(source) |
446 header_rcode(rcode);
444 response->header[2] = 0; 447 response->header[2] = 0;
445 448
446 switch (tcode) { 449 switch (tcode) {
@@ -454,7 +457,7 @@ fw_fill_response(struct fw_packet *response,
454 case TCODE_READ_QUADLET_REQUEST: 457 case TCODE_READ_QUADLET_REQUEST:
455 response->header[0] |= 458 response->header[0] |=
456 header_tcode(TCODE_READ_QUADLET_RESPONSE); 459 header_tcode(TCODE_READ_QUADLET_RESPONSE);
457 response->header[3] = 0; 460 response->header[3] = *(u32 *)payload;
458 response->header_length = 16; 461 response->header_length = 16;
459 response->payload_length = 0; 462 response->payload_length = 0;
460 break; 463 break;
@@ -463,11 +466,11 @@ fw_fill_response(struct fw_packet *response,
463 case TCODE_LOCK_REQUEST: 466 case TCODE_LOCK_REQUEST:
464 response->header[0] |= header_tcode(tcode + 2); 467 response->header[0] |= header_tcode(tcode + 2);
465 response->header[3] = 468 response->header[3] =
466 header_data_length(request->payload_length) | 469 header_data_length(length) |
467 header_extended_tcode(extended_tcode); 470 header_extended_tcode(extended_tcode);
468 response->header_length = 16; 471 response->header_length = 16;
469 response->payload = data; 472 response->payload = payload;
470 response->payload_length = request->payload_length; 473 response->payload_length = length;
471 break; 474 break;
472 475
473 default: 476 default:
@@ -530,7 +533,7 @@ allocate_request(struct fw_packet *p)
530 if (data) 533 if (data)
531 memcpy(request->data, p->payload, p->payload_length); 534 memcpy(request->data, p->payload, p->payload_length);
532 535
533 fw_fill_response(&request->response, p, request->data); 536 memcpy(request->request_header, p->header, sizeof p->header);
534 537
535 return request; 538 return request;
536} 539}
@@ -538,21 +541,18 @@ allocate_request(struct fw_packet *p)
538void 541void
539fw_send_response(struct fw_card *card, struct fw_request *request, int rcode) 542fw_send_response(struct fw_card *card, struct fw_request *request, int rcode)
540{ 543{
541 int response_tcode;
542
543 /* Broadcast packets are reported as ACK_COMPLETE, so this 544 /* Broadcast packets are reported as ACK_COMPLETE, so this
544 * check is sufficient to ensure we don't send response to 545 * check is sufficient to ensure we don't send response to
545 * broadcast packets or posted writes. */ 546 * broadcast packets or posted writes. */
546 if (request->ack != ACK_PENDING) 547 if (request->ack != ACK_PENDING)
547 return; 548 return;
548 549
549 request->response.header[1] |= header_rcode(rcode); 550 if (rcode == RCODE_COMPLETE)
550 response_tcode = header_get_tcode(request->response.header[0]); 551 fw_fill_response(&request->response, request->request_header,
551 if (rcode != RCODE_COMPLETE) 552 rcode, request->data, request->length);
552 /* Clear the data_length field. */ 553 else
553 request->response.header[3] &= 0xffff; 554 fw_fill_response(&request->response, request->request_header,
554 else if (response_tcode == TCODE_READ_QUADLET_RESPONSE) 555 rcode, NULL, 0);
555 request->response.header[3] = request->data[0];
556 556
557 card->driver->send_response(card, &request->response); 557 card->driver->send_response(card, &request->response);
558} 558}