Skip to content

Commit 71d322f

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: codecs: nau8825: Simplify mclk initialization
Most of clk_xxx() functions do check if provided clk-pointer is non-NULL. These do not check if the pointer is an error-pointer. Providing such to a clk_xxx() results in a panic. By utilizing _optional() variant of devm_clk_get() the driver code is both simplified and more robust. There is no need to remember about IS_ERR(clk) checks each time mclk is accessed. Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://msgid.link/r/20240221152516.852353-3-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e2cb72d commit 71d322f

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

sound/soc/codecs/nau8825.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,16 +2836,12 @@ static int nau8825_read_device_properties(struct device *dev,
28362836
if (nau8825->adc_delay < 125 || nau8825->adc_delay > 500)
28372837
dev_warn(dev, "Please set the suitable delay time!\n");
28382838

2839-
nau8825->mclk = devm_clk_get(dev, "mclk");
2840-
if (PTR_ERR(nau8825->mclk) == -EPROBE_DEFER) {
2841-
return -EPROBE_DEFER;
2842-
} else if (PTR_ERR(nau8825->mclk) == -ENOENT) {
2839+
nau8825->mclk = devm_clk_get_optional(dev, "mclk");
2840+
if (IS_ERR(nau8825->mclk))
2841+
return PTR_ERR(nau8825->mclk);
2842+
if (!nau8825->mclk)
28432843
/* The MCLK is managed externally or not used at all */
2844-
nau8825->mclk = NULL;
28452844
dev_info(dev, "No 'mclk' clock found, assume MCLK is managed externally");
2846-
} else if (IS_ERR(nau8825->mclk)) {
2847-
return -EINVAL;
2848-
}
28492845

28502846
return 0;
28512847
}

0 commit comments

Comments
 (0)