diff options
author | Jay Fenlason <fenlason@redhat.com> | 2008-07-20 08:20:53 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2008-10-15 16:21:09 -0400 |
commit | 1e119fa9950dfe0e6d97470098db776110ca47a9 (patch) | |
tree | 02ad70ddae6d5cf4869c628e44dae97686a03d97 /drivers/firewire/fw-sbp2.c | |
parent | fc392fe83176cefbab99f9d12e6e27395aa2b5d0 (diff) |
firewire: fw_send_request_sync()
Share code between fw_send_request + wait_for_completion callers.
Signed-off-by: Jay Fenlason <fenlason@redhat.com>
Addendum:
Removes an unnecessary struct and an ununsed retry loop.
Calls it fw_run_transaction() instead of fw_send_request_sync().
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Acked-by: Kristian Høgsberg <krh@redhat.com>
Diffstat (limited to 'drivers/firewire/fw-sbp2.c')
-rw-r--r-- | drivers/firewire/fw-sbp2.c | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index aaff50ebba1..05997cee4f3 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c | |||
@@ -621,25 +621,15 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, | |||
621 | return retval; | 621 | return retval; |
622 | } | 622 | } |
623 | 623 | ||
624 | static void | ||
625 | complete_agent_reset_write(struct fw_card *card, int rcode, | ||
626 | void *payload, size_t length, void *done) | ||
627 | { | ||
628 | complete(done); | ||
629 | } | ||
630 | |||
631 | static void sbp2_agent_reset(struct sbp2_logical_unit *lu) | 624 | static void sbp2_agent_reset(struct sbp2_logical_unit *lu) |
632 | { | 625 | { |
633 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 626 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); |
634 | DECLARE_COMPLETION_ONSTACK(done); | 627 | __be32 d = 0; |
635 | struct fw_transaction t; | ||
636 | static u32 z; | ||
637 | 628 | ||
638 | fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST, | 629 | fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, |
639 | lu->tgt->node_id, lu->generation, device->max_speed, | 630 | lu->tgt->node_id, lu->generation, device->max_speed, |
640 | lu->command_block_agent_address + SBP2_AGENT_RESET, | 631 | lu->command_block_agent_address + SBP2_AGENT_RESET, |
641 | &z, sizeof(z), complete_agent_reset_write, &done); | 632 | &d, sizeof(d)); |
642 | wait_for_completion(&done); | ||
643 | } | 633 | } |
644 | 634 | ||
645 | static void | 635 | static void |
@@ -653,7 +643,7 @@ static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu) | |||
653 | { | 643 | { |
654 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 644 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); |
655 | struct fw_transaction *t; | 645 | struct fw_transaction *t; |
656 | static u32 z; | 646 | static __be32 d; |
657 | 647 | ||
658 | t = kmalloc(sizeof(*t), GFP_ATOMIC); | 648 | t = kmalloc(sizeof(*t), GFP_ATOMIC); |
659 | if (t == NULL) | 649 | if (t == NULL) |
@@ -662,7 +652,7 @@ static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu) | |||
662 | fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, | 652 | fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, |
663 | lu->tgt->node_id, lu->generation, device->max_speed, | 653 | lu->tgt->node_id, lu->generation, device->max_speed, |
664 | lu->command_block_agent_address + SBP2_AGENT_RESET, | 654 | lu->command_block_agent_address + SBP2_AGENT_RESET, |
665 | &z, sizeof(z), complete_agent_reset_write_no_wait, t); | 655 | &d, sizeof(d), complete_agent_reset_write_no_wait, t); |
666 | } | 656 | } |
667 | 657 | ||
668 | static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation) | 658 | static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation) |
@@ -823,13 +813,6 @@ static void sbp2_target_put(struct sbp2_target *tgt) | |||
823 | kref_put(&tgt->kref, sbp2_release_target); | 813 | kref_put(&tgt->kref, sbp2_release_target); |
824 | } | 814 | } |
825 | 815 | ||
826 | static void | ||
827 | complete_set_busy_timeout(struct fw_card *card, int rcode, | ||
828 | void *payload, size_t length, void *done) | ||
829 | { | ||
830 | complete(done); | ||
831 | } | ||
832 | |||
833 | /* | 816 | /* |
834 | * Write retransmit retry values into the BUSY_TIMEOUT register. | 817 | * Write retransmit retry values into the BUSY_TIMEOUT register. |
835 | * - The single-phase retry protocol is supported by all SBP-2 devices, but the | 818 | * - The single-phase retry protocol is supported by all SBP-2 devices, but the |
@@ -849,17 +832,12 @@ complete_set_busy_timeout(struct fw_card *card, int rcode, | |||
849 | static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) | 832 | static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) |
850 | { | 833 | { |
851 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 834 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); |
852 | DECLARE_COMPLETION_ONSTACK(done); | 835 | __be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT); |
853 | struct fw_transaction t; | ||
854 | static __be32 busy_timeout; | ||
855 | |||
856 | busy_timeout = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT); | ||
857 | 836 | ||
858 | fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST, | 837 | fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, |
859 | lu->tgt->node_id, lu->generation, device->max_speed, | 838 | lu->tgt->node_id, lu->generation, device->max_speed, |
860 | CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT, &busy_timeout, | 839 | CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT, |
861 | sizeof(busy_timeout), complete_set_busy_timeout, &done); | 840 | &d, sizeof(d)); |
862 | wait_for_completion(&done); | ||
863 | } | 841 | } |
864 | 842 | ||
865 | static void sbp2_reconnect(struct work_struct *work); | 843 | static void sbp2_reconnect(struct work_struct *work); |