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 <tiwai@suse.de>
Link: https://patch.msgid.link/20251216141154.172218-2-tiwai@suse.de
This commit is contained in:
Takashi Iwai
2025-12-16 15:11:46 +01:00
parent 5de5db3535
commit e38bdd3070

View 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);
guard(pm_runtime_active_auto)(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(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);
cs35l41->fw_request_ongoing = false;
}
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,