aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/sx8.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 52dc5e131718..cd5674b63faf 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -744,16 +744,14 @@ static unsigned int carm_fill_get_fw_ver(struct carm_host *host,
744 744
745static inline void carm_end_request_queued(struct carm_host *host, 745static inline void carm_end_request_queued(struct carm_host *host,
746 struct carm_request *crq, 746 struct carm_request *crq,
747 int uptodate) 747 int error)
748{ 748{
749 struct request *req = crq->rq; 749 struct request *req = crq->rq;
750 int rc; 750 int rc;
751 751
752 rc = end_that_request_first(req, uptodate, req->hard_nr_sectors); 752 rc = __blk_end_request(req, error, blk_rq_bytes(req));
753 assert(rc == 0); 753 assert(rc == 0);
754 754
755 end_that_request_last(req, uptodate);
756
757 rc = carm_put_request(host, crq); 755 rc = carm_put_request(host, crq);
758 assert(rc == 0); 756 assert(rc == 0);
759} 757}
@@ -793,9 +791,9 @@ static inline void carm_round_robin(struct carm_host *host)
793} 791}
794 792
795static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq, 793static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq,
796 int is_ok) 794 int error)
797{ 795{
798 carm_end_request_queued(host, crq, is_ok); 796 carm_end_request_queued(host, crq, error);
799 if (max_queue == 1) 797 if (max_queue == 1)
800 carm_round_robin(host); 798 carm_round_robin(host);
801 else if ((host->n_msgs <= CARM_MSG_LOW_WATER) && 799 else if ((host->n_msgs <= CARM_MSG_LOW_WATER) &&
@@ -873,14 +871,14 @@ queue_one_request:
873 sg = &crq->sg[0]; 871 sg = &crq->sg[0];
874 n_elem = blk_rq_map_sg(q, rq, sg); 872 n_elem = blk_rq_map_sg(q, rq, sg);
875 if (n_elem <= 0) { 873 if (n_elem <= 0) {
876 carm_end_rq(host, crq, 0); 874 carm_end_rq(host, crq, -EIO);
877 return; /* request with no s/g entries? */ 875 return; /* request with no s/g entries? */
878 } 876 }
879 877
880 /* map scatterlist to PCI bus addresses */ 878 /* map scatterlist to PCI bus addresses */
881 n_elem = pci_map_sg(host->pdev, sg, n_elem, pci_dir); 879 n_elem = pci_map_sg(host->pdev, sg, n_elem, pci_dir);
882 if (n_elem <= 0) { 880 if (n_elem <= 0) {
883 carm_end_rq(host, crq, 0); 881 carm_end_rq(host, crq, -EIO);
884 return; /* request with no s/g entries? */ 882 return; /* request with no s/g entries? */
885 } 883 }
886 crq->n_elem = n_elem; 884 crq->n_elem = n_elem;
@@ -941,7 +939,7 @@ queue_one_request:
941 939
942static void carm_handle_array_info(struct carm_host *host, 940static void carm_handle_array_info(struct carm_host *host,
943 struct carm_request *crq, u8 *mem, 941 struct carm_request *crq, u8 *mem,
944 int is_ok) 942 int error)
945{ 943{
946 struct carm_port *port; 944 struct carm_port *port;
947 u8 *msg_data = mem + sizeof(struct carm_array_info); 945 u8 *msg_data = mem + sizeof(struct carm_array_info);
@@ -952,9 +950,9 @@ static void carm_handle_array_info(struct carm_host *host,
952 950
953 DPRINTK("ENTER\n"); 951 DPRINTK("ENTER\n");
954 952
955 carm_end_rq(host, crq, is_ok); 953 carm_end_rq(host, crq, error);
956 954
957 if (!is_ok) 955 if (error)
958 goto out; 956 goto out;
959 if (le32_to_cpu(desc->array_status) & ARRAY_NO_EXIST) 957 if (le32_to_cpu(desc->array_status) & ARRAY_NO_EXIST)
960 goto out; 958 goto out;
@@ -1001,7 +999,7 @@ out:
1001 999
1002static void carm_handle_scan_chan(struct carm_host *host, 1000static void carm_handle_scan_chan(struct carm_host *host,
1003 struct carm_request *crq, u8 *mem, 1001 struct carm_request *crq, u8 *mem,
1004 int is_ok) 1002 int error)
1005{ 1003{
1006 u8 *msg_data = mem + IOC_SCAN_CHAN_OFFSET; 1004 u8 *msg_data = mem + IOC_SCAN_CHAN_OFFSET;
1007 unsigned int i, dev_count = 0; 1005 unsigned int i, dev_count = 0;
@@ -1009,9 +1007,9 @@ static void carm_handle_scan_chan(struct carm_host *host,
1009 1007
1010 DPRINTK("ENTER\n"); 1008 DPRINTK("ENTER\n");
1011 1009
1012 carm_end_rq(host, crq, is_ok); 1010 carm_end_rq(host, crq, error);
1013 1011
1014 if (!is_ok) { 1012 if (error) {
1015 new_state = HST_ERROR; 1013 new_state = HST_ERROR;
1016 goto out; 1014 goto out;
1017 } 1015 }
@@ -1033,23 +1031,23 @@ out:
1033} 1031}
1034 1032
1035static void carm_handle_generic(struct carm_host *host, 1033static void carm_handle_generic(struct carm_host *host,
1036 struct carm_request *crq, int is_ok, 1034 struct carm_request *crq, int error,
1037 int cur_state, int next_state) 1035 int cur_state, int next_state)
1038{ 1036{
1039 DPRINTK("ENTER\n"); 1037 DPRINTK("ENTER\n");
1040 1038
1041 carm_end_rq(host, crq, is_ok); 1039 carm_end_rq(host, crq, error);
1042 1040
1043 assert(host->state == cur_state); 1041 assert(host->state == cur_state);
1044 if (is_ok) 1042 if (error)
1045 host->state = next_state;
1046 else
1047 host->state = HST_ERROR; 1043 host->state = HST_ERROR;
1044 else
1045 host->state = next_state;
1048 schedule_work(&host->fsm_task); 1046 schedule_work(&host->fsm_task);
1049} 1047}
1050 1048
1051static inline void carm_handle_rw(struct carm_host *host, 1049static inline void carm_handle_rw(struct carm_host *host,
1052 struct carm_request *crq, int is_ok) 1050 struct carm_request *crq, int error)
1053{ 1051{
1054 int pci_dir; 1052 int pci_dir;
1055 1053
@@ -1062,7 +1060,7 @@ static inline void carm_handle_rw(struct carm_host *host,
1062 1060
1063 pci_unmap_sg(host->pdev, &crq->sg[0], crq->n_elem, pci_dir); 1061 pci_unmap_sg(host->pdev, &crq->sg[0], crq->n_elem, pci_dir);
1064 1062
1065 carm_end_rq(host, crq, is_ok); 1063 carm_end_rq(host, crq, error);
1066} 1064}
1067 1065
1068static inline void carm_handle_resp(struct carm_host *host, 1066static inline void carm_handle_resp(struct carm_host *host,
@@ -1071,7 +1069,7 @@ static inline void carm_handle_resp(struct carm_host *host,
1071 u32 handle = le32_to_cpu(ret_handle_le); 1069 u32 handle = le32_to_cpu(ret_handle_le);
1072 unsigned int msg_idx; 1070 unsigned int msg_idx;
1073 struct carm_request *crq; 1071 struct carm_request *crq;
1074 int is_ok = (status == RMSG_OK); 1072 int error = (status == RMSG_OK) ? 0 : -EIO;
1075 u8 *mem; 1073 u8 *mem;
1076 1074
1077 VPRINTK("ENTER, handle == 0x%x\n", handle); 1075 VPRINTK("ENTER, handle == 0x%x\n", handle);
@@ -1090,7 +1088,7 @@ static inline void carm_handle_resp(struct carm_host *host,
1090 /* fast path */ 1088 /* fast path */
1091 if (likely(crq->msg_type == CARM_MSG_READ || 1089 if (likely(crq->msg_type == CARM_MSG_READ ||
1092 crq->msg_type == CARM_MSG_WRITE)) { 1090 crq->msg_type == CARM_MSG_WRITE)) {
1093 carm_handle_rw(host, crq, is_ok); 1091 carm_handle_rw(host, crq, error);
1094 return; 1092 return;
1095 } 1093 }
1096 1094
@@ -1100,7 +1098,7 @@ static inline void carm_handle_resp(struct carm_host *host,
1100 case CARM_MSG_IOCTL: { 1098 case CARM_MSG_IOCTL: {
1101 switch (crq->msg_subtype) { 1099 switch (crq->msg_subtype) {
1102 case CARM_IOC_SCAN_CHAN: 1100 case CARM_IOC_SCAN_CHAN:
1103 carm_handle_scan_chan(host, crq, mem, is_ok); 1101 carm_handle_scan_chan(host, crq, mem, error);
1104 break; 1102 break;
1105 default: 1103 default:
1106 /* unknown / invalid response */ 1104 /* unknown / invalid response */
@@ -1112,21 +1110,21 @@ static inline void carm_handle_resp(struct carm_host *host,
1112 case CARM_MSG_MISC: { 1110 case CARM_MSG_MISC: {
1113 switch (crq->msg_subtype) { 1111 switch (crq->msg_subtype) {
1114 case MISC_ALLOC_MEM: 1112 case MISC_ALLOC_MEM:
1115 carm_handle_generic(host, crq, is_ok, 1113 carm_handle_generic(host, crq, error,
1116 HST_ALLOC_BUF, HST_SYNC_TIME); 1114 HST_ALLOC_BUF, HST_SYNC_TIME);
1117 break; 1115 break;
1118 case MISC_SET_TIME: 1116 case MISC_SET_TIME:
1119 carm_handle_generic(host, crq, is_ok, 1117 carm_handle_generic(host, crq, error,
1120 HST_SYNC_TIME, HST_GET_FW_VER); 1118 HST_SYNC_TIME, HST_GET_FW_VER);
1121 break; 1119 break;
1122 case MISC_GET_FW_VER: { 1120 case MISC_GET_FW_VER: {
1123 struct carm_fw_ver *ver = (struct carm_fw_ver *) 1121 struct carm_fw_ver *ver = (struct carm_fw_ver *)
1124 mem + sizeof(struct carm_msg_get_fw_ver); 1122 mem + sizeof(struct carm_msg_get_fw_ver);
1125 if (is_ok) { 1123 if (!error) {
1126 host->fw_ver = le32_to_cpu(ver->version); 1124 host->fw_ver = le32_to_cpu(ver->version);
1127 host->flags |= (ver->features & FL_FW_VER_MASK); 1125 host->flags |= (ver->features & FL_FW_VER_MASK);
1128 } 1126 }
1129 carm_handle_generic(host, crq, is_ok, 1127 carm_handle_generic(host, crq, error,
1130 HST_GET_FW_VER, HST_PORT_SCAN); 1128 HST_GET_FW_VER, HST_PORT_SCAN);
1131 break; 1129 break;
1132 } 1130 }
@@ -1140,7 +1138,7 @@ static inline void carm_handle_resp(struct carm_host *host,
1140 case CARM_MSG_ARRAY: { 1138 case CARM_MSG_ARRAY: {
1141 switch (crq->msg_subtype) { 1139 switch (crq->msg_subtype) {
1142 case CARM_ARRAY_INFO: 1140 case CARM_ARRAY_INFO:
1143 carm_handle_array_info(host, crq, mem, is_ok); 1141 carm_handle_array_info(host, crq, mem, error);
1144 break; 1142 break;
1145 default: 1143 default:
1146 /* unknown / invalid response */ 1144 /* unknown / invalid response */
@@ -1159,7 +1157,7 @@ static inline void carm_handle_resp(struct carm_host *host,
1159err_out: 1157err_out:
1160 printk(KERN_WARNING DRV_NAME "(%s): BUG: unhandled message type %d/%d\n", 1158 printk(KERN_WARNING DRV_NAME "(%s): BUG: unhandled message type %d/%d\n",
1161 pci_name(host->pdev), crq->msg_type, crq->msg_subtype); 1159 pci_name(host->pdev), crq->msg_type, crq->msg_subtype);
1162 carm_end_rq(host, crq, 0); 1160 carm_end_rq(host, crq, -EIO);
1163} 1161}
1164 1162
1165static inline void carm_handle_responses(struct carm_host *host) 1163static inline void carm_handle_responses(struct carm_host *host)