diff options
author | Mark Haverkamp <markh@osdl.org> | 2005-08-03 18:39:09 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-08-05 17:51:57 -0400 |
commit | e53cb35aaefb83de695e3fd305b9cfabd5bf8c86 (patch) | |
tree | a867bcdd28f7e0d7e735b10086e02337875bdbaa /drivers/scsi | |
parent | bd1aac809ddbcf7772cfd809d8cfb29c729c6cf9 (diff) |
[SCSI] aacraid: remove duplicate io callback code
Received from Mark Salyzyn from Adaptec:
This patch removes the duplicate code in the write_callback command
completion handler, and renames read_callback to io_callback. Optimized
the lba calculation into the debug print routine macro to optimize the
i/o code path.
Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/aacraid/aachba.c | 63 |
1 files changed, 7 insertions, 56 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index ccdf440021fb..b03c8dee76b7 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -814,12 +814,11 @@ int aac_get_adapter_info(struct aac_dev* dev) | |||
814 | } | 814 | } |
815 | 815 | ||
816 | 816 | ||
817 | static void read_callback(void *context, struct fib * fibptr) | 817 | static void io_callback(void *context, struct fib * fibptr) |
818 | { | 818 | { |
819 | struct aac_dev *dev; | 819 | struct aac_dev *dev; |
820 | struct aac_read_reply *readreply; | 820 | struct aac_read_reply *readreply; |
821 | struct scsi_cmnd *scsicmd; | 821 | struct scsi_cmnd *scsicmd; |
822 | u32 lba; | ||
823 | u32 cid; | 822 | u32 cid; |
824 | 823 | ||
825 | scsicmd = (struct scsi_cmnd *) context; | 824 | scsicmd = (struct scsi_cmnd *) context; |
@@ -827,8 +826,7 @@ static void read_callback(void *context, struct fib * fibptr) | |||
827 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; | 826 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
828 | cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun); | 827 | cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun); |
829 | 828 | ||
830 | lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; | 829 | dprintk((KERN_DEBUG "io_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3], jiffies)); |
831 | dprintk((KERN_DEBUG "read_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies)); | ||
832 | 830 | ||
833 | if (fibptr == NULL) | 831 | if (fibptr == NULL) |
834 | BUG(); | 832 | BUG(); |
@@ -847,7 +845,7 @@ static void read_callback(void *context, struct fib * fibptr) | |||
847 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; | 845 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
848 | else { | 846 | else { |
849 | #ifdef AAC_DETAILED_STATUS_INFO | 847 | #ifdef AAC_DETAILED_STATUS_INFO |
850 | printk(KERN_WARNING "read_callback: io failed, status = %d\n", | 848 | printk(KERN_WARNING "io_callback: io failed, status = %d\n", |
851 | le32_to_cpu(readreply->status)); | 849 | le32_to_cpu(readreply->status)); |
852 | #endif | 850 | #endif |
853 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; | 851 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
@@ -867,53 +865,6 @@ static void read_callback(void *context, struct fib * fibptr) | |||
867 | aac_io_done(scsicmd); | 865 | aac_io_done(scsicmd); |
868 | } | 866 | } |
869 | 867 | ||
870 | static void write_callback(void *context, struct fib * fibptr) | ||
871 | { | ||
872 | struct aac_dev *dev; | ||
873 | struct aac_write_reply *writereply; | ||
874 | struct scsi_cmnd *scsicmd; | ||
875 | u32 lba; | ||
876 | u32 cid; | ||
877 | |||
878 | scsicmd = (struct scsi_cmnd *) context; | ||
879 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; | ||
880 | cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun); | ||
881 | |||
882 | lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; | ||
883 | dprintk((KERN_DEBUG "write_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies)); | ||
884 | if (fibptr == NULL) | ||
885 | BUG(); | ||
886 | |||
887 | if(scsicmd->use_sg) | ||
888 | pci_unmap_sg(dev->pdev, | ||
889 | (struct scatterlist *)scsicmd->buffer, | ||
890 | scsicmd->use_sg, | ||
891 | scsicmd->sc_data_direction); | ||
892 | else if(scsicmd->request_bufflen) | ||
893 | pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle, | ||
894 | scsicmd->request_bufflen, | ||
895 | scsicmd->sc_data_direction); | ||
896 | |||
897 | writereply = (struct aac_write_reply *) fib_data(fibptr); | ||
898 | if (le32_to_cpu(writereply->status) == ST_OK) | ||
899 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; | ||
900 | else { | ||
901 | printk(KERN_WARNING "write_callback: write failed, status = %d\n", writereply->status); | ||
902 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; | ||
903 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | ||
904 | HARDWARE_ERROR, | ||
905 | SENCODE_INTERNAL_TARGET_FAILURE, | ||
906 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, | ||
907 | 0, 0); | ||
908 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | ||
909 | sizeof(struct sense_data)); | ||
910 | } | ||
911 | |||
912 | fib_complete(fibptr); | ||
913 | fib_free(fibptr); | ||
914 | aac_io_done(scsicmd); | ||
915 | } | ||
916 | |||
917 | static int aac_read(struct scsi_cmnd * scsicmd, int cid) | 868 | static int aac_read(struct scsi_cmnd * scsicmd, int cid) |
918 | { | 869 | { |
919 | u32 lba; | 870 | u32 lba; |
@@ -978,7 +929,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) | |||
978 | fibsize, | 929 | fibsize, |
979 | FsaNormal, | 930 | FsaNormal, |
980 | 0, 1, | 931 | 0, 1, |
981 | (fib_callback) read_callback, | 932 | (fib_callback) io_callback, |
982 | (void *) scsicmd); | 933 | (void *) scsicmd); |
983 | } else { | 934 | } else { |
984 | struct aac_read *readcmd; | 935 | struct aac_read *readcmd; |
@@ -1002,7 +953,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) | |||
1002 | fibsize, | 953 | fibsize, |
1003 | FsaNormal, | 954 | FsaNormal, |
1004 | 0, 1, | 955 | 0, 1, |
1005 | (fib_callback) read_callback, | 956 | (fib_callback) io_callback, |
1006 | (void *) scsicmd); | 957 | (void *) scsicmd); |
1007 | } | 958 | } |
1008 | 959 | ||
@@ -1085,7 +1036,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid) | |||
1085 | fibsize, | 1036 | fibsize, |
1086 | FsaNormal, | 1037 | FsaNormal, |
1087 | 0, 1, | 1038 | 0, 1, |
1088 | (fib_callback) write_callback, | 1039 | (fib_callback) io_callback, |
1089 | (void *) scsicmd); | 1040 | (void *) scsicmd); |
1090 | } else { | 1041 | } else { |
1091 | struct aac_write *writecmd; | 1042 | struct aac_write *writecmd; |
@@ -1111,7 +1062,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid) | |||
1111 | fibsize, | 1062 | fibsize, |
1112 | FsaNormal, | 1063 | FsaNormal, |
1113 | 0, 1, | 1064 | 0, 1, |
1114 | (fib_callback) write_callback, | 1065 | (fib_callback) io_callback, |
1115 | (void *) scsicmd); | 1066 | (void *) scsicmd); |
1116 | } | 1067 | } |
1117 | 1068 | ||