Commit f4421b9c authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ppc64: Use enum dma_data_direction for the vio DMA api routines.

From: Stephen Rothwell <sfr@canb.auug.org.au>

This patch uses enum dma_data_direction for the vio DMA api routines.
This allows us to remove some include of linux/pci.h.

Also missed some pci_dma_mapping_error uses.
parent 61d5b689
......@@ -77,7 +77,7 @@ dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, size_t size,
return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
#ifdef CONFIG_PPC_PSERIES
if (dev->bus == &vio_bus_type)
return vio_map_single(to_vio_dev(dev), cpu_addr, size, (int)direction);
return vio_map_single(to_vio_dev(dev), cpu_addr, size, direction);
#endif
BUG();
return (dma_addr_t)0;
......@@ -91,7 +91,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
#ifdef CONFIG_PPC_PSERIES
else if (dev->bus == &vio_bus_type)
vio_unmap_single(to_vio_dev(dev), dma_addr, size, (int)direction);
vio_unmap_single(to_vio_dev(dev), dma_addr, size, direction);
#endif
else
BUG();
......@@ -106,7 +106,7 @@ dma_addr_t dma_map_page(struct device *dev, struct page *page,
return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
#ifdef CONFIG_PPC_PSERIES
if (dev->bus == &vio_bus_type)
return vio_map_page(to_vio_dev(dev), page, offset, size, (int)direction);
return vio_map_page(to_vio_dev(dev), page, offset, size, direction);
#endif
BUG();
return (dma_addr_t)0;
......@@ -120,7 +120,7 @@ void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
#ifdef CONFIG_PPC_PSERIES
else if (dev->bus == &vio_bus_type)
vio_unmap_page(to_vio_dev(dev), dma_address, size, (int)direction);
vio_unmap_page(to_vio_dev(dev), dma_address, size, direction);
#endif
else
BUG();
......@@ -134,7 +134,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
#ifdef CONFIG_PPC_PSERIES
if (dev->bus == &vio_bus_type)
return vio_map_sg(to_vio_dev(dev), sg, nents, (int)direction);
return vio_map_sg(to_vio_dev(dev), sg, nents, direction);
#endif
BUG();
return 0;
......@@ -148,7 +148,7 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
#ifdef CONFIG_PPC_PSERIES
else if (dev->bus == &vio_bus_type)
vio_unmap_sg(to_vio_dev(dev), sg, nhwentries, (int)direction);
vio_unmap_sg(to_vio_dev(dev), sg, nhwentries, direction);
#endif
else
BUG();
......@@ -162,7 +162,7 @@ void dma_sync_single(struct device *dev, dma_addr_t dma_handle, size_t size,
pci_dma_sync_single(to_pci_dev(dev), dma_handle, size, (int)direction);
#ifdef CONFIG_PPC_PSERIES
else if (dev->bus == &vio_bus_type)
vio_dma_sync_single(to_vio_dev(dev), dma_handle, size, (int)direction);
vio_dma_sync_single(to_vio_dev(dev), dma_handle, size, direction);
#endif
else
BUG();
......@@ -176,7 +176,7 @@ void dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems,
pci_dma_sync_sg(to_pci_dev(dev), sg, nelems, (int)direction);
#ifdef CONFIG_PPC_PSERIES
else if (dev->bus == &vio_bus_type)
vio_dma_sync_sg(to_vio_dev(dev), sg, nelems, (int)direction);
vio_dma_sync_sg(to_vio_dev(dev), sg, nelems, direction);
#endif
else
BUG();
......
......@@ -14,7 +14,6 @@
#include <linux/init.h>
#include <linux/console.h>
#include <linux/pci.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kobject.h>
......@@ -416,14 +415,14 @@ EXPORT_SYMBOL(vio_disable_interrupts);
dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr,
size_t size, int direction )
size_t size, enum dma_data_direction direction)
{
struct iommu_table *tbl;
dma_addr_t dma_handle = DMA_ERROR_CODE;
unsigned long uaddr;
unsigned int npages;
BUG_ON(direction == PCI_DMA_NONE);
BUG_ON(direction == DMA_NONE);
uaddr = (unsigned long)vaddr;
npages = PAGE_ALIGN( uaddr + size ) - ( uaddr & PAGE_MASK );
......@@ -432,7 +431,7 @@ dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr,
tbl = dev->iommu_table;
if (tbl) {
dma_handle = iommu_alloc(tbl, vaddr, npages, direction);
dma_handle = iommu_alloc(tbl, vaddr, npages, (int)direction);
dma_handle |= (uaddr & ~PAGE_MASK);
}
......@@ -441,12 +440,12 @@ dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr,
EXPORT_SYMBOL(vio_map_single);
void vio_unmap_single(struct vio_dev *dev, dma_addr_t dma_handle,
size_t size, int direction)
size_t size, enum dma_data_direction direction)
{
struct iommu_table * tbl;
unsigned int npages;
BUG_ON(direction == PCI_DMA_NONE);
BUG_ON(direction == DMA_NONE);
npages = PAGE_ALIGN( dma_handle + size ) - ( dma_handle & PAGE_MASK );
npages >>= PAGE_SHIFT;
......@@ -458,11 +457,11 @@ void vio_unmap_single(struct vio_dev *dev, dma_addr_t dma_handle,
EXPORT_SYMBOL(vio_unmap_single);
int vio_map_sg(struct vio_dev *vdev, struct scatterlist *sglist, int nelems,
int direction)
enum dma_data_direction direction)
{
struct iommu_table *tbl;
BUG_ON(direction == PCI_DMA_NONE);
BUG_ON(direction == DMA_NONE);
if (nelems == 0)
return 0;
......@@ -471,16 +470,16 @@ int vio_map_sg(struct vio_dev *vdev, struct scatterlist *sglist, int nelems,
if (!tbl)
return 0;
return iommu_alloc_sg(tbl, &vdev->dev, sglist, nelems, direction);
return iommu_alloc_sg(tbl, &vdev->dev, sglist, nelems, (int)direction);
}
EXPORT_SYMBOL(vio_map_sg);
void vio_unmap_sg(struct vio_dev *vdev, struct scatterlist *sglist, int nelems,
int direction)
enum dma_data_direction direction)
{
struct iommu_table *tbl;
BUG_ON(direction == PCI_DMA_NONE);
BUG_ON(direction == DMA_NONE);
tbl = vdev->iommu_table;
if (tbl)
......@@ -516,7 +515,7 @@ void *vio_alloc_consistent(struct vio_dev *dev, size_t size,
/* Page allocation succeeded */
memset(ret, 0, npages << PAGE_SHIFT);
/* Set up tces to cover the allocated range */
tce = iommu_alloc(tbl, ret, npages, PCI_DMA_BIDIRECTIONAL);
tce = iommu_alloc(tbl, ret, npages, (int)DMA_BIDIRECTIONAL);
if (tce == DMA_ERROR_CODE) {
PPCDBG(PPCDBG_TCE, "vio_alloc_consistent: iommu_alloc failed\n" );
free_pages((unsigned long)ret, order);
......
......@@ -39,7 +39,6 @@
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
......@@ -218,7 +217,7 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
ibmveth_assert(index != 0xffff);
ibmveth_assert(pool->skbuff[index] == NULL);
dma_addr = vio_map_single(adapter->vdev, skb->data, pool->buff_size, PCI_DMA_FROMDEVICE);
dma_addr = vio_map_single(adapter->vdev, skb->data, pool->buff_size, DMA_FROM_DEVICE);
pool->dma_addr[index] = dma_addr;
pool->skbuff[index] = skb;
......@@ -236,7 +235,7 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
if(lpar_rc != H_Success) {
pool->skbuff[index] = NULL;
pool->consumer_index--;
vio_unmap_single(adapter->vdev, pool->dma_addr[index], pool->buff_size, PCI_DMA_FROMDEVICE);
vio_unmap_single(adapter->vdev, pool->dma_addr[index], pool->buff_size, DMA_FROM_DEVICE);
dev_kfree_skb_any(skb);
adapter->replenish_add_buff_failure++;
break;
......@@ -300,7 +299,7 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibm
vio_unmap_single(adapter->vdev,
pool->dma_addr[i],
pool->buff_size,
PCI_DMA_FROMDEVICE);
DMA_FROM_DEVICE);
dev_kfree_skb_any(skb);
pool->skbuff[i] = NULL;
}
......@@ -338,7 +337,7 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64
vio_unmap_single(adapter->vdev,
adapter->rx_buff_pool[pool].dma_addr[index],
adapter->rx_buff_pool[pool].buff_size,
PCI_DMA_FROMDEVICE);
DMA_FROM_DEVICE);
free_index = adapter->rx_buff_pool[pool].producer_index++ % adapter->rx_buff_pool[pool].size;
adapter->rx_buff_pool[pool].free_map[free_index] = index;
......@@ -406,7 +405,7 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
{
if(adapter->buffer_list_addr != NULL) {
if(!vio_dma_mapping_error(adapter->buffer_list_dma)) {
vio_unmap_single(adapter->vdev, adapter->buffer_list_dma, 4096, PCI_DMA_BIDIRECTIONAL);
vio_unmap_single(adapter->vdev, adapter->buffer_list_dma, 4096, DMA_BIDIRECTIONAL);
adapter->buffer_list_dma = DMA_ERROR_CODE;
}
free_page((unsigned long)adapter->buffer_list_addr);
......@@ -415,7 +414,7 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
if(adapter->filter_list_addr != NULL) {
if(!vio_dma_mapping_error(adapter->filter_list_dma)) {
vio_unmap_single(adapter->vdev, adapter->filter_list_dma, 4096, PCI_DMA_BIDIRECTIONAL);
vio_unmap_single(adapter->vdev, adapter->filter_list_dma, 4096, DMA_BIDIRECTIONAL);
adapter->filter_list_dma = DMA_ERROR_CODE;
}
free_page((unsigned long)adapter->filter_list_addr);
......@@ -424,7 +423,7 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
if(adapter->rx_queue.queue_addr != NULL) {
if(!vio_dma_mapping_error(adapter->rx_queue.queue_dma)) {
vio_unmap_single(adapter->vdev, adapter->rx_queue.queue_dma, adapter->rx_queue.queue_len, PCI_DMA_BIDIRECTIONAL);
vio_unmap_single(adapter->vdev, adapter->rx_queue.queue_dma, adapter->rx_queue.queue_len, DMA_BIDIRECTIONAL);
adapter->rx_queue.queue_dma = DMA_ERROR_CODE;
}
kfree(adapter->rx_queue.queue_addr);
......@@ -470,9 +469,9 @@ static int ibmveth_open(struct net_device *netdev)
return -ENOMEM;
}
adapter->buffer_list_dma = vio_map_single(adapter->vdev, adapter->buffer_list_addr, 4096, PCI_DMA_BIDIRECTIONAL);
adapter->filter_list_dma = vio_map_single(adapter->vdev, adapter->filter_list_addr, 4096, PCI_DMA_BIDIRECTIONAL);
adapter->rx_queue.queue_dma = vio_map_single(adapter->vdev, adapter->rx_queue.queue_addr, adapter->rx_queue.queue_len, PCI_DMA_BIDIRECTIONAL);
adapter->buffer_list_dma = vio_map_single(adapter->vdev, adapter->buffer_list_addr, 4096, DMA_BIDIRECTIONAL);
adapter->filter_list_dma = vio_map_single(adapter->vdev, adapter->filter_list_addr, 4096, DMA_BIDIRECTIONAL);
adapter->rx_queue.queue_dma = vio_map_single(adapter->vdev, adapter->rx_queue.queue_addr, adapter->rx_queue.queue_len, DMA_BIDIRECTIONAL);
if((vio_dma_mapping_error(adapter->buffer_list_dma) ) ||
(vio_dma_mapping_error(adapter->filter_list_dma)) ||
......@@ -673,7 +672,7 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
vio_unmap_single(adapter->vdev,
desc[curfrag+1].fields.address,
desc[curfrag+1].fields.length,
PCI_DMA_TODEVICE);
DMA_TO_DEVICE);
curfrag++;
}
dev_kfree_skb(skb);
......@@ -710,7 +709,7 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
}
do {
vio_unmap_single(adapter->vdev, desc[nfrags].fields.address, desc[nfrags].fields.length, PCI_DMA_TODEVICE);
vio_unmap_single(adapter->vdev, desc[nfrags].fields.address, desc[nfrags].fields.length, DMA_TO_DEVICE);
} while(--nfrags >= 0);
dev_kfree_skb(skb);
......
......@@ -17,7 +17,6 @@
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/device.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <asm/hvcall.h>
#include <asm/prom.h>
......@@ -58,13 +57,13 @@ int vio_enable_interrupts(struct vio_dev *dev);
int vio_disable_interrupts(struct vio_dev *dev);
dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr,
size_t size, int direction);
size_t size, enum dma_data_direction direction);
void vio_unmap_single(struct vio_dev *dev, dma_addr_t dma_handle,
size_t size, int direction);
size_t size, enum dma_data_direction direction);
int vio_map_sg(struct vio_dev *vdev, struct scatterlist *sglist,
int nelems, int direction);
int nelems, enum dma_data_direction direction);
void vio_unmap_sg(struct vio_dev *vdev, struct scatterlist *sglist,
int nelems, int direction);
int nelems, enum dma_data_direction direction);
void *vio_alloc_consistent(struct vio_dev *dev, size_t size,
dma_addr_t *dma_handle);
void vio_free_consistent(struct vio_dev *dev, size_t size, void *vaddr,
......@@ -81,18 +80,18 @@ static inline int vio_dma_supported(struct vio_dev *hwdev, u64 mask)
static inline void vio_dma_sync_single(struct vio_dev *hwdev,
dma_addr_t dma_handle,
size_t size, int direction)
dma_addr_t dma_handle, size_t size,
enum dma_data_direction direction)
{
BUG_ON(direction == PCI_DMA_NONE);
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline void vio_dma_sync_sg(struct vio_dev *hwdev,
struct scatterlist *sg,
int nelems, int direction)
struct scatterlist *sg, int nelems,
enum dma_data_direction direction)
{
BUG_ON(direction == PCI_DMA_NONE);
BUG_ON(direction == DMA_NONE);
/* nothing to do */
}
static inline int vio_set_dma_mask(struct vio_dev *dev, u64 mask) { return -EIO; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment