[4/6] ASoC: sunxi: sun4i-spdif: Use dev_err_probe() for probe error handling

Message ID 20260715095525.40668-5-phucduc.bui@gmail.com (mailing list archive)
State New
Headers
Series ASoC: sunxi: Simplify error handling |

Commit Message

Bui Duc Phuc July 15, 2026, 9:55 a.m. UTC
From: bui duc phuc <phucduc.bui@gmail.com>

Use dev_err_probe() for probe error handling to simplify the error paths
and handle -EPROBE_DEFER correctly.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/sunxi/sun4i-spdif.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
  

Comments

Chen-Yu Tsai July 15, 2026, 3:03 p.m. UTC | #1
On Wed, Jul 15, 2026 at 5:56 PM <phucduc.bui@gmail.com> wrote:
>
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> Use dev_err_probe() for probe error handling to simplify the error paths
> and handle -EPROBE_DEFER correctly.
>
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>

Reviewed-by: Chen-Yu Tsai <wens@kernel.org>
  

Patch

diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c
index c2ec19437cd7..d979bb00312f 100644
--- a/sound/soc/sunxi/sun4i-spdif.c
+++ b/sound/soc/sunxi/sun4i-spdif.c
@@ -684,26 +684,23 @@  static int sun4i_spdif_probe(struct platform_device *pdev)
 
 	host->regmap = devm_regmap_init_mmio(&pdev->dev, base,
 						&sun4i_spdif_regmap_config);
-	if (IS_ERR(host->regmap)) {
-		dev_err(&pdev->dev, "failed to initialise regmap.\n");
-		return PTR_ERR(host->regmap);
-	}
+	if (IS_ERR(host->regmap))
+		return dev_err_probe(&pdev->dev, PTR_ERR(host->regmap),
+				     "failed to initialise regmap.\n");
 
 	/* Clocks */
 	host->apb_clk = devm_clk_get(&pdev->dev, "apb");
-	if (IS_ERR(host->apb_clk)) {
-		dev_err(&pdev->dev, "failed to get a apb clock.\n");
-		return PTR_ERR(host->apb_clk);
-	}
+	if (IS_ERR(host->apb_clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(host->apb_clk),
+				     "failed to get a apb clock.\n");
 
 	if (quirks->tx_clk_name)
 		tx_clk_name = quirks->tx_clk_name;
 	host->spdif_clk = devm_clk_get(&pdev->dev, tx_clk_name);
-	if (IS_ERR(host->spdif_clk)) {
-		dev_err(&pdev->dev, "failed to get the \"%s\" clock.\n",
-			tx_clk_name);
-		return PTR_ERR(host->spdif_clk);
-	}
+	if (IS_ERR(host->spdif_clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(host->spdif_clk),
+				     "failed to get the \"%s\" clock.\n",
+				     tx_clk_name);
 
 	host->dma_params_tx.addr = res->start + quirks->reg_dac_txdata;
 	host->dma_params_tx.maxburst = 8;