[PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-04-22 Thread Alexey Charkov
Remove legacy PCI DMA wrappers and instead use generic DMA functions
directly in preparation for OF bus binding

Signed-off-by: Alexey Charkov 
---
 drivers/net/ethernet/via/via-rhine.c | 84 ++--
 1 file changed, 43 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/via/via-rhine.c 
b/drivers/net/ethernet/via/via-rhine.c
index f61dc2b..0674d0f 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -919,10 +919,10 @@ static int rhine_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto err_out;
 
/* this should always be supported */
-   rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   rc = dma_set_mask(>dev, DMA_BIT_MASK(32));
if (rc) {
dev_err(>dev,
-   "32-bit PCI DMA addresses not supported by the 
card!?\n");
+   "32-bit DMA addresses not supported by the card!?\n");
goto err_out_pci_disable;
}
 
@@ -1096,23 +1096,25 @@ static int alloc_ring(struct net_device* dev)
void *ring;
dma_addr_t ring_dma;
 
-   ring = pci_alloc_consistent(rp->pdev,
-   RX_RING_SIZE * sizeof(struct rx_desc) +
-   TX_RING_SIZE * sizeof(struct tx_desc),
-   _dma);
+   ring = dma_alloc_coherent(>pdev->dev,
+ RX_RING_SIZE * sizeof(struct rx_desc) +
+ TX_RING_SIZE * sizeof(struct tx_desc),
+ _dma,
+ GFP_ATOMIC);
if (!ring) {
netdev_err(dev, "Could not allocate DMA memory\n");
return -ENOMEM;
}
if (rp->quirks & rqRhineI) {
-   rp->tx_bufs = pci_alloc_consistent(rp->pdev,
-  PKT_BUF_SZ * TX_RING_SIZE,
-  >tx_bufs_dma);
+   rp->tx_bufs = dma_alloc_coherent(>pdev->dev,
+PKT_BUF_SZ * TX_RING_SIZE,
+>tx_bufs_dma,
+GFP_ATOMIC);
if (rp->tx_bufs == NULL) {
-   pci_free_consistent(rp->pdev,
-   RX_RING_SIZE * sizeof(struct rx_desc) +
-   TX_RING_SIZE * sizeof(struct tx_desc),
-   ring, ring_dma);
+   dma_free_coherent(>pdev->dev,
+ RX_RING_SIZE * sizeof(struct rx_desc) 
+
+ TX_RING_SIZE * sizeof(struct tx_desc),
+ ring, ring_dma);
return -ENOMEM;
}
}
@@ -1129,15 +1131,15 @@ static void free_ring(struct net_device* dev)
 {
struct rhine_private *rp = netdev_priv(dev);
 
-   pci_free_consistent(rp->pdev,
-   RX_RING_SIZE * sizeof(struct rx_desc) +
-   TX_RING_SIZE * sizeof(struct tx_desc),
-   rp->rx_ring, rp->rx_ring_dma);
+   dma_free_coherent(>pdev->dev,
+ RX_RING_SIZE * sizeof(struct rx_desc) +
+ TX_RING_SIZE * sizeof(struct tx_desc),
+ rp->rx_ring, rp->rx_ring_dma);
rp->tx_ring = NULL;
 
if (rp->tx_bufs)
-   pci_free_consistent(rp->pdev, PKT_BUF_SZ * TX_RING_SIZE,
-   rp->tx_bufs, rp->tx_bufs_dma);
+   dma_free_coherent(>pdev->dev, PKT_BUF_SZ * TX_RING_SIZE,
+ rp->tx_bufs, rp->tx_bufs_dma);
 
rp->tx_bufs = NULL;
 
@@ -1174,8 +1176,8 @@ static void alloc_rbufs(struct net_device *dev)
break;
 
rp->rx_skbuff_dma[i] =
-   pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz,
-  PCI_DMA_FROMDEVICE);
+   dma_map_single(>pdev->dev, skb->data, rp->rx_buf_sz,
+  DMA_FROM_DEVICE);
if (dma_mapping_error(>pdev->dev, rp->rx_skbuff_dma[i])) {
rp->rx_skbuff_dma[i] = 0;
dev_kfree_skb(skb);
@@ -1197,9 +1199,9 @@ static void free_rbufs(struct net_device* dev)
rp->rx_ring[i].rx_status = 0;
rp->rx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid 
address. */
if (rp->rx_skbuff[i]) {
-   pci_unmap_single(rp->pdev,
+   dma_unmap_single(>pdev->dev,
 rp->rx_skbuff_dma[i],
-rp->rx_buf_sz, PCI_DMA_FROMDEVICE);
+ 

[PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-04-22 Thread Alexey Charkov
Remove legacy PCI DMA wrappers and instead use generic DMA functions
directly in preparation for OF bus binding

Signed-off-by: Alexey Charkov alch...@gmail.com
---
 drivers/net/ethernet/via/via-rhine.c | 84 ++--
 1 file changed, 43 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/via/via-rhine.c 
b/drivers/net/ethernet/via/via-rhine.c
index f61dc2b..0674d0f 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -919,10 +919,10 @@ static int rhine_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto err_out;
 
/* this should always be supported */
-   rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   rc = dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
if (rc) {
dev_err(pdev-dev,
-   32-bit PCI DMA addresses not supported by the 
card!?\n);
+   32-bit DMA addresses not supported by the card!?\n);
goto err_out_pci_disable;
}
 
@@ -1096,23 +1096,25 @@ static int alloc_ring(struct net_device* dev)
void *ring;
dma_addr_t ring_dma;
 
-   ring = pci_alloc_consistent(rp-pdev,
-   RX_RING_SIZE * sizeof(struct rx_desc) +
-   TX_RING_SIZE * sizeof(struct tx_desc),
-   ring_dma);
+   ring = dma_alloc_coherent(rp-pdev-dev,
+ RX_RING_SIZE * sizeof(struct rx_desc) +
+ TX_RING_SIZE * sizeof(struct tx_desc),
+ ring_dma,
+ GFP_ATOMIC);
if (!ring) {
netdev_err(dev, Could not allocate DMA memory\n);
return -ENOMEM;
}
if (rp-quirks  rqRhineI) {
-   rp-tx_bufs = pci_alloc_consistent(rp-pdev,
-  PKT_BUF_SZ * TX_RING_SIZE,
-  rp-tx_bufs_dma);
+   rp-tx_bufs = dma_alloc_coherent(rp-pdev-dev,
+PKT_BUF_SZ * TX_RING_SIZE,
+rp-tx_bufs_dma,
+GFP_ATOMIC);
if (rp-tx_bufs == NULL) {
-   pci_free_consistent(rp-pdev,
-   RX_RING_SIZE * sizeof(struct rx_desc) +
-   TX_RING_SIZE * sizeof(struct tx_desc),
-   ring, ring_dma);
+   dma_free_coherent(rp-pdev-dev,
+ RX_RING_SIZE * sizeof(struct rx_desc) 
+
+ TX_RING_SIZE * sizeof(struct tx_desc),
+ ring, ring_dma);
return -ENOMEM;
}
}
@@ -1129,15 +1131,15 @@ static void free_ring(struct net_device* dev)
 {
struct rhine_private *rp = netdev_priv(dev);
 
-   pci_free_consistent(rp-pdev,
-   RX_RING_SIZE * sizeof(struct rx_desc) +
-   TX_RING_SIZE * sizeof(struct tx_desc),
-   rp-rx_ring, rp-rx_ring_dma);
+   dma_free_coherent(rp-pdev-dev,
+ RX_RING_SIZE * sizeof(struct rx_desc) +
+ TX_RING_SIZE * sizeof(struct tx_desc),
+ rp-rx_ring, rp-rx_ring_dma);
rp-tx_ring = NULL;
 
if (rp-tx_bufs)
-   pci_free_consistent(rp-pdev, PKT_BUF_SZ * TX_RING_SIZE,
-   rp-tx_bufs, rp-tx_bufs_dma);
+   dma_free_coherent(rp-pdev-dev, PKT_BUF_SZ * TX_RING_SIZE,
+ rp-tx_bufs, rp-tx_bufs_dma);
 
rp-tx_bufs = NULL;
 
@@ -1174,8 +1176,8 @@ static void alloc_rbufs(struct net_device *dev)
break;
 
rp-rx_skbuff_dma[i] =
-   pci_map_single(rp-pdev, skb-data, rp-rx_buf_sz,
-  PCI_DMA_FROMDEVICE);
+   dma_map_single(rp-pdev-dev, skb-data, rp-rx_buf_sz,
+  DMA_FROM_DEVICE);
if (dma_mapping_error(rp-pdev-dev, rp-rx_skbuff_dma[i])) {
rp-rx_skbuff_dma[i] = 0;
dev_kfree_skb(skb);
@@ -1197,9 +1199,9 @@ static void free_rbufs(struct net_device* dev)
rp-rx_ring[i].rx_status = 0;
rp-rx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid 
address. */
if (rp-rx_skbuff[i]) {
-   pci_unmap_single(rp-pdev,
+   dma_unmap_single(rp-pdev-dev,
 rp-rx_skbuff_dma[i],
-rp-rx_buf_sz, PCI_DMA_FROMDEVICE);
+ 

Re: [PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-01-27 Thread Alexey Charkov
2014/1/27 Ben Hutchings :
> On Mon, 2014-01-27 at 15:51 +0400, Alexey Charkov wrote:
>> Remove legacy PCI DMA wrappers and instead use generic DMA functions
>> directly in preparation for OF bus binding
>>
>> Signed-off-by: Alexey Charkov 
>> Signed-off-by: Roger Luethi 
>> ---
>>  drivers/net/ethernet/via/via-rhine.c | 56 
>> +++-
>>  1 file changed, 29 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/via/via-rhine.c 
>> b/drivers/net/ethernet/via/via-rhine.c
>> index ef312bc..fee8732 100644
>> --- a/drivers/net/ethernet/via/via-rhine.c
>> +++ b/drivers/net/ethernet/via/via-rhine.c
>> @@ -919,10 +919,10 @@ static int rhine_init_one(struct pci_dev *pdev, const 
>> struct pci_device_id *ent)
>>   goto err_out;
>>
>>   /* this should always be supported */
>> - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
>> + rc = dma_set_mask(>dev, DMA_BIT_MASK(32));
>>   if (rc) {
>>   dev_err(>dev,
>> - "32-bit PCI DMA addresses not supported by the 
>> card!?\n");
>> + "32-bit DMA addresses not supported by the card!?\n");
>>   goto err_out;
>>   }
>>
>> @@ -1094,20 +1094,22 @@ static int alloc_ring(struct net_device* dev)
>>   void *ring;
>>   dma_addr_t ring_dma;
>>
>> - ring = pci_alloc_consistent(rp->pdev,
>> + ring = dma_alloc_coherent(>pdev->dev,
>>   RX_RING_SIZE * sizeof(struct rx_desc) +
>>   TX_RING_SIZE * sizeof(struct tx_desc),
>> - _dma);
>> + _dma,
>> + GFP_ATOMIC);
> [...]
>
> Indentation is messed up here (and in several other function calls
> you're changing).  You should align the function arguments so each line
> begins in the column after the opening parenthesis.

Ben, thanks for pointing out. I actually just tried to follow the
style of surrounding code, but happy to adjust if that's the preferred
option. From what I can see, these lines should still fit in below 80
cols even with increased indents...

Should we then also adjust other function calls within the driver with
similar indentation (if any), that are currently not touched by this
patch series?

Thanks,
Alexey
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-01-27 Thread Ben Hutchings
On Mon, 2014-01-27 at 19:26 +0400, Alexey Charkov wrote:
> 2014/1/27 Ben Hutchings :
> > On Mon, 2014-01-27 at 15:51 +0400, Alexey Charkov wrote:
[...]
> >> @@ -1094,20 +1094,22 @@ static int alloc_ring(struct net_device* dev)
> >>   void *ring;
> >>   dma_addr_t ring_dma;
> >>
> >> - ring = pci_alloc_consistent(rp->pdev,
> >> + ring = dma_alloc_coherent(>pdev->dev,
> >>   RX_RING_SIZE * sizeof(struct rx_desc) +
> >>   TX_RING_SIZE * sizeof(struct tx_desc),
> >> - _dma);
> >> + _dma,
> >> + GFP_ATOMIC);
> > [...]
> >
> > Indentation is messed up here (and in several other function calls
> > you're changing).  You should align the function arguments so each line
> > begins in the column after the opening parenthesis.
> 
> Ben, thanks for pointing out. I actually just tried to follow the
> style of surrounding code, but happy to adjust if that's the preferred
> option. From what I can see, these lines should still fit in below 80
> cols even with increased indents...
> 
> Should we then also adjust other function calls within the driver with
> similar indentation (if any), that are currently not touched by this
> patch series?

There is no need to do that at the same time, but it would be a nice bit
of cleanup.

Ben.

-- 
Ben Hutchings
If at first you don't succeed, you're doing about average.


signature.asc
Description: This is a digitally signed message part


Re: [PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-01-27 Thread Ben Hutchings
On Mon, 2014-01-27 at 15:51 +0400, Alexey Charkov wrote:
> Remove legacy PCI DMA wrappers and instead use generic DMA functions
> directly in preparation for OF bus binding
> 
> Signed-off-by: Alexey Charkov 
> Signed-off-by: Roger Luethi 
> ---
>  drivers/net/ethernet/via/via-rhine.c | 56 
> +++-
>  1 file changed, 29 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/net/ethernet/via/via-rhine.c 
> b/drivers/net/ethernet/via/via-rhine.c
> index ef312bc..fee8732 100644
> --- a/drivers/net/ethernet/via/via-rhine.c
> +++ b/drivers/net/ethernet/via/via-rhine.c
> @@ -919,10 +919,10 @@ static int rhine_init_one(struct pci_dev *pdev, const 
> struct pci_device_id *ent)
>   goto err_out;
>  
>   /* this should always be supported */
> - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
> + rc = dma_set_mask(>dev, DMA_BIT_MASK(32));
>   if (rc) {
>   dev_err(>dev,
> - "32-bit PCI DMA addresses not supported by the 
> card!?\n");
> + "32-bit DMA addresses not supported by the card!?\n");
>   goto err_out;
>   }
>  
> @@ -1094,20 +1094,22 @@ static int alloc_ring(struct net_device* dev)
>   void *ring;
>   dma_addr_t ring_dma;
>  
> - ring = pci_alloc_consistent(rp->pdev,
> + ring = dma_alloc_coherent(>pdev->dev,
>   RX_RING_SIZE * sizeof(struct rx_desc) +
>   TX_RING_SIZE * sizeof(struct tx_desc),
> - _dma);
> + _dma,
> + GFP_ATOMIC);
[...]

Indentation is messed up here (and in several other function calls
you're changing).  You should align the function arguments so each line
begins in the column after the opening parenthesis.

Ben.

-- 
Ben Hutchings
If at first you don't succeed, you're doing about average.


signature.asc
Description: This is a digitally signed message part


[PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-01-27 Thread Alexey Charkov
Remove legacy PCI DMA wrappers and instead use generic DMA functions
directly in preparation for OF bus binding

Signed-off-by: Alexey Charkov 
Signed-off-by: Roger Luethi 
---
 drivers/net/ethernet/via/via-rhine.c | 56 +++-
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/via/via-rhine.c 
b/drivers/net/ethernet/via/via-rhine.c
index ef312bc..fee8732 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -919,10 +919,10 @@ static int rhine_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto err_out;
 
/* this should always be supported */
-   rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   rc = dma_set_mask(>dev, DMA_BIT_MASK(32));
if (rc) {
dev_err(>dev,
-   "32-bit PCI DMA addresses not supported by the 
card!?\n");
+   "32-bit DMA addresses not supported by the card!?\n");
goto err_out;
}
 
@@ -1094,20 +1094,22 @@ static int alloc_ring(struct net_device* dev)
void *ring;
dma_addr_t ring_dma;
 
-   ring = pci_alloc_consistent(rp->pdev,
+   ring = dma_alloc_coherent(>pdev->dev,
RX_RING_SIZE * sizeof(struct rx_desc) +
TX_RING_SIZE * sizeof(struct tx_desc),
-   _dma);
+   _dma,
+   GFP_ATOMIC);
if (!ring) {
netdev_err(dev, "Could not allocate DMA memory\n");
return -ENOMEM;
}
if (rp->quirks & rqRhineI) {
-   rp->tx_bufs = pci_alloc_consistent(rp->pdev,
+   rp->tx_bufs = dma_alloc_coherent(>pdev->dev,
   PKT_BUF_SZ * TX_RING_SIZE,
-  >tx_bufs_dma);
+  >tx_bufs_dma,
+  GFP_ATOMIC);
if (rp->tx_bufs == NULL) {
-   pci_free_consistent(rp->pdev,
+   dma_free_coherent(>pdev->dev,
RX_RING_SIZE * sizeof(struct rx_desc) +
TX_RING_SIZE * sizeof(struct tx_desc),
ring, ring_dma);
@@ -1127,14 +1129,14 @@ static void free_ring(struct net_device* dev)
 {
struct rhine_private *rp = netdev_priv(dev);
 
-   pci_free_consistent(rp->pdev,
+   dma_free_coherent(>pdev->dev,
RX_RING_SIZE * sizeof(struct rx_desc) +
TX_RING_SIZE * sizeof(struct tx_desc),
rp->rx_ring, rp->rx_ring_dma);
rp->tx_ring = NULL;
 
if (rp->tx_bufs)
-   pci_free_consistent(rp->pdev, PKT_BUF_SZ * TX_RING_SIZE,
+   dma_free_coherent(>pdev->dev, PKT_BUF_SZ * TX_RING_SIZE,
rp->tx_bufs, rp->tx_bufs_dma);
 
rp->tx_bufs = NULL;
@@ -1172,8 +1174,8 @@ static void alloc_rbufs(struct net_device *dev)
break;
 
rp->rx_skbuff_dma[i] =
-   pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz,
-  PCI_DMA_FROMDEVICE);
+   dma_map_single(>pdev->dev, skb->data, rp->rx_buf_sz,
+  DMA_FROM_DEVICE);
if (dma_mapping_error(>pdev->dev, rp->rx_skbuff_dma[i])) {
rp->rx_skbuff_dma[i] = 0;
dev_kfree_skb(skb);
@@ -1195,9 +1197,9 @@ static void free_rbufs(struct net_device* dev)
rp->rx_ring[i].rx_status = 0;
rp->rx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid 
address. */
if (rp->rx_skbuff[i]) {
-   pci_unmap_single(rp->pdev,
+   dma_unmap_single(>pdev->dev,
 rp->rx_skbuff_dma[i],
-rp->rx_buf_sz, PCI_DMA_FROMDEVICE);
+rp->rx_buf_sz, DMA_FROM_DEVICE);
dev_kfree_skb(rp->rx_skbuff[i]);
}
rp->rx_skbuff[i] = NULL;
@@ -1236,10 +1238,10 @@ static void free_tbufs(struct net_device* dev)
rp->tx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid 
address. */
if (rp->tx_skbuff[i]) {
if (rp->tx_skbuff_dma[i]) {
-   pci_unmap_single(rp->pdev,
+   dma_unmap_single(>pdev->dev,
 rp->tx_skbuff_dma[i],
 rp->tx_skbuff[i]->len,
-

[PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-01-27 Thread Alexey Charkov
Remove legacy PCI DMA wrappers and instead use generic DMA functions
directly in preparation for OF bus binding

Signed-off-by: Alexey Charkov alch...@gmail.com
Signed-off-by: Roger Luethi r...@hellgate.ch
---
 drivers/net/ethernet/via/via-rhine.c | 56 +++-
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/via/via-rhine.c 
b/drivers/net/ethernet/via/via-rhine.c
index ef312bc..fee8732 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -919,10 +919,10 @@ static int rhine_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto err_out;
 
/* this should always be supported */
-   rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   rc = dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
if (rc) {
dev_err(pdev-dev,
-   32-bit PCI DMA addresses not supported by the 
card!?\n);
+   32-bit DMA addresses not supported by the card!?\n);
goto err_out;
}
 
@@ -1094,20 +1094,22 @@ static int alloc_ring(struct net_device* dev)
void *ring;
dma_addr_t ring_dma;
 
-   ring = pci_alloc_consistent(rp-pdev,
+   ring = dma_alloc_coherent(rp-pdev-dev,
RX_RING_SIZE * sizeof(struct rx_desc) +
TX_RING_SIZE * sizeof(struct tx_desc),
-   ring_dma);
+   ring_dma,
+   GFP_ATOMIC);
if (!ring) {
netdev_err(dev, Could not allocate DMA memory\n);
return -ENOMEM;
}
if (rp-quirks  rqRhineI) {
-   rp-tx_bufs = pci_alloc_consistent(rp-pdev,
+   rp-tx_bufs = dma_alloc_coherent(rp-pdev-dev,
   PKT_BUF_SZ * TX_RING_SIZE,
-  rp-tx_bufs_dma);
+  rp-tx_bufs_dma,
+  GFP_ATOMIC);
if (rp-tx_bufs == NULL) {
-   pci_free_consistent(rp-pdev,
+   dma_free_coherent(rp-pdev-dev,
RX_RING_SIZE * sizeof(struct rx_desc) +
TX_RING_SIZE * sizeof(struct tx_desc),
ring, ring_dma);
@@ -1127,14 +1129,14 @@ static void free_ring(struct net_device* dev)
 {
struct rhine_private *rp = netdev_priv(dev);
 
-   pci_free_consistent(rp-pdev,
+   dma_free_coherent(rp-pdev-dev,
RX_RING_SIZE * sizeof(struct rx_desc) +
TX_RING_SIZE * sizeof(struct tx_desc),
rp-rx_ring, rp-rx_ring_dma);
rp-tx_ring = NULL;
 
if (rp-tx_bufs)
-   pci_free_consistent(rp-pdev, PKT_BUF_SZ * TX_RING_SIZE,
+   dma_free_coherent(rp-pdev-dev, PKT_BUF_SZ * TX_RING_SIZE,
rp-tx_bufs, rp-tx_bufs_dma);
 
rp-tx_bufs = NULL;
@@ -1172,8 +1174,8 @@ static void alloc_rbufs(struct net_device *dev)
break;
 
rp-rx_skbuff_dma[i] =
-   pci_map_single(rp-pdev, skb-data, rp-rx_buf_sz,
-  PCI_DMA_FROMDEVICE);
+   dma_map_single(rp-pdev-dev, skb-data, rp-rx_buf_sz,
+  DMA_FROM_DEVICE);
if (dma_mapping_error(rp-pdev-dev, rp-rx_skbuff_dma[i])) {
rp-rx_skbuff_dma[i] = 0;
dev_kfree_skb(skb);
@@ -1195,9 +1197,9 @@ static void free_rbufs(struct net_device* dev)
rp-rx_ring[i].rx_status = 0;
rp-rx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid 
address. */
if (rp-rx_skbuff[i]) {
-   pci_unmap_single(rp-pdev,
+   dma_unmap_single(rp-pdev-dev,
 rp-rx_skbuff_dma[i],
-rp-rx_buf_sz, PCI_DMA_FROMDEVICE);
+rp-rx_buf_sz, DMA_FROM_DEVICE);
dev_kfree_skb(rp-rx_skbuff[i]);
}
rp-rx_skbuff[i] = NULL;
@@ -1236,10 +1238,10 @@ static void free_tbufs(struct net_device* dev)
rp-tx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid 
address. */
if (rp-tx_skbuff[i]) {
if (rp-tx_skbuff_dma[i]) {
-   pci_unmap_single(rp-pdev,
+   dma_unmap_single(rp-pdev-dev,
 rp-tx_skbuff_dma[i],
 rp-tx_skbuff[i]-len,
-

Re: [PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-01-27 Thread Ben Hutchings
On Mon, 2014-01-27 at 19:26 +0400, Alexey Charkov wrote:
 2014/1/27 Ben Hutchings b...@decadent.org.uk:
  On Mon, 2014-01-27 at 15:51 +0400, Alexey Charkov wrote:
[...]
  @@ -1094,20 +1094,22 @@ static int alloc_ring(struct net_device* dev)
void *ring;
dma_addr_t ring_dma;
 
  - ring = pci_alloc_consistent(rp-pdev,
  + ring = dma_alloc_coherent(rp-pdev-dev,
RX_RING_SIZE * sizeof(struct rx_desc) +
TX_RING_SIZE * sizeof(struct tx_desc),
  - ring_dma);
  + ring_dma,
  + GFP_ATOMIC);
  [...]
 
  Indentation is messed up here (and in several other function calls
  you're changing).  You should align the function arguments so each line
  begins in the column after the opening parenthesis.
 
 Ben, thanks for pointing out. I actually just tried to follow the
 style of surrounding code, but happy to adjust if that's the preferred
 option. From what I can see, these lines should still fit in below 80
 cols even with increased indents...
 
 Should we then also adjust other function calls within the driver with
 similar indentation (if any), that are currently not touched by this
 patch series?

There is no need to do that at the same time, but it would be a nice bit
of cleanup.

Ben.

-- 
Ben Hutchings
If at first you don't succeed, you're doing about average.


signature.asc
Description: This is a digitally signed message part


Re: [PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-01-27 Thread Ben Hutchings
On Mon, 2014-01-27 at 15:51 +0400, Alexey Charkov wrote:
 Remove legacy PCI DMA wrappers and instead use generic DMA functions
 directly in preparation for OF bus binding
 
 Signed-off-by: Alexey Charkov alch...@gmail.com
 Signed-off-by: Roger Luethi r...@hellgate.ch
 ---
  drivers/net/ethernet/via/via-rhine.c | 56 
 +++-
  1 file changed, 29 insertions(+), 27 deletions(-)
 
 diff --git a/drivers/net/ethernet/via/via-rhine.c 
 b/drivers/net/ethernet/via/via-rhine.c
 index ef312bc..fee8732 100644
 --- a/drivers/net/ethernet/via/via-rhine.c
 +++ b/drivers/net/ethernet/via/via-rhine.c
 @@ -919,10 +919,10 @@ static int rhine_init_one(struct pci_dev *pdev, const 
 struct pci_device_id *ent)
   goto err_out;
  
   /* this should always be supported */
 - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
 + rc = dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
   if (rc) {
   dev_err(pdev-dev,
 - 32-bit PCI DMA addresses not supported by the 
 card!?\n);
 + 32-bit DMA addresses not supported by the card!?\n);
   goto err_out;
   }
  
 @@ -1094,20 +1094,22 @@ static int alloc_ring(struct net_device* dev)
   void *ring;
   dma_addr_t ring_dma;
  
 - ring = pci_alloc_consistent(rp-pdev,
 + ring = dma_alloc_coherent(rp-pdev-dev,
   RX_RING_SIZE * sizeof(struct rx_desc) +
   TX_RING_SIZE * sizeof(struct tx_desc),
 - ring_dma);
 + ring_dma,
 + GFP_ATOMIC);
[...]

Indentation is messed up here (and in several other function calls
you're changing).  You should align the function arguments so each line
begins in the column after the opening parenthesis.

Ben.

-- 
Ben Hutchings
If at first you don't succeed, you're doing about average.


signature.asc
Description: This is a digitally signed message part


Re: [PATCH 1/3] net: via-rhine: switch to generic DMA functions

2014-01-27 Thread Alexey Charkov
2014/1/27 Ben Hutchings b...@decadent.org.uk:
 On Mon, 2014-01-27 at 15:51 +0400, Alexey Charkov wrote:
 Remove legacy PCI DMA wrappers and instead use generic DMA functions
 directly in preparation for OF bus binding

 Signed-off-by: Alexey Charkov alch...@gmail.com
 Signed-off-by: Roger Luethi r...@hellgate.ch
 ---
  drivers/net/ethernet/via/via-rhine.c | 56 
 +++-
  1 file changed, 29 insertions(+), 27 deletions(-)

 diff --git a/drivers/net/ethernet/via/via-rhine.c 
 b/drivers/net/ethernet/via/via-rhine.c
 index ef312bc..fee8732 100644
 --- a/drivers/net/ethernet/via/via-rhine.c
 +++ b/drivers/net/ethernet/via/via-rhine.c
 @@ -919,10 +919,10 @@ static int rhine_init_one(struct pci_dev *pdev, const 
 struct pci_device_id *ent)
   goto err_out;

   /* this should always be supported */
 - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
 + rc = dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
   if (rc) {
   dev_err(pdev-dev,
 - 32-bit PCI DMA addresses not supported by the 
 card!?\n);
 + 32-bit DMA addresses not supported by the card!?\n);
   goto err_out;
   }

 @@ -1094,20 +1094,22 @@ static int alloc_ring(struct net_device* dev)
   void *ring;
   dma_addr_t ring_dma;

 - ring = pci_alloc_consistent(rp-pdev,
 + ring = dma_alloc_coherent(rp-pdev-dev,
   RX_RING_SIZE * sizeof(struct rx_desc) +
   TX_RING_SIZE * sizeof(struct tx_desc),
 - ring_dma);
 + ring_dma,
 + GFP_ATOMIC);
 [...]

 Indentation is messed up here (and in several other function calls
 you're changing).  You should align the function arguments so each line
 begins in the column after the opening parenthesis.

Ben, thanks for pointing out. I actually just tried to follow the
style of surrounding code, but happy to adjust if that's the preferred
option. From what I can see, these lines should still fit in below 80
cols even with increased indents...

Should we then also adjust other function calls within the driver with
similar indentation (if any), that are currently not touched by this
patch series?

Thanks,
Alexey
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/