patch-2.3.47 linux/drivers/scsi/qlogicisp.c

Next file: linux/drivers/scsi/qlogicpti.c
Previous file: linux/drivers/scsi/qlogicfc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.46/linux/drivers/scsi/qlogicisp.c linux/drivers/scsi/qlogicisp.c
@@ -810,8 +810,8 @@
 		sg = (struct scatterlist *) Cmnd->request_buffer;
 		ds = cmd->dataseg;
 
-		sg_count = pci_map_sg(hostdata->pci_dev, sg, Cmnd->use_sg);
-		Cmnd->use_sg = sg_count;
+		sg_count = pci_map_sg(hostdata->pci_dev, sg, Cmnd->use_sg,
+				      scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
 
 		cmd->segment_cnt = cpu_to_le16(sg_count);
 
@@ -853,17 +853,22 @@
 			}
 			sg_count -= n;
 		}
-	} else {
+	} else if (Cmnd->request_bufflen) {
 		Cmnd->SCp.ptr = (char *)(unsigned long)
 			pci_map_single(hostdata->pci_dev,
 				       Cmnd->request_buffer,
-				       Cmnd->request_bufflen);
+				       Cmnd->request_bufflen,
+				       scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
 
 		cmd->dataseg[0].d_base =
 			cpu_to_le32((u32)(long)Cmnd->SCp.ptr);
 		cmd->dataseg[0].d_count =
 			cpu_to_le32((u32)Cmnd->request_bufflen);
 		cmd->segment_cnt = cpu_to_le16(1);
+	} else {
+		cmd->dataseg[0].d_base = 0;
+		cmd->dataseg[0].d_count = 0;
+		cmd->segment_cnt = cpu_to_le16(1); /* Shouldn't this be 0? */
 	}
 
 	/* Committed, record Scsi_Cmd so we can find it later. */
@@ -974,11 +979,13 @@
 		if (Cmnd->use_sg)
 			pci_unmap_sg(hostdata->pci_dev,
 				     (struct scatterlist *)Cmnd->buffer,
-				     Cmnd->use_sg);
-		else
+				     Cmnd->use_sg,
+				     scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
+		else if (Cmnd->request_bufflen)
 			pci_unmap_single(hostdata->pci_dev,
 					 (u32)((long)Cmnd->SCp.ptr),
-					 Cmnd->request_bufflen);
+					 Cmnd->request_bufflen,
+					 scsi_to_pci_dma_dir(Cmnd->sc_data_direction));
 
 		isp_outw(out_ptr, host, MBOX5);
 		(*Cmnd->scsi_done)(Cmnd);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)