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 <tiwai@suse.de>
Link: https://patch.msgid.link/20251216141154.172218-4-tiwai@suse.de
This commit is contained in:
Takashi Iwai
2025-12-16 15:11:48 +01:00
parent 0ff22680e5
commit 4a91da4afc
2 changed files with 5 additions and 12 deletions

View 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;
}

View 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;
}