Commit df79c015 authored by Dan Carpenter's avatar Dan Carpenter Committed by Ben Hutchings

ethernet: micrel: fix some error codes

commit 3af0d554 upstream.

There were two issues here:
1) dma_mapping_error() return true/false but we want to return -ENOMEM
2) If dmaengine_prep_slave_sg() failed then "err" wasn't set but
   presumably that should be -ENOMEM as well.

I changed the success path to "return 0;" instead of "return ret;" for
clarity.

Fixes: 94fe8c68 ('ks8842: Support DMA when accessed via timberdale')
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent f84eda3a
...@@ -562,8 +562,8 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev) ...@@ -562,8 +562,8 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)
sg_init_table(sg, 1); sg_init_table(sg, 1);
sg_dma_address(sg) = dma_map_single(adapter->dev, sg_dma_address(sg) = dma_map_single(adapter->dev,
ctl->skb->data, DMA_BUFFER_SIZE, DMA_FROM_DEVICE); ctl->skb->data, DMA_BUFFER_SIZE, DMA_FROM_DEVICE);
err = dma_mapping_error(adapter->dev, sg_dma_address(sg)); if (dma_mapping_error(adapter->dev, sg_dma_address(sg))) {
if (unlikely(err)) { err = -ENOMEM;
sg_dma_address(sg) = 0; sg_dma_address(sg) = 0;
goto out; goto out;
} }
...@@ -574,8 +574,10 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev) ...@@ -574,8 +574,10 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)
sg, 1, DMA_FROM_DEVICE, sg, 1, DMA_FROM_DEVICE,
DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_SRC_UNMAP); DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_SRC_UNMAP);
if (!ctl->adesc) if (!ctl->adesc) {
err = -ENOMEM;
goto out; goto out;
}
ctl->adesc->callback_param = netdev; ctl->adesc->callback_param = netdev;
ctl->adesc->callback = ks8842_dma_rx_cb; ctl->adesc->callback = ks8842_dma_rx_cb;
...@@ -586,7 +588,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev) ...@@ -586,7 +588,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)
goto out; goto out;
} }
return err; return 0;
out: out:
if (sg_dma_address(sg)) if (sg_dma_address(sg))
dma_unmap_single(adapter->dev, sg_dma_address(sg), dma_unmap_single(adapter->dev, sg_dma_address(sg),
......
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