aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/firewire/fw-sbp2.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index d7940db30a5b..a7525234c862 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -764,8 +764,11 @@ static struct fw_driver sbp2_driver = {
764 .id_table = sbp2_id_table, 764 .id_table = sbp2_id_table,
765}; 765};
766 766
767static unsigned int sbp2_status_to_sense_data(u8 * sbp2_status, u8 * sense_data) 767static unsigned int
768sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
768{ 769{
770 int sam_status;
771
769 sense_data[0] = 0x70; 772 sense_data[0] = 0x70;
770 sense_data[1] = 0x0; 773 sense_data[1] = 0x0;
771 sense_data[2] = sbp2_status[1]; 774 sense_data[2] = sbp2_status[1];
@@ -783,22 +786,19 @@ static unsigned int sbp2_status_to_sense_data(u8 * sbp2_status, u8 * sense_data)
783 sense_data[14] = sbp2_status[12]; 786 sense_data[14] = sbp2_status[12];
784 sense_data[15] = sbp2_status[13]; 787 sense_data[15] = sbp2_status[13];
785 788
786 switch (sbp2_status[0] & 0x3f) { 789 sam_status = sbp2_status[0] & 0x3f;
787 case SAM_STAT_GOOD:
788 return DID_OK;
789 790
791 switch (sam_status) {
792 case SAM_STAT_GOOD:
790 case SAM_STAT_CHECK_CONDITION: 793 case SAM_STAT_CHECK_CONDITION:
791 /* return CHECK_CONDITION << 1 | DID_OK << 16; */
792 return DID_OK;
793
794 case SAM_STAT_BUSY:
795 return DID_BUS_BUSY;
796
797 case SAM_STAT_CONDITION_MET: 794 case SAM_STAT_CONDITION_MET:
795 case SAM_STAT_BUSY:
798 case SAM_STAT_RESERVATION_CONFLICT: 796 case SAM_STAT_RESERVATION_CONFLICT:
799 case SAM_STAT_COMMAND_TERMINATED: 797 case SAM_STAT_COMMAND_TERMINATED:
798 return DID_OK << 16 | sam_status;
799
800 default: 800 default:
801 return DID_ERROR; 801 return DID_ERROR << 16;
802 } 802 }
803} 803}
804 804
@@ -812,33 +812,31 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
812 int result; 812 int result;
813 813
814 if (status != NULL) { 814 if (status != NULL) {
815 if (status_get_dead(*status)) { 815 if (status_get_dead(*status))
816 fw_notify("agent died, issuing agent reset\n");
817 sbp2_agent_reset(unit); 816 sbp2_agent_reset(unit);
818 }
819 817
820 switch (status_get_response(*status)) { 818 switch (status_get_response(*status)) {
821 case SBP2_STATUS_REQUEST_COMPLETE: 819 case SBP2_STATUS_REQUEST_COMPLETE:
822 result = DID_OK; 820 result = DID_OK << 16;
823 break; 821 break;
824 case SBP2_STATUS_TRANSPORT_FAILURE: 822 case SBP2_STATUS_TRANSPORT_FAILURE:
825 result = DID_BUS_BUSY; 823 result = DID_BUS_BUSY << 16;
826 break; 824 break;
827 case SBP2_STATUS_ILLEGAL_REQUEST: 825 case SBP2_STATUS_ILLEGAL_REQUEST:
828 case SBP2_STATUS_VENDOR_DEPENDENT: 826 case SBP2_STATUS_VENDOR_DEPENDENT:
829 default: 827 default:
830 result = DID_ERROR; 828 result = DID_ERROR << 16;
831 break; 829 break;
832 } 830 }
833 831
834 if (result == DID_OK && status_get_len(*status) > 1) 832 if (result == DID_OK << 16 && status_get_len(*status) > 1)
835 result = sbp2_status_to_sense_data(status_get_data(*status), 833 result = sbp2_status_to_sense_data(status_get_data(*status),
836 orb->cmd->sense_buffer); 834 orb->cmd->sense_buffer);
837 } else { 835 } else {
838 /* If the orb completes with status == NULL, something 836 /* If the orb completes with status == NULL, something
839 * went wrong, typically a bus reset happened mid-orb 837 * went wrong, typically a bus reset happened mid-orb
840 * or when sending the write (less likely). */ 838 * or when sending the write (less likely). */
841 result = DID_BUS_BUSY; 839 result = DID_BUS_BUSY << 16;
842 } 840 }
843 841
844 dma_unmap_single(device->card->device, orb->base.request_bus, 842 dma_unmap_single(device->card->device, orb->base.request_bus,
@@ -859,9 +857,8 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
859 sizeof orb->request_buffer_bus, 857 sizeof orb->request_buffer_bus,
860 DMA_FROM_DEVICE); 858 DMA_FROM_DEVICE);
861 859
862 orb->cmd->result = result << 16; 860 orb->cmd->result = result;
863 orb->done(orb->cmd); 861 orb->done(orb->cmd);
864
865 kfree(orb); 862 kfree(orb);
866} 863}
867 864