]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: jz4725b: Convert to devm_clk_get_enabled()
authorJihed Chaibi <jihed.chaibi.dev@gmail.com>
Mon, 23 Mar 2026 16:15:49 +0000 (17:15 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 30 Mar 2026 18:40:27 +0000 (19:40 +0100)
The clock is obtained with devm_clk_get() in the platform probe, then
manually enabled in the component probe and disabled in the component
remove without checking the return value of clk_prepare_enable().

Use devm_clk_get_enabled() instead, which combines the get, prepare and
enable operations into one call whose lifetime is tied to the device.
This removes the need for explicit enable/disable in the component
probe/remove callbacks, and ensures that clock enable failures are
propagated as errors rather than silently ignored.

Remove the now-unused struct clk pointer from struct jz_icdc and drop
the empty component remove callback.

Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com>
Link: https://patch.msgid.link/20260323161551.47181-2-jihed.chaibi.dev@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/jz4725b.c

index 39cebaa167bebb9f307842beed7216279d18ece3..8a7d26a08c03bc5c074a38c31d22f905f3aaefaa 100644 (file)
@@ -160,7 +160,6 @@ enum {
 struct jz_icdc {
        struct regmap *regmap;
        void __iomem *base;
-       struct clk *clk;
 };
 
 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(jz4725b_adc_tlv,     0, 150, 0);
@@ -405,8 +404,6 @@ static int jz4725b_codec_dev_probe(struct snd_soc_component *component)
        struct jz_icdc *icdc = snd_soc_component_get_drvdata(component);
        struct regmap *map = icdc->regmap;
 
-       clk_prepare_enable(icdc->clk);
-
        /* Write CONFIGn (n=1 to 8) bits.
         * The value 0x0f is specified in the datasheet as a requirement.
         */
@@ -418,16 +415,8 @@ static int jz4725b_codec_dev_probe(struct snd_soc_component *component)
        return 0;
 }
 
-static void jz4725b_codec_dev_remove(struct snd_soc_component *component)
-{
-       struct jz_icdc *icdc = snd_soc_component_get_drvdata(component);
-
-       clk_disable_unprepare(icdc->clk);
-}
-
 static const struct snd_soc_component_driver jz4725b_codec = {
        .probe                  = jz4725b_codec_dev_probe,
-       .remove                 = jz4725b_codec_dev_remove,
        .set_bias_level         = jz4725b_codec_set_bias_level,
        .controls               = jz4725b_codec_controls,
        .num_controls           = ARRAY_SIZE(jz4725b_codec_controls),
@@ -618,6 +607,7 @@ static int jz4725b_codec_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct jz_icdc *icdc;
+       struct clk *clk;
        int ret;
 
        icdc = devm_kzalloc(dev, sizeof(*icdc), GFP_KERNEL);
@@ -633,9 +623,9 @@ static int jz4725b_codec_probe(struct platform_device *pdev)
        if (IS_ERR(icdc->regmap))
                return PTR_ERR(icdc->regmap);
 
-       icdc->clk = devm_clk_get(&pdev->dev, "aic");
-       if (IS_ERR(icdc->clk))
-               return PTR_ERR(icdc->clk);
+       clk = devm_clk_get_enabled(dev, "aic");
+       if (IS_ERR(clk))
+               return PTR_ERR(clk);
 
        platform_set_drvdata(pdev, icdc);