From: bui duc phuc <redacted>
The current code uses devm_clk_get() and sets the clock pointer
to NULL when it returns an error. However, this silently ignores
errors such as -EPROBE_DEFER, allowing the driver to continue
probing without the requested clock.
Use devm_clk_get_optional() to handle missing optional clocks
automatically, and dev_err_probe() to properly propagate other
errors, including -EPROBE_DEFER.
Signed-off-by: bui duc phuc <redacted>
---
sound/soc/fsl/fsl_sai.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 042885ba415e..44a34f48a0cf 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -1589,12 +1589,10 @@ static int fsl_sai_probe(struct platform_device *pdev)
for (i = 1; i < FSL_SAI_MCLK_MAX; i++) {
sprintf(tmp, "mclk%d", i);
- sai->mclk_clk[i] = devm_clk_get(dev, tmp);
- if (IS_ERR(sai->mclk_clk[i])) {
- dev_err(dev, "failed to get mclk%d clock: %ld\n",
- i, PTR_ERR(sai->mclk_clk[i]));
- sai->mclk_clk[i] = NULL;
- }
+ sai->mclk_clk[i] = devm_clk_get_optional(dev, tmp);
+ if (IS_ERR(sai->mclk_clk[i]))
+ return dev_err_probe(dev, PTR_ERR(sai->mclk_clk[i]),
+ "failed to get mclk%d clock\n", i);
}
if (sai->soc_data->mclk0_is_mclk1)--
2.43.0