0001
0002
0003
0004
0005
0006 #include <linux/blkdev.h>
0007 #include <linux/device.h>
0008 #include <linux/export.h>
0009 #include <linux/kernel.h>
0010
0011 #include <scsi/scsi.h>
0012 #include <scsi/scsi_cmnd.h>
0013 #include <scsi/scsi_device.h>
0014 #include <scsi/scsi_host.h>
0015
0016
0017
0018
0019
0020
0021
0022
0023 int scsi_dma_map(struct scsi_cmnd *cmd)
0024 {
0025 int nseg = 0;
0026
0027 if (scsi_sg_count(cmd)) {
0028 struct device *dev = cmd->device->host->dma_dev;
0029
0030 nseg = dma_map_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd),
0031 cmd->sc_data_direction);
0032 if (unlikely(!nseg))
0033 return -ENOMEM;
0034 }
0035 return nseg;
0036 }
0037 EXPORT_SYMBOL(scsi_dma_map);
0038
0039
0040
0041
0042
0043 void scsi_dma_unmap(struct scsi_cmnd *cmd)
0044 {
0045 if (scsi_sg_count(cmd)) {
0046 struct device *dev = cmd->device->host->dma_dev;
0047
0048 dma_unmap_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd),
0049 cmd->sc_data_direction);
0050 }
0051 }
0052 EXPORT_SYMBOL(scsi_dma_unmap);