]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: hda/cs35l41: Clean up runtime PM with guard()
authorTakashi Iwai <tiwai@suse.de>
Tue, 16 Dec 2025 14:11:46 +0000 (15:11 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 23 Dec 2025 09:51:57 +0000 (10:51 +0100)
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 <tiwai@suse.de>
Link: https://patch.msgid.link/20251216141154.172218-2-tiwai@suse.de
sound/hda/codecs/side-codecs/cs35l41_hda.c

index 21e00055c0c44372427e8b8aeb785ef5d4fddd06..b64890006bb70196334679a657ca960bdc8a892b 100644 (file)
@@ -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,