aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-22 22:11:06 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-22 22:11:06 -0400
commit69450bb5eb8e9df28281c62f98e971c9969dc4ff (patch)
tree85991e6e8b74cb08b5013fd7e419c3df67d23e35 /drivers/mmc
parente38f981758118d829cd40cfe9c09e3fa81e422aa (diff)
parentd6ec084200c37683278c821338f74ddf21ab80f5 (diff)
Merge branch 'sg' of git://git.kernel.dk/linux-2.6-block
* 'sg' of git://git.kernel.dk/linux-2.6-block: Add CONFIG_DEBUG_SG sg validation Change table chaining layout Update arch/ to use sg helpers Update swiotlb to use sg helpers Update net/ to use sg helpers Update fs/ to use sg helpers [SG] Update drivers to use sg helpers [SG] Update crypto/ to sg helpers [SG] Update block layer to use sg helpers [SG] Add helpers for manipulating SG entries
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/card/queue.c15
-rw-r--r--drivers/mmc/host/at91_mci.c8
-rw-r--r--drivers/mmc/host/au1xmmc.c11
-rw-r--r--drivers/mmc/host/imxmmc.c2
-rw-r--r--drivers/mmc/host/mmc_spi.c8
-rw-r--r--drivers/mmc/host/omap.c4
-rw-r--r--drivers/mmc/host/sdhci.c2
-rw-r--r--drivers/mmc/host/tifm_sd.c8
-rw-r--r--drivers/mmc/host/wbsd.c6
9 files changed, 31 insertions, 33 deletions
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index a5d0354bbbda..9203a0b221b3 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -13,6 +13,7 @@
13#include <linux/blkdev.h> 13#include <linux/blkdev.h>
14#include <linux/freezer.h> 14#include <linux/freezer.h>
15#include <linux/kthread.h> 15#include <linux/kthread.h>
16#include <linux/scatterlist.h>
16 17
17#include <linux/mmc/card.h> 18#include <linux/mmc/card.h>
18#include <linux/mmc/host.h> 19#include <linux/mmc/host.h>
@@ -153,19 +154,21 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
153 blk_queue_max_hw_segments(mq->queue, bouncesz / 512); 154 blk_queue_max_hw_segments(mq->queue, bouncesz / 512);
154 blk_queue_max_segment_size(mq->queue, bouncesz); 155 blk_queue_max_segment_size(mq->queue, bouncesz);
155 156
156 mq->sg = kzalloc(sizeof(struct scatterlist), 157 mq->sg = kmalloc(sizeof(struct scatterlist),
157 GFP_KERNEL); 158 GFP_KERNEL);
158 if (!mq->sg) { 159 if (!mq->sg) {
159 ret = -ENOMEM; 160 ret = -ENOMEM;
160 goto cleanup_queue; 161 goto cleanup_queue;
161 } 162 }
163 sg_init_table(mq->sg, 1);
162 164
163 mq->bounce_sg = kzalloc(sizeof(struct scatterlist) * 165 mq->bounce_sg = kmalloc(sizeof(struct scatterlist) *
164 bouncesz / 512, GFP_KERNEL); 166 bouncesz / 512, GFP_KERNEL);
165 if (!mq->bounce_sg) { 167 if (!mq->bounce_sg) {
166 ret = -ENOMEM; 168 ret = -ENOMEM;
167 goto cleanup_queue; 169 goto cleanup_queue;
168 } 170 }
171 sg_init_table(mq->bounce_sg, bouncesz / 512);
169 } 172 }
170 } 173 }
171#endif 174#endif
@@ -302,12 +305,12 @@ static void copy_sg(struct scatterlist *dst, unsigned int dst_len,
302 BUG_ON(dst_len == 0); 305 BUG_ON(dst_len == 0);
303 306
304 if (dst_size == 0) { 307 if (dst_size == 0) {
305 dst_buf = page_address(dst->page) + dst->offset; 308 dst_buf = sg_virt(dst);
306 dst_size = dst->length; 309 dst_size = dst->length;
307 } 310 }
308 311
309 if (src_size == 0) { 312 if (src_size == 0) {
310 src_buf = page_address(src->page) + src->offset; 313 src_buf = sg_virt(dst);
311 src_size = src->length; 314 src_size = src->length;
312 } 315 }
313 316
@@ -353,9 +356,7 @@ unsigned int mmc_queue_map_sg(struct mmc_queue *mq)
353 return 1; 356 return 1;
354 } 357 }
355 358
356 mq->sg[0].page = virt_to_page(mq->bounce_buf); 359 sg_init_one(mq->sg, mq->bounce_buf, 0);
357 mq->sg[0].offset = offset_in_page(mq->bounce_buf);
358 mq->sg[0].length = 0;
359 360
360 while (sg_len) { 361 while (sg_len) {
361 mq->sg[0].length += mq->bounce_sg[sg_len - 1].length; 362 mq->sg[0].length += mq->bounce_sg[sg_len - 1].length;
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c
index 7a452c2ad1f9..b1edcefdd4f9 100644
--- a/drivers/mmc/host/at91_mci.c
+++ b/drivers/mmc/host/at91_mci.c
@@ -149,7 +149,7 @@ static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data
149 149
150 sg = &data->sg[i]; 150 sg = &data->sg[i];
151 151
152 sgbuffer = kmap_atomic(sg->page, KM_BIO_SRC_IRQ) + sg->offset; 152 sgbuffer = kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
153 amount = min(size, sg->length); 153 amount = min(size, sg->length);
154 size -= amount; 154 size -= amount;
155 155
@@ -226,7 +226,7 @@ static void at91_mci_pre_dma_read(struct at91mci_host *host)
226 sg = &data->sg[host->transfer_index++]; 226 sg = &data->sg[host->transfer_index++];
227 pr_debug("sg = %p\n", sg); 227 pr_debug("sg = %p\n", sg);
228 228
229 sg->dma_address = dma_map_page(NULL, sg->page, sg->offset, sg->length, DMA_FROM_DEVICE); 229 sg->dma_address = dma_map_page(NULL, sg_page(sg), sg->offset, sg->length, DMA_FROM_DEVICE);
230 230
231 pr_debug("dma address = %08X, length = %d\n", sg->dma_address, sg->length); 231 pr_debug("dma address = %08X, length = %d\n", sg->dma_address, sg->length);
232 232
@@ -283,7 +283,7 @@ static void at91_mci_post_dma_read(struct at91mci_host *host)
283 int index; 283 int index;
284 284
285 /* Swap the contents of the buffer */ 285 /* Swap the contents of the buffer */
286 buffer = kmap_atomic(sg->page, KM_BIO_SRC_IRQ) + sg->offset; 286 buffer = kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
287 pr_debug("buffer = %p, length = %d\n", buffer, sg->length); 287 pr_debug("buffer = %p, length = %d\n", buffer, sg->length);
288 288
289 for (index = 0; index < (sg->length / 4); index++) 289 for (index = 0; index < (sg->length / 4); index++)
@@ -292,7 +292,7 @@ static void at91_mci_post_dma_read(struct at91mci_host *host)
292 kunmap_atomic(buffer, KM_BIO_SRC_IRQ); 292 kunmap_atomic(buffer, KM_BIO_SRC_IRQ);
293 } 293 }
294 294
295 flush_dcache_page(sg->page); 295 flush_dcache_page(sg_page(sg));
296 } 296 }
297 297
298 /* Is there another transfer to trigger? */ 298 /* Is there another transfer to trigger? */
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 92c4d0dfee43..bcbb6d247bf7 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -340,7 +340,7 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host)
340 340
341 /* This is the pointer to the data buffer */ 341 /* This is the pointer to the data buffer */
342 sg = &data->sg[host->pio.index]; 342 sg = &data->sg[host->pio.index];
343 sg_ptr = page_address(sg->page) + sg->offset + host->pio.offset; 343 sg_ptr = sg_virt(sg) + host->pio.offset;
344 344
345 /* This is the space left inside the buffer */ 345 /* This is the space left inside the buffer */
346 sg_len = data->sg[host->pio.index].length - host->pio.offset; 346 sg_len = data->sg[host->pio.index].length - host->pio.offset;
@@ -400,7 +400,7 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host)
400 400
401 if (host->pio.index < host->dma.len) { 401 if (host->pio.index < host->dma.len) {
402 sg = &data->sg[host->pio.index]; 402 sg = &data->sg[host->pio.index];
403 sg_ptr = page_address(sg->page) + sg->offset + host->pio.offset; 403 sg_ptr = sg_virt(sg) + host->pio.offset;
404 404
405 /* This is the space left inside the buffer */ 405 /* This is the space left inside the buffer */
406 sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset; 406 sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset;
@@ -613,14 +613,11 @@ au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data)
613 613
614 if (host->flags & HOST_F_XMIT){ 614 if (host->flags & HOST_F_XMIT){
615 ret = au1xxx_dbdma_put_source_flags(channel, 615 ret = au1xxx_dbdma_put_source_flags(channel,
616 (void *) (page_address(sg->page) + 616 (void *) sg_virt(sg), len, flags);
617 sg->offset),
618 len, flags);
619 } 617 }
620 else { 618 else {
621 ret = au1xxx_dbdma_put_dest_flags(channel, 619 ret = au1xxx_dbdma_put_dest_flags(channel,
622 (void *) (page_address(sg->page) + 620 (void *) sg_virt(sg),
623 sg->offset),
624 len, flags); 621 len, flags);
625 } 622 }
626 623
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c
index 6ebc41e7592c..fc72e1fadb6a 100644
--- a/drivers/mmc/host/imxmmc.c
+++ b/drivers/mmc/host/imxmmc.c
@@ -262,7 +262,7 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data)
262 } 262 }
263 263
264 /* Convert back to virtual address */ 264 /* Convert back to virtual address */
265 host->data_ptr = (u16*)(page_address(data->sg->page) + data->sg->offset); 265 host->data_ptr = (u16*)sg_virt(sg);
266 host->data_cnt = 0; 266 host->data_cnt = 0;
267 267
268 clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); 268 clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events);
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 7ae18eaed6c5..12c2d807c145 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -813,7 +813,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
813 && dir == DMA_FROM_DEVICE) 813 && dir == DMA_FROM_DEVICE)
814 dir = DMA_BIDIRECTIONAL; 814 dir = DMA_BIDIRECTIONAL;
815 815
816 dma_addr = dma_map_page(dma_dev, sg->page, 0, 816 dma_addr = dma_map_page(dma_dev, sg_page(sg), 0,
817 PAGE_SIZE, dir); 817 PAGE_SIZE, dir);
818 if (direction == DMA_TO_DEVICE) 818 if (direction == DMA_TO_DEVICE)
819 t->tx_dma = dma_addr + sg->offset; 819 t->tx_dma = dma_addr + sg->offset;
@@ -822,7 +822,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
822 } 822 }
823 823
824 /* allow pio too; we don't allow highmem */ 824 /* allow pio too; we don't allow highmem */
825 kmap_addr = kmap(sg->page); 825 kmap_addr = kmap(sg_page(sg));
826 if (direction == DMA_TO_DEVICE) 826 if (direction == DMA_TO_DEVICE)
827 t->tx_buf = kmap_addr + sg->offset; 827 t->tx_buf = kmap_addr + sg->offset;
828 else 828 else
@@ -855,8 +855,8 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
855 855
856 /* discard mappings */ 856 /* discard mappings */
857 if (direction == DMA_FROM_DEVICE) 857 if (direction == DMA_FROM_DEVICE)
858 flush_kernel_dcache_page(sg->page); 858 flush_kernel_dcache_page(sg_page(sg));
859 kunmap(sg->page); 859 kunmap(sg_page(sg));
860 if (dma_dev) 860 if (dma_dev)
861 dma_unmap_page(dma_dev, dma_addr, PAGE_SIZE, dir); 861 dma_unmap_page(dma_dev, dma_addr, PAGE_SIZE, dir);
862 862
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 60a67dfcda6a..971e18b91f4a 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -24,10 +24,10 @@
24#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
25#include <linux/mmc/card.h> 25#include <linux/mmc/card.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/scatterlist.h>
27 28
28#include <asm/io.h> 29#include <asm/io.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/scatterlist.h>
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
32 32
33#include <asm/arch/board.h> 33#include <asm/arch/board.h>
@@ -383,7 +383,7 @@ mmc_omap_sg_to_buf(struct mmc_omap_host *host)
383 383
384 sg = host->data->sg + host->sg_idx; 384 sg = host->data->sg + host->sg_idx;
385 host->buffer_bytes_left = sg->length; 385 host->buffer_bytes_left = sg->length;
386 host->buffer = page_address(sg->page) + sg->offset; 386 host->buffer = sg_virt(sg);
387 if (host->buffer_bytes_left > host->total_bytes_left) 387 if (host->buffer_bytes_left > host->total_bytes_left)
388 host->buffer_bytes_left = host->total_bytes_left; 388 host->buffer_bytes_left = host->total_bytes_left;
389} 389}
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index b397121b947d..0db837e44b77 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -231,7 +231,7 @@ static void sdhci_deactivate_led(struct sdhci_host *host)
231 231
232static inline char* sdhci_sg_to_buffer(struct sdhci_host* host) 232static inline char* sdhci_sg_to_buffer(struct sdhci_host* host)
233{ 233{
234 return page_address(host->cur_sg->page) + host->cur_sg->offset; 234 return sg_virt(host->cur_sg);
235} 235}
236 236
237static inline int sdhci_next_sg(struct sdhci_host* host) 237static inline int sdhci_next_sg(struct sdhci_host* host)
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
index 9b904795eb77..c11a3d256051 100644
--- a/drivers/mmc/host/tifm_sd.c
+++ b/drivers/mmc/host/tifm_sd.c
@@ -192,7 +192,7 @@ static void tifm_sd_transfer_data(struct tifm_sd *host)
192 } 192 }
193 off = sg[host->sg_pos].offset + host->block_pos; 193 off = sg[host->sg_pos].offset + host->block_pos;
194 194
195 pg = nth_page(sg[host->sg_pos].page, off >> PAGE_SHIFT); 195 pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT);
196 p_off = offset_in_page(off); 196 p_off = offset_in_page(off);
197 p_cnt = PAGE_SIZE - p_off; 197 p_cnt = PAGE_SIZE - p_off;
198 p_cnt = min(p_cnt, cnt); 198 p_cnt = min(p_cnt, cnt);
@@ -241,18 +241,18 @@ static void tifm_sd_bounce_block(struct tifm_sd *host, struct mmc_data *r_data)
241 } 241 }
242 off = sg[host->sg_pos].offset + host->block_pos; 242 off = sg[host->sg_pos].offset + host->block_pos;
243 243
244 pg = nth_page(sg[host->sg_pos].page, off >> PAGE_SHIFT); 244 pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT);
245 p_off = offset_in_page(off); 245 p_off = offset_in_page(off);
246 p_cnt = PAGE_SIZE - p_off; 246 p_cnt = PAGE_SIZE - p_off;
247 p_cnt = min(p_cnt, cnt); 247 p_cnt = min(p_cnt, cnt);
248 p_cnt = min(p_cnt, t_size); 248 p_cnt = min(p_cnt, t_size);
249 249
250 if (r_data->flags & MMC_DATA_WRITE) 250 if (r_data->flags & MMC_DATA_WRITE)
251 tifm_sd_copy_page(host->bounce_buf.page, 251 tifm_sd_copy_page(sg_page(&host->bounce_buf),
252 r_data->blksz - t_size, 252 r_data->blksz - t_size,
253 pg, p_off, p_cnt); 253 pg, p_off, p_cnt);
254 else if (r_data->flags & MMC_DATA_READ) 254 else if (r_data->flags & MMC_DATA_READ)
255 tifm_sd_copy_page(pg, p_off, host->bounce_buf.page, 255 tifm_sd_copy_page(pg, p_off, sg_page(&host->bounce_buf),
256 r_data->blksz - t_size, p_cnt); 256 r_data->blksz - t_size, p_cnt);
257 257
258 t_size -= p_cnt; 258 t_size -= p_cnt;
diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c
index 80db11c05f2a..fa4c8c53cc7a 100644
--- a/drivers/mmc/host/wbsd.c
+++ b/drivers/mmc/host/wbsd.c
@@ -269,7 +269,7 @@ static inline int wbsd_next_sg(struct wbsd_host *host)
269 269
270static inline char *wbsd_sg_to_buffer(struct wbsd_host *host) 270static inline char *wbsd_sg_to_buffer(struct wbsd_host *host)
271{ 271{
272 return page_address(host->cur_sg->page) + host->cur_sg->offset; 272 return sg_virt(host->cur_sg);
273} 273}
274 274
275static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data) 275static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data)
@@ -283,7 +283,7 @@ static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data)
283 len = data->sg_len; 283 len = data->sg_len;
284 284
285 for (i = 0; i < len; i++) { 285 for (i = 0; i < len; i++) {
286 sgbuf = page_address(sg[i].page) + sg[i].offset; 286 sgbuf = sg_virt(&sg[i]);
287 memcpy(dmabuf, sgbuf, sg[i].length); 287 memcpy(dmabuf, sgbuf, sg[i].length);
288 dmabuf += sg[i].length; 288 dmabuf += sg[i].length;
289 } 289 }
@@ -300,7 +300,7 @@ static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data)
300 len = data->sg_len; 300 len = data->sg_len;
301 301
302 for (i = 0; i < len; i++) { 302 for (i = 0; i < len; i++) {
303 sgbuf = page_address(sg[i].page) + sg[i].offset; 303 sgbuf = sg_virt(&sg[i]);
304 memcpy(sgbuf, dmabuf, sg[i].length); 304 memcpy(sgbuf, dmabuf, sg[i].length);
305 dmabuf += sg[i].length; 305 dmabuf += sg[i].length;
306 } 306 }