Skip to content

Commit e2fc058

Browse files
Dragan Simicbroonie
authored andcommitted
spi: rockchip: Use dev_{err,warn}_probe() in the probe path
Use function dev_err_probe() in the probe path instead of dev_err() where appropriate, to make the code a bit more uniform and compact. Use the new function dev_warn_probe() to improve error handling for the TX and RX DMA channel requests, which are actually optional, and tweak the logged warnings a bit to additionally describe their optional nature. Previously, deferred requests for the TX and RX DMA channels produced no debug messages, and the final error messages didn't include the error codes, which are all highly useful when debugging permanently failed DMA channel requests, such as when the required drivers aren't enabled. Suggested-by: Hélene Vulquin <[email protected]> Signed-off-by: Dragan Simic <[email protected]> Tested-by: Hélène Vulquin <[email protected]> Link: https://patch.msgid.link/5b6bd142dab3ab93d7039db3e2fdcfea6bee2217.1727601608.git.dsimic@manjaro.org Signed-off-by: Mark Brown <[email protected]>
1 parent 36e69b1 commit e2fc058

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

drivers/spi/spi-rockchip.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -773,15 +773,15 @@ static int rockchip_spi_probe(struct platform_device *pdev)
773773

774774
rs->apb_pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk");
775775
if (IS_ERR(rs->apb_pclk)) {
776-
dev_err(&pdev->dev, "Failed to get apb_pclk\n");
777-
ret = PTR_ERR(rs->apb_pclk);
776+
ret = dev_err_probe(&pdev->dev, PTR_ERR(rs->apb_pclk),
777+
"Failed to get apb_pclk\n");
778778
goto err_put_ctlr;
779779
}
780780

781781
rs->spiclk = devm_clk_get_enabled(&pdev->dev, "spiclk");
782782
if (IS_ERR(rs->spiclk)) {
783-
dev_err(&pdev->dev, "Failed to get spi_pclk\n");
784-
ret = PTR_ERR(rs->spiclk);
783+
ret = dev_err_probe(&pdev->dev, PTR_ERR(rs->spiclk),
784+
"Failed to get spi_pclk\n");
785785
goto err_put_ctlr;
786786
}
787787

@@ -817,8 +817,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
817817

818818
rs->fifo_len = get_fifo_len(rs);
819819
if (!rs->fifo_len) {
820-
dev_err(&pdev->dev, "Failed to get fifo length\n");
821-
ret = -EINVAL;
820+
ret = dev_err_probe(&pdev->dev, -EINVAL, "Failed to get fifo length\n");
822821
goto err_put_ctlr;
823822
}
824823

@@ -858,22 +857,21 @@ static int rockchip_spi_probe(struct platform_device *pdev)
858857

859858
ctlr->dma_tx = dma_request_chan(rs->dev, "tx");
860859
if (IS_ERR(ctlr->dma_tx)) {
861-
/* Check tx to see if we need defer probing driver */
862-
if (PTR_ERR(ctlr->dma_tx) == -EPROBE_DEFER) {
863-
ret = -EPROBE_DEFER;
860+
/* Check tx to see if we need to defer driver probing */
861+
ret = dev_warn_probe(rs->dev, PTR_ERR(ctlr->dma_tx),
862+
"Failed to request optional TX DMA channel\n");
863+
if (ret == -EPROBE_DEFER)
864864
goto err_disable_pm_runtime;
865-
}
866-
dev_warn(rs->dev, "Failed to request TX DMA channel\n");
867865
ctlr->dma_tx = NULL;
868866
}
869867

870868
ctlr->dma_rx = dma_request_chan(rs->dev, "rx");
871869
if (IS_ERR(ctlr->dma_rx)) {
872-
if (PTR_ERR(ctlr->dma_rx) == -EPROBE_DEFER) {
873-
ret = -EPROBE_DEFER;
870+
/* Check rx to see if we need to defer driver probing */
871+
ret = dev_warn_probe(rs->dev, PTR_ERR(ctlr->dma_rx),
872+
"Failed to request optional RX DMA channel\n");
873+
if (ret == -EPROBE_DEFER)
874874
goto err_free_dma_tx;
875-
}
876-
dev_warn(rs->dev, "Failed to request RX DMA channel\n");
877875
ctlr->dma_rx = NULL;
878876
}
879877

0 commit comments

Comments
 (0)