public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] enic: Use dma_set_mask_and_coherent()
@ 2022-01-01 14:02 Christophe JAILLET
  2022-01-02 12:30 ` patchwork-bot+netdevbpf
  2022-01-03  8:47 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-01-01 14:02 UTC (permalink / raw)
  To: benve, govind, davem, kuba
  Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET

Use dma_set_mask_and_coherent() instead of unrolling it with some
dma_set_mask()+dma_set_coherent_mask().

This simplifies code and removes some dead code (dma_set_coherent_mask()
can not fail after a successful dma_set_mask())

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo•fr>
---
 drivers/net/ethernet/cisco/enic/enic_main.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 2faba079b4fb..1c81b161de52 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2718,26 +2718,14 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * fail to 32-bit.
 	 */
 
-	err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(47));
+	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(47));
 	if (err) {
-		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 		if (err) {
 			dev_err(dev, "No usable DMA configuration, aborting\n");
 			goto err_out_release_regions;
 		}
-		err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-		if (err) {
-			dev_err(dev, "Unable to obtain %u-bit DMA "
-				"for consistent allocations, aborting\n", 32);
-			goto err_out_release_regions;
-		}
 	} else {
-		err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(47));
-		if (err) {
-			dev_err(dev, "Unable to obtain %u-bit DMA "
-				"for consistent allocations, aborting\n", 47);
-			goto err_out_release_regions;
-		}
 		using_dac = 1;
 	}
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-05 19:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-01 14:02 [PATCH] enic: Use dma_set_mask_and_coherent() Christophe JAILLET
2022-01-02 12:30 ` patchwork-bot+netdevbpf
2022-01-03  8:47 ` Christoph Hellwig
2022-01-05 19:51   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox