]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ASoC: uniphier: Handle regmap_write errors in aio_src_set_param()
authorIngyu Jang <ingyujang25@unist.ac.kr>
Thu, 26 Sep 2024 10:40:04 +0000 (19:40 +0900)
committerMark Brown <broonie@kernel.org>
Sat, 5 Oct 2024 01:53:57 +0000 (02:53 +0100)
The aio_src_set_param() function did not previously check the return
values of regmap_write() and regmap_update_bits().
If these functions fail, it could lead to silent failures when
configuring the sample rate converter (SRC), causing improper behavior
in audio processing without any indication of an error.

This patch modifies aio_src_set_param to check the return values of
regmap_write() and regmap_update_bits().
If either function returns an error, the error code is propagated back
to the caller to ensure proper error handling.
This change aligns with the existing error-handling behavior in
functions like uniphier_aio_prepare(), where a failure in a sub-function
should result in an immediate return of the error.

Signed-off-by: Ingyu Jang <ingyujang25@unist.ac.kr>
Link: https://patch.msgid.link/SE1P216MB2287F4D575CFBDC9755E896BFD6A2@SE1P216MB2287.KORP216.PROD.OUTLOOK.COM
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/uniphier/aio-core.c

index 0eba607581341e86b54bd74e58dfdb289f7a70cf..2c4e8b87325335cd4ced1046a7143877228bd142 100644 (file)
@@ -921,16 +921,19 @@ int aio_src_set_param(struct uniphier_aio_sub *sub,
 {
        struct regmap *r = sub->aio->chip->regmap;
        u32 v;
+       int ret;
 
        if (sub->swm->dir != PORT_DIR_OUTPUT)
                return 0;
 
-       regmap_write(r, OPORTMXSRC1CTR(sub->swm->oport.map),
+       ret = regmap_write(r, OPORTMXSRC1CTR(sub->swm->oport.map),
                     OPORTMXSRC1CTR_THMODE_SRC |
                     OPORTMXSRC1CTR_SRCPATH_CALC |
                     OPORTMXSRC1CTR_SYNC_ASYNC |
                     OPORTMXSRC1CTR_FSIIPSEL_INNER |
                     OPORTMXSRC1CTR_FSISEL_ACLK);
+       if (ret)
+               return ret;
 
        switch (params_rate(params)) {
        default:
@@ -951,12 +954,18 @@ int aio_src_set_param(struct uniphier_aio_sub *sub,
                break;
        }
 
-       regmap_write(r, OPORTMXRATE_I(sub->swm->oport.map),
+
+       ret = regmap_write(r, OPORTMXRATE_I(sub->swm->oport.map),
                     v | OPORTMXRATE_I_ACLKSRC_APLL |
                     OPORTMXRATE_I_LRCKSTP_STOP);
-       regmap_update_bits(r, OPORTMXRATE_I(sub->swm->oport.map),
+       if (ret)
+               return ret;
+
+       ret = regmap_update_bits(r, OPORTMXRATE_I(sub->swm->oport.map),
                           OPORTMXRATE_I_LRCKSTP_MASK,
                           OPORTMXRATE_I_LRCKSTP_START);
+       if (ret)
+               return ret;
 
        return 0;
 }