Skip to content

Commit 6532582

Browse files
Dan Carpenterbroonie
authored andcommitted
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: b59c122 ("spi: spi-geni-qcom: Add support for GPI dma") Signed-off-by: Dan Carpenter <[email protected]> Acked-By: Vinod Koul <[email protected]> Link: https://lore.kernel.org/r/20211110073935.GA5176@kili Signed-off-by: Mark Brown <[email protected]>
1 parent 12f62a8 commit 6532582

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/spi/spi-geni-qcom.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,22 +491,26 @@ static int spi_geni_grab_gpi_chan(struct spi_geni_master *mas)
491491
int ret;
492492

493493
mas->tx = dma_request_chan(mas->dev, "tx");
494-
ret = dev_err_probe(mas->dev, IS_ERR(mas->tx), "Failed to get tx DMA ch\n");
495-
if (ret < 0)
494+
if (IS_ERR(mas->tx)) {
495+
ret = dev_err_probe(mas->dev, PTR_ERR(mas->tx),
496+
"Failed to get tx DMA ch\n");
496497
goto err_tx;
498+
}
497499

498500
mas->rx = dma_request_chan(mas->dev, "rx");
499-
ret = dev_err_probe(mas->dev, IS_ERR(mas->rx), "Failed to get rx DMA ch\n");
500-
if (ret < 0)
501+
if (IS_ERR(mas->rx)) {
502+
ret = dev_err_probe(mas->dev, PTR_ERR(mas->rx),
503+
"Failed to get rx DMA ch\n");
501504
goto err_rx;
505+
}
502506

503507
return 0;
504508

505509
err_rx:
510+
mas->rx = NULL;
506511
dma_release_channel(mas->tx);
507-
mas->tx = NULL;
508512
err_tx:
509-
mas->rx = NULL;
513+
mas->tx = NULL;
510514
return ret;
511515
}
512516

0 commit comments

Comments
 (0)