diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2007-07-09 14:59:59 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-07-14 20:28:10 -0400 |
commit | 7689e82efdb636e8a076a1293b977bce313110c5 (patch) | |
tree | 3d8702ff24a205db7670ad5425e3a35fe45b0f00 /drivers | |
parent | 6d877688ef411313c94aa3c83c7473fbec6db32c (diff) |
[SCSI] don't build scsi_dma_{map,unmap} for !HAS_DMA
With
dma-mapping-prevent-dma-dependent-code-from-linking-on.patch
scsi fails to build on !HAS_DMA architectures:
drivers/built-in.o(.text+0x20af6): In function `scsi_dma_map':
: undefined reference to `dma_map_sg'
drivers/built-in.o(.text+0x20b5c): In function `scsi_dma_unmap':
: undefined reference to `dma_unmap_sg'
I split those functions out into a new file. Builds on s390 and i386.
Move scsi_dma_{map,unmap} into scsi_lib_dma.c which is only build if
HAS_DMA is set.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: James Bottomley <James.Bottomley@SteelEye.com>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/Kconfig | 5 | ||||
-rw-r--r-- | drivers/scsi/Makefile | 6 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 38 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib_dma.c | 50 |
4 files changed, 58 insertions, 41 deletions
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 874cfee29358..6ac3873e4d73 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -10,6 +10,7 @@ config RAID_ATTRS | |||
10 | config SCSI | 10 | config SCSI |
11 | tristate "SCSI device support" | 11 | tristate "SCSI device support" |
12 | depends on BLOCK | 12 | depends on BLOCK |
13 | select SCSI_DMA if HAS_DMA | ||
13 | ---help--- | 14 | ---help--- |
14 | If you want to use a SCSI hard disk, SCSI tape drive, SCSI CD-ROM or | 15 | If you want to use a SCSI hard disk, SCSI tape drive, SCSI CD-ROM or |
15 | any other SCSI device under Linux, say Y and make sure that you know | 16 | any other SCSI device under Linux, say Y and make sure that you know |
@@ -29,6 +30,10 @@ config SCSI | |||
29 | However, do not compile this as a module if your root file system | 30 | However, do not compile this as a module if your root file system |
30 | (the one containing the directory /) is located on a SCSI device. | 31 | (the one containing the directory /) is located on a SCSI device. |
31 | 32 | ||
33 | config SCSI_DMA | ||
34 | bool | ||
35 | default n | ||
36 | |||
32 | config SCSI_TGT | 37 | config SCSI_TGT |
33 | tristate "SCSI target support" | 38 | tristate "SCSI target support" |
34 | depends on SCSI && EXPERIMENTAL | 39 | depends on SCSI && EXPERIMENTAL |
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index cbc2e2ba5412..0f8689557158 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile | |||
@@ -148,9 +148,9 @@ obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o | |||
148 | obj-$(CONFIG_SCSI_WAIT_SCAN) += scsi_wait_scan.o | 148 | obj-$(CONFIG_SCSI_WAIT_SCAN) += scsi_wait_scan.o |
149 | 149 | ||
150 | scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ | 150 | scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ |
151 | scsicam.o scsi_error.o scsi_lib.o \ | 151 | scsicam.o scsi_error.o scsi_lib.o |
152 | scsi_scan.o scsi_sysfs.o \ | 152 | scsi_mod-$(CONFIG_SCSI_DMA) += scsi_lib_dma.o |
153 | scsi_devinfo.o | 153 | scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o |
154 | scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o | 154 | scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o |
155 | scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o | 155 | scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o |
156 | scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o | 156 | scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 70454b4e8485..1f5a07bf2a75 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -2290,41 +2290,3 @@ void scsi_kunmap_atomic_sg(void *virt) | |||
2290 | kunmap_atomic(virt, KM_BIO_SRC_IRQ); | 2290 | kunmap_atomic(virt, KM_BIO_SRC_IRQ); |
2291 | } | 2291 | } |
2292 | EXPORT_SYMBOL(scsi_kunmap_atomic_sg); | 2292 | EXPORT_SYMBOL(scsi_kunmap_atomic_sg); |
2293 | |||
2294 | /** | ||
2295 | * scsi_dma_map - perform DMA mapping against command's sg lists | ||
2296 | * @cmd: scsi command | ||
2297 | * | ||
2298 | * Returns the number of sg lists actually used, zero if the sg lists | ||
2299 | * is NULL, or -ENOMEM if the mapping failed. | ||
2300 | */ | ||
2301 | int scsi_dma_map(struct scsi_cmnd *cmd) | ||
2302 | { | ||
2303 | int nseg = 0; | ||
2304 | |||
2305 | if (scsi_sg_count(cmd)) { | ||
2306 | struct device *dev = cmd->device->host->shost_gendev.parent; | ||
2307 | |||
2308 | nseg = dma_map_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd), | ||
2309 | cmd->sc_data_direction); | ||
2310 | if (unlikely(!nseg)) | ||
2311 | return -ENOMEM; | ||
2312 | } | ||
2313 | return nseg; | ||
2314 | } | ||
2315 | EXPORT_SYMBOL(scsi_dma_map); | ||
2316 | |||
2317 | /** | ||
2318 | * scsi_dma_unmap - unmap command's sg lists mapped by scsi_dma_map | ||
2319 | * @cmd: scsi command | ||
2320 | */ | ||
2321 | void scsi_dma_unmap(struct scsi_cmnd *cmd) | ||
2322 | { | ||
2323 | if (scsi_sg_count(cmd)) { | ||
2324 | struct device *dev = cmd->device->host->shost_gendev.parent; | ||
2325 | |||
2326 | dma_unmap_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd), | ||
2327 | cmd->sc_data_direction); | ||
2328 | } | ||
2329 | } | ||
2330 | EXPORT_SYMBOL(scsi_dma_unmap); | ||
diff --git a/drivers/scsi/scsi_lib_dma.c b/drivers/scsi/scsi_lib_dma.c new file mode 100644 index 000000000000..ac6855cd2657 --- /dev/null +++ b/drivers/scsi/scsi_lib_dma.c | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * SCSI library functions depending on DMA | ||
3 | */ | ||
4 | |||
5 | #include <linux/blkdev.h> | ||
6 | #include <linux/device.h> | ||
7 | #include <linux/kernel.h> | ||
8 | |||
9 | #include <scsi/scsi.h> | ||
10 | #include <scsi/scsi_cmnd.h> | ||
11 | #include <scsi/scsi_device.h> | ||
12 | #include <scsi/scsi_host.h> | ||
13 | |||
14 | /** | ||
15 | * scsi_dma_map - perform DMA mapping against command's sg lists | ||
16 | * @cmd: scsi command | ||
17 | * | ||
18 | * Returns the number of sg lists actually used, zero if the sg lists | ||
19 | * is NULL, or -ENOMEM if the mapping failed. | ||
20 | */ | ||
21 | int scsi_dma_map(struct scsi_cmnd *cmd) | ||
22 | { | ||
23 | int nseg = 0; | ||
24 | |||
25 | if (scsi_sg_count(cmd)) { | ||
26 | struct device *dev = cmd->device->host->shost_gendev.parent; | ||
27 | |||
28 | nseg = dma_map_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd), | ||
29 | cmd->sc_data_direction); | ||
30 | if (unlikely(!nseg)) | ||
31 | return -ENOMEM; | ||
32 | } | ||
33 | return nseg; | ||
34 | } | ||
35 | EXPORT_SYMBOL(scsi_dma_map); | ||
36 | |||
37 | /** | ||
38 | * scsi_dma_unmap - unmap command's sg lists mapped by scsi_dma_map | ||
39 | * @cmd: scsi command | ||
40 | */ | ||
41 | void scsi_dma_unmap(struct scsi_cmnd *cmd) | ||
42 | { | ||
43 | if (scsi_sg_count(cmd)) { | ||
44 | struct device *dev = cmd->device->host->shost_gendev.parent; | ||
45 | |||
46 | dma_unmap_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd), | ||
47 | cmd->sc_data_direction); | ||
48 | } | ||
49 | } | ||
50 | EXPORT_SYMBOL(scsi_dma_unmap); | ||