Skip to content

Commit

Permalink
x86: move dma_map_sg to common header
Browse files Browse the repository at this point in the history
the old i386 implementation is moved to pci-base_32.c

Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Glauber Costa authored and Ingo Molnar committed Apr 19, 2008
1 parent 0cb0ae6 commit 16a3ce9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
19 changes: 19 additions & 0 deletions arch/x86/kernel/pci-base_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,28 @@ static dma_addr_t pci32_map_single(struct device *dev, void *ptr,
return virt_to_phys(ptr);
}

static int pci32_dma_map_sg(struct device *dev, struct scatterlist *sglist,
int nents, int direction)
{
struct scatterlist *sg;
int i;

WARN_ON(nents == 0 || sglist[0].length == 0);

for_each_sg(sglist, sg, nents, i) {
BUG_ON(!sg_page(sg));

sg->dma_address = sg_phys(sg);
}

flush_write_buffers();
return nents;
}

static const struct dma_mapping_ops pci32_dma_ops = {
.map_single = pci32_map_single,
.unmap_single = NULL,
.map_sg = pci32_dma_map_sg,
};

const struct dma_mapping_ops *dma_ops = &pci32_dma_ops;
Expand Down
8 changes: 7 additions & 1 deletion include/asm-x86/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,11 @@ dma_unmap_single(struct device *dev, dma_addr_t addr, size_t size,
dma_ops->unmap_single(dev, addr, size, direction);
}


static inline int
dma_map_sg(struct device *hwdev, struct scatterlist *sg,
int nents, int direction)
{
BUG_ON(!valid_dma_direction(direction));
return dma_ops->map_sg(hwdev, sg, nents, direction);
}
#endif
20 changes: 0 additions & 20 deletions include/asm-x86/dma-mapping_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
void dma_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t dma_handle);

static inline int
dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
enum dma_data_direction direction)
{
struct scatterlist *sg;
int i;

BUG_ON(!valid_dma_direction(direction));
WARN_ON(nents == 0 || sglist[0].length == 0);

for_each_sg(sglist, sg, nents, i) {
BUG_ON(!sg_page(sg));

sg->dma_address = sg_phys(sg);
}

flush_write_buffers();
return nents;
}

static inline dma_addr_t
dma_map_page(struct device *dev, struct page *page, unsigned long offset,
size_t size, enum dma_data_direction direction)
Expand Down
7 changes: 0 additions & 7 deletions include/asm-x86/dma-mapping_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
flush_write_buffers();
}

static inline int
dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, int direction)
{
BUG_ON(!valid_dma_direction(direction));
return dma_ops->map_sg(hwdev, sg, nents, direction);
}

static inline void
dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
int direction)
Expand Down

0 comments on commit 16a3ce9

Please sign in to comment.