spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan()
This code has several issues:
1) It passes IS_ERR() to dev_err_probe() instead of PTR_ERR().
2) It always prints an error message, even when it succeeds.
3) The "if (ret < 0) {" conditions are never true.
4) If requesting "mas->tx" fails then it sets "mas->rx" to NULL but the
intention was to set "mas->tx" to NULL.
Fixes: b59c122484
("spi: spi-geni-qcom: Add support for GPI dma")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-By: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20211110073935.GA5176@kili
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
12f62a857c
commit
6532582c35
1 changed files with 11 additions and 7 deletions
|
@ -491,22 +491,26 @@ static int spi_geni_grab_gpi_chan(struct spi_geni_master *mas)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mas->tx = dma_request_chan(mas->dev, "tx");
|
mas->tx = dma_request_chan(mas->dev, "tx");
|
||||||
ret = dev_err_probe(mas->dev, IS_ERR(mas->tx), "Failed to get tx DMA ch\n");
|
if (IS_ERR(mas->tx)) {
|
||||||
if (ret < 0)
|
ret = dev_err_probe(mas->dev, PTR_ERR(mas->tx),
|
||||||
|
"Failed to get tx DMA ch\n");
|
||||||
goto err_tx;
|
goto err_tx;
|
||||||
|
}
|
||||||
|
|
||||||
mas->rx = dma_request_chan(mas->dev, "rx");
|
mas->rx = dma_request_chan(mas->dev, "rx");
|
||||||
ret = dev_err_probe(mas->dev, IS_ERR(mas->rx), "Failed to get rx DMA ch\n");
|
if (IS_ERR(mas->rx)) {
|
||||||
if (ret < 0)
|
ret = dev_err_probe(mas->dev, PTR_ERR(mas->rx),
|
||||||
|
"Failed to get rx DMA ch\n");
|
||||||
goto err_rx;
|
goto err_rx;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_rx:
|
err_rx:
|
||||||
dma_release_channel(mas->tx);
|
|
||||||
mas->tx = NULL;
|
|
||||||
err_tx:
|
|
||||||
mas->rx = NULL;
|
mas->rx = NULL;
|
||||||
|
dma_release_channel(mas->tx);
|
||||||
|
err_tx:
|
||||||
|
mas->tx = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue