Skip to content

Commit

Permalink
ethernet: micrel: fix some error codes
Browse files Browse the repository at this point in the history
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: 94fe8c6 ('ks8842: Support DMA when accessed via timberdale')
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Dan Carpenter authored and davem330 committed Mar 18, 2016
1 parent 3004932 commit 3af0d55
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/net/ethernet/micrel/ks8842.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)
sg_init_table(sg, 1);
sg_dma_address(sg) = dma_map_single(adapter->dev,
ctl->skb->data, DMA_BUFFER_SIZE, DMA_FROM_DEVICE);
err = dma_mapping_error(adapter->dev, sg_dma_address(sg));
if (unlikely(err)) {
if (dma_mapping_error(adapter->dev, sg_dma_address(sg))) {
err = -ENOMEM;
sg_dma_address(sg) = 0;
goto out;
}
Expand All @@ -572,8 +572,10 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)
ctl->adesc = dmaengine_prep_slave_sg(ctl->chan,
sg, 1, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT);

if (!ctl->adesc)
if (!ctl->adesc) {
err = -ENOMEM;
goto out;
}

ctl->adesc->callback_param = netdev;
ctl->adesc->callback = ks8842_dma_rx_cb;
Expand All @@ -584,7 +586,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev)
goto out;
}

return err;
return 0;
out:
if (sg_dma_address(sg))
dma_unmap_single(adapter->dev, sg_dma_address(sg),
Expand Down

0 comments on commit 3af0d55

Please sign in to comment.