From 4a91da4afc7db944d17234e4ecc164df8252b23b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 16 Dec 2025 15:11:48 +0100 Subject: [PATCH] ALSA: hda/tas2781: Clean up runtime PM with guard() 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 Link: https://patch.msgid.link/20251216141154.172218-4-tiwai@suse.de --- sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 10 +++------- sound/hda/codecs/side-codecs/tas2781_hda_spi.c | 7 ++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c index c8619995b1d78..c74f83d4ec7f4 100644 --- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c +++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c @@ -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; } diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_spi.c b/sound/hda/codecs/side-codecs/tas2781_hda_spi.c index b9a55672bf15d..f8412c5df9195 100644 --- a/sound/hda/codecs/side-codecs/tas2781_hda_spi.c +++ b/sound/hda/codecs/side-codecs/tas2781_hda_spi.c @@ -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; } -- 2.47.3