diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2009-03-13 16:16:13 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-13 16:16:13 -0400 |
commit | 5d82720a7f41f0c877e026c7d17e3bf20ccdbae0 (patch) | |
tree | 47ec22f0bdf7b5eaa79eef17dbacedc29b1123c2 /drivers/ide/ide-dma.c | |
parent | 3eb76c1ccde496c3c0bfda23d1c803e40b762ce6 (diff) |
ide: save the returned value of dma_map_sg
dma_map_sg could return a value different to 'nents' argument of
dma_map_sg so the ide stack needs to save it for the later usage
(e.g. for_each_sg).
The ide stack also needs to save the original sg_nents value for
pci_unmap_sg.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
[bart: backport to Linus' tree]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-dma.c')
-rw-r--r-- | drivers/ide/ide-dma.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 72ebab0bc755..059c90bb5ad2 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -128,6 +128,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq) | |||
128 | { | 128 | { |
129 | ide_hwif_t *hwif = drive->hwif; | 129 | ide_hwif_t *hwif = drive->hwif; |
130 | struct scatterlist *sg = hwif->sg_table; | 130 | struct scatterlist *sg = hwif->sg_table; |
131 | int i; | ||
131 | 132 | ||
132 | ide_map_sg(drive, rq); | 133 | ide_map_sg(drive, rq); |
133 | 134 | ||
@@ -136,8 +137,13 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq) | |||
136 | else | 137 | else |
137 | hwif->sg_dma_direction = DMA_TO_DEVICE; | 138 | hwif->sg_dma_direction = DMA_TO_DEVICE; |
138 | 139 | ||
139 | return dma_map_sg(hwif->dev, sg, hwif->sg_nents, | 140 | i = dma_map_sg(hwif->dev, sg, hwif->sg_nents, hwif->sg_dma_direction); |
140 | hwif->sg_dma_direction); | 141 | if (i) { |
142 | hwif->orig_sg_nents = hwif->sg_nents; | ||
143 | hwif->sg_nents = i; | ||
144 | } | ||
145 | |||
146 | return i; | ||
141 | } | 147 | } |
142 | EXPORT_SYMBOL_GPL(ide_build_sglist); | 148 | EXPORT_SYMBOL_GPL(ide_build_sglist); |
143 | 149 | ||
@@ -156,7 +162,7 @@ void ide_destroy_dmatable(ide_drive_t *drive) | |||
156 | { | 162 | { |
157 | ide_hwif_t *hwif = drive->hwif; | 163 | ide_hwif_t *hwif = drive->hwif; |
158 | 164 | ||
159 | dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents, | 165 | dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->orig_sg_nents, |
160 | hwif->sg_dma_direction); | 166 | hwif->sg_dma_direction); |
161 | } | 167 | } |
162 | EXPORT_SYMBOL_GPL(ide_destroy_dmatable); | 168 | EXPORT_SYMBOL_GPL(ide_destroy_dmatable); |