Commit 7689e82efdb636e8a076a1293b977bce313110c5
Committed by
James Bottomley
1 parent
6d877688ef
Exists in
master
and in
7 other branches
[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>
Showing 4 changed files with 58 additions and 41 deletions Side-by-side Diff
drivers/scsi/Kconfig
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | config SCSI |
11 | 11 | tristate "SCSI device support" |
12 | 12 | depends on BLOCK |
13 | + select SCSI_DMA if HAS_DMA | |
13 | 14 | ---help--- |
14 | 15 | If you want to use a SCSI hard disk, SCSI tape drive, SCSI CD-ROM or |
15 | 16 | any other SCSI device under Linux, say Y and make sure that you know |
... | ... | @@ -28,6 +29,10 @@ |
28 | 29 | |
29 | 30 | However, do not compile this as a module if your root file system |
30 | 31 | (the one containing the directory /) is located on a SCSI device. |
32 | + | |
33 | +config SCSI_DMA | |
34 | + bool | |
35 | + default n | |
31 | 36 | |
32 | 37 | config SCSI_TGT |
33 | 38 | tristate "SCSI target support" |
drivers/scsi/Makefile
... | ... | @@ -148,9 +148,9 @@ |
148 | 148 | obj-$(CONFIG_SCSI_WAIT_SCAN) += scsi_wait_scan.o |
149 | 149 | |
150 | 150 | scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ |
151 | - scsicam.o scsi_error.o scsi_lib.o \ | |
152 | - scsi_scan.o scsi_sysfs.o \ | |
153 | - scsi_devinfo.o | |
151 | + scsicam.o scsi_error.o scsi_lib.o | |
152 | +scsi_mod-$(CONFIG_SCSI_DMA) += scsi_lib_dma.o | |
153 | +scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o | |
154 | 154 | scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o |
155 | 155 | scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o |
156 | 156 | scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o |
drivers/scsi/scsi_lib.c
... | ... | @@ -2290,42 +2290,4 @@ |
2290 | 2290 | kunmap_atomic(virt, KM_BIO_SRC_IRQ); |
2291 | 2291 | } |
2292 | 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); |
drivers/scsi/scsi_lib_dma.c
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); |