Message ID | 20220714132342.13051-1-kda@linux-powerpc.org (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: altera: Handle dma_set_coherent_mask error codes | expand |
On Thu, 14 Jul 2022 16:23:42 +0300 Denis Kirjanov wrote: > handle the error in the case that DMA mask is not supportyed > > Fixes: bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver") > Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org> > --- > drivers/net/ethernet/altera/altera_tse_main.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c > index 8c5828582c21..7773d978321a 100644 > --- a/drivers/net/ethernet/altera/altera_tse_main.c > +++ b/drivers/net/ethernet/altera/altera_tse_main.c > @@ -1439,10 +1439,14 @@ static int altera_tse_probe(struct platform_device *pdev) > } > > if (!dma_set_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask))) { > - dma_set_coherent_mask(priv->device, > + ret = dma_set_coherent_mask(priv->device, > DMA_BIT_MASK(priv->dmaops->dmamask)); > + if (ret) > + goto err_free_netdev; > } else if (!dma_set_mask(priv->device, DMA_BIT_MASK(32))) { > - dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32)); > + ret = dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32)); > + if (ret) > + goto err_free_netdev; > } else { > ret = -EIO; > goto err_free_netdev; Practically speaking this can't fail, see Christophe's patches like b6f2f0352c0302 If you want to be on the safe side just replace the dma_set_mask() with dma_set_mask_and_coherent() and let the else branch handle the failure. Please CC maintainers when reposting.
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c index 8c5828582c21..7773d978321a 100644 --- a/drivers/net/ethernet/altera/altera_tse_main.c +++ b/drivers/net/ethernet/altera/altera_tse_main.c @@ -1439,10 +1439,14 @@ static int altera_tse_probe(struct platform_device *pdev) } if (!dma_set_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask))) { - dma_set_coherent_mask(priv->device, + ret = dma_set_coherent_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask)); + if (ret) + goto err_free_netdev; } else if (!dma_set_mask(priv->device, DMA_BIT_MASK(32))) { - dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32)); + ret = dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32)); + if (ret) + goto err_free_netdev; } else { ret = -EIO; goto err_free_netdev;
handle the error in the case that DMA mask is not supportyed Fixes: bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver") Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org> --- drivers/net/ethernet/altera/altera_tse_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)