]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: hda/tas2781: Clean up runtime PM with guard()
authorTakashi Iwai <tiwai@suse.de>
Tue, 16 Dec 2025 14:11:48 +0000 (15:11 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 23 Dec 2025 09:51:58 +0000 (10:51 +0100)
Use guard(pm_runtime_active_auto) for replacing the manual calls of
pm_runtime_get_sync() and pm_runtime_put_autosuspend().

Along with this, we can use guard() for the tas_priv->codec_lock mutex
in tasdev_fw_ready(), too (that aligns both i2c and spi codes).

Merely code cleanups and no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20251216141154.172218-4-tiwai@suse.de
sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
sound/hda/codecs/side-codecs/tas2781_hda_spi.c

index c8619995b1d78caf80c853aae8954a4a1b7ca087..c74f83d4ec7f4caa826e966ec0dfd6759575a974 100644 (file)
@@ -500,8 +500,8 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
        struct hda_codec *codec = tas_priv->codec;
        int ret;
 
-       pm_runtime_get_sync(tas_priv->dev);
-       mutex_lock(&tas_priv->codec_lock);
+       guard(pm_runtime_active_auto)(tas_priv->dev);
+       guard(mutex)(&tas_priv->codec_lock);
 
        ret = tasdevice_rca_parser(tas_priv, fmw);
        if (ret)
@@ -537,9 +537,7 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
        }
 
 out:
-       mutex_unlock(&tas_hda->priv->codec_lock);
        release_firmware(fmw);
-       pm_runtime_put_autosuspend(tas_hda->dev);
 }
 
 static int tas2781_hda_bind(struct device *dev, struct device *master,
@@ -571,7 +569,7 @@ static int tas2781_hda_bind(struct device *dev, struct device *master,
                break;
        }
 
-       pm_runtime_get_sync(dev);
+       guard(pm_runtime_active_auto)(dev);
 
        comp->dev = dev;
 
@@ -581,8 +579,6 @@ static int tas2781_hda_bind(struct device *dev, struct device *master,
        if (!ret)
                comp->playback_hook = tas2781_hda_playback_hook;
 
-       pm_runtime_put_autosuspend(dev);
-
        return ret;
 }
 
index b9a55672bf15d53d144b476f3755919592761312..f8412c5df919557cbc4175624ab5802648a94896 100644 (file)
@@ -636,7 +636,7 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
        struct hda_codec *codec = tas_priv->codec;
        int ret, val;
 
-       pm_runtime_get_sync(tas_priv->dev);
+       guard(pm_runtime_active_auto)(tas_priv->dev);
        guard(mutex)(&tas_priv->codec_lock);
 
        ret = tasdevice_rca_parser(tas_priv, fmw);
@@ -699,7 +699,6 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
        tas2781_save_calibration(tas_hda);
 out:
        release_firmware(fmw);
-       pm_runtime_put_autosuspend(tas_hda->priv->dev);
 }
 
 static int tas2781_hda_bind(struct device *dev, struct device *master,
@@ -720,7 +719,7 @@ static int tas2781_hda_bind(struct device *dev, struct device *master,
 
        codec = parent->codec;
 
-       pm_runtime_get_sync(dev);
+       guard(pm_runtime_active_auto)(dev);
 
        comp->dev = dev;
 
@@ -731,8 +730,6 @@ static int tas2781_hda_bind(struct device *dev, struct device *master,
        if (!ret)
                comp->playback_hook = tas2781_hda_playback_hook;
 
-       pm_runtime_put_autosuspend(dev);
-
        return ret;
 }