From e38bdd30708b8bad577b07de5fdb2baa1cae8527 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 16 Dec 2025 15:11:46 +0100 Subject: [PATCH] ALSA: hda/cs35l41: Clean up runtime PM with guard() Replace the manual pm_runtime_get_sync() and pm_runtime_put_autosuspend() calls with the new guard(pm_runtime_active_auto) for code simplification. Along with this change, the former scoped_guard(mutex) can be set back to the plain guard(mutex), and the indent level is taken back, too. Merely code cleanups, and no functional changes. Signed-off-by: Takashi Iwai Link: https://patch.msgid.link/20251216141154.172218-2-tiwai@suse.de --- sound/hda/codecs/side-codecs/cs35l41_hda.c | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/sound/hda/codecs/side-codecs/cs35l41_hda.c b/sound/hda/codecs/side-codecs/cs35l41_hda.c index 21e00055c0c44..b64890006bb70 100644 --- a/sound/hda/codecs/side-codecs/cs35l41_hda.c +++ b/sound/hda/codecs/side-codecs/cs35l41_hda.c @@ -1255,19 +1255,16 @@ static void cs35l41_fw_load_work(struct work_struct *work) { struct cs35l41_hda *cs35l41 = container_of(work, struct cs35l41_hda, fw_load_work); - pm_runtime_get_sync(cs35l41->dev); - - scoped_guard(mutex, &cs35l41->fw_mutex) { - /* Recheck if playback is ongoing, mutex will block playback during firmware loading */ - if (cs35l41->playback_started) - dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback. Retrying...\n"); - else - cs35l41_load_firmware(cs35l41, cs35l41->request_fw_load); + guard(pm_runtime_active_auto)(cs35l41->dev); - cs35l41->fw_request_ongoing = false; - } + guard(mutex)(&cs35l41->fw_mutex); + /* Recheck if playback is ongoing, mutex will block playback during firmware loading */ + if (cs35l41->playback_started) + dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback. Retrying...\n"); + else + cs35l41_load_firmware(cs35l41, cs35l41->request_fw_load); - pm_runtime_put_autosuspend(cs35l41->dev); + cs35l41->fw_request_ongoing = false; } static int cs35l41_fw_load_ctl_put(struct snd_kcontrol *kcontrol, @@ -1455,7 +1452,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas if (comp->dev) return -EBUSY; - pm_runtime_get_sync(dev); + guard(pm_runtime_active_auto)(dev); mutex_lock(&cs35l41->fw_mutex); @@ -1499,8 +1496,6 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas dev_warn(dev, "Unable to create device link\n"); unlock_system_sleep(sleep_flags); - pm_runtime_put_autosuspend(dev); - dev_info(cs35l41->dev, "CS35L41 Bound - SSID: %s, BST: %d, VSPK: %d, CH: %c, FW EN: %d, SPKID: %d\n", cs35l41->acpi_subsystem_id, cs35l41->hw_cfg.bst_type, -- 2.47.3