-/**
- * ide_raw_build_sglist - map IDE scatter gather for DMA
- * @drive: the drive to build the DMA table for
- * @rq: the request holding the sg list
- *
- * Perform the PCI mapping magic necessary to access the source or
- * target buffers of a taskfile request via PCI DMA. The lower layers
- * of the kernel provide the necessary cache management so that we can
- * operate in a portable fashion
- */
-
-int ide_raw_build_sglist(ide_drive_t *drive, struct request *rq)
-{
- ide_hwif_t *hwif = HWIF(drive);
- struct scatterlist *sg = hwif->sg_table;
- int nents = 0;
- ide_task_t *args = rq->special;
- u8 *virt_addr = rq->buffer;
- int sector_count = rq->nr_sectors;
-
- if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
- hwif->sg_dma_direction = PCI_DMA_TODEVICE;
- else
- hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
-
-#if 1
- if (sector_count > 256)
- BUG();
-
- if (sector_count > 128) {
-#else
- while (sector_count > 128) {
-#endif
- memset(&sg[nents], 0, sizeof(*sg));
- sg[nents].page = virt_to_page(virt_addr);
- sg[nents].offset = offset_in_page(virt_addr);
- sg[nents].length = 128 * SECTOR_SIZE;
- nents++;
- virt_addr = virt_addr + (128 * SECTOR_SIZE);
- sector_count -= 128;
- }
- memset(&sg[nents], 0, sizeof(*sg));
- sg[nents].page = virt_to_page(virt_addr);
- sg[nents].offset = offset_in_page(virt_addr);
- sg[nents].length = sector_count * SECTOR_SIZE;
- nents++;
-
- return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction);
-}
-
-EXPORT_SYMBOL_GPL(ide_raw_build_sglist);
-