ASoC: use pm_runtime_resume_and_get() when possible
Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>: After a set of SOF-specific changes, this patchset correct problematic uses of pm_runtime_get_sync() in ASoC, or simplifies the flow with no functional changes. Two patches for Intel platforms also add a test on resume success. Additional changes were initially suggested to completely remove the use of pm_runtime_get_sync(). These changes were dropped since they are way too invasive, specifically in cases where the return values were not tested, which would lead to duplicate pm_runtime_put(). The remaining uses of pm_runtime_get_sync() cannot really be blindly modified without context and knowledge of each driver.
This commit is contained in:
commit
1e0ec034db
@ -581,7 +581,7 @@ static int tas2552_component_probe(struct snd_soc_component *component)
|
||||
|
||||
gpiod_set_value(tas2552->enable_gpio, 1);
|
||||
|
||||
ret = pm_runtime_get_sync(component->dev);
|
||||
ret = pm_runtime_resume_and_get(component->dev);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Enabling device failed: %d\n",
|
||||
ret);
|
||||
|
@ -714,12 +714,11 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
|
||||
struct snd_soc_component *component = mbhc->component;
|
||||
int ret;
|
||||
|
||||
ret = pm_runtime_get_sync(component->dev);
|
||||
ret = pm_runtime_resume_and_get(component->dev);
|
||||
if (ret < 0 && ret != -EACCES) {
|
||||
dev_err_ratelimited(component->dev,
|
||||
"pm_runtime_get_sync failed in %s, ret %d\n",
|
||||
"pm_runtime_resume_and_get failed in %s, ret %d\n",
|
||||
__func__, ret);
|
||||
pm_runtime_put_noidle(component->dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1097,12 +1096,11 @@ static void wcd_correct_swch_plug(struct work_struct *work)
|
||||
mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch);
|
||||
component = mbhc->component;
|
||||
|
||||
ret = pm_runtime_get_sync(component->dev);
|
||||
ret = pm_runtime_resume_and_get(component->dev);
|
||||
if (ret < 0 && ret != -EACCES) {
|
||||
dev_err_ratelimited(component->dev,
|
||||
"pm_runtime_get_sync failed in %s, ret %d\n",
|
||||
"pm_runtime_resume_and_get failed in %s, ret %d\n",
|
||||
__func__, ret);
|
||||
pm_runtime_put_noidle(component->dev);
|
||||
return;
|
||||
}
|
||||
micbias_mv = wcd_mbhc_get_micbias(mbhc);
|
||||
|
@ -749,11 +749,9 @@ static int wsa881x_put_pa_gain(struct snd_kcontrol *kc,
|
||||
unsigned int mask = (1 << fls(max)) - 1;
|
||||
int val, ret, min_gain, max_gain;
|
||||
|
||||
ret = pm_runtime_get_sync(comp->dev);
|
||||
if (ret < 0 && ret != -EACCES) {
|
||||
pm_runtime_put_noidle(comp->dev);
|
||||
ret = pm_runtime_resume_and_get(comp->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
}
|
||||
|
||||
max_gain = (max - ucontrol->value.integer.value[0]) & mask;
|
||||
/*
|
||||
|
@ -1141,11 +1141,9 @@ static int fsl_sai_probe(struct platform_device *pdev)
|
||||
goto err_pm_disable;
|
||||
}
|
||||
|
||||
ret = pm_runtime_get_sync(dev);
|
||||
if (ret < 0) {
|
||||
pm_runtime_put_noidle(dev);
|
||||
ret = pm_runtime_resume_and_get(dev);
|
||||
if (ret < 0)
|
||||
goto err_pm_get_sync;
|
||||
}
|
||||
|
||||
/* Get sai version */
|
||||
ret = fsl_sai_check_version(dev);
|
||||
|
@ -346,11 +346,9 @@ static int img_i2s_out_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
|
||||
chan_control_mask = IMG_I2S_OUT_CHAN_CTL_CLKT_MASK;
|
||||
|
||||
ret = pm_runtime_get_sync(i2s->dev);
|
||||
if (ret < 0) {
|
||||
pm_runtime_put_noidle(i2s->dev);
|
||||
ret = pm_runtime_resume_and_get(i2s->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
img_i2s_out_disable(i2s);
|
||||
|
||||
@ -482,11 +480,9 @@ static int img_i2s_out_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
goto err_pm_disable;
|
||||
}
|
||||
ret = pm_runtime_get_sync(&pdev->dev);
|
||||
if (ret < 0) {
|
||||
pm_runtime_put_noidle(&pdev->dev);
|
||||
ret = pm_runtime_resume_and_get(&pdev->dev);
|
||||
if (ret < 0)
|
||||
goto err_suspend;
|
||||
}
|
||||
|
||||
reg = IMG_I2S_OUT_CTL_FRM_SIZE_MASK;
|
||||
img_i2s_out_writel(i2s, reg, IMG_I2S_OUT_CTL);
|
||||
|
@ -667,7 +667,9 @@ static int catpt_dai_pcm_new(struct snd_soc_pcm_runtime *rtm,
|
||||
if (!memcmp(&cdev->devfmt[devfmt.iface], &devfmt, sizeof(devfmt)))
|
||||
return 0;
|
||||
|
||||
pm_runtime_get_sync(cdev->dev);
|
||||
ret = pm_runtime_resume_and_get(cdev->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
|
||||
ret = catpt_ipc_set_device_format(cdev, &devfmt);
|
||||
|
||||
@ -853,9 +855,12 @@ static int catpt_mixer_volume_get(struct snd_kcontrol *kcontrol,
|
||||
snd_soc_kcontrol_component(kcontrol);
|
||||
struct catpt_dev *cdev = dev_get_drvdata(component->dev);
|
||||
u32 dspvol;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
pm_runtime_get_sync(cdev->dev);
|
||||
ret = pm_runtime_resume_and_get(cdev->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < CATPT_CHANNELS_MAX; i++) {
|
||||
dspvol = catpt_mixer_volume(cdev, &cdev->mixer, i);
|
||||
@ -876,7 +881,9 @@ static int catpt_mixer_volume_put(struct snd_kcontrol *kcontrol,
|
||||
struct catpt_dev *cdev = dev_get_drvdata(component->dev);
|
||||
int ret;
|
||||
|
||||
pm_runtime_get_sync(cdev->dev);
|
||||
ret = pm_runtime_resume_and_get(cdev->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
|
||||
ret = catpt_set_dspvol(cdev, cdev->mixer.mixer_hw_id,
|
||||
ucontrol->value.integer.value);
|
||||
@ -897,6 +904,7 @@ static int catpt_stream_volume_get(struct snd_kcontrol *kcontrol,
|
||||
struct catpt_dev *cdev = dev_get_drvdata(component->dev);
|
||||
long *ctlvol = (long *)kcontrol->private_value;
|
||||
u32 dspvol;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
stream = catpt_stream_find(cdev, pin_id);
|
||||
@ -906,7 +914,9 @@ static int catpt_stream_volume_get(struct snd_kcontrol *kcontrol,
|
||||
return 0;
|
||||
}
|
||||
|
||||
pm_runtime_get_sync(cdev->dev);
|
||||
ret = pm_runtime_resume_and_get(cdev->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < CATPT_CHANNELS_MAX; i++) {
|
||||
dspvol = catpt_stream_volume(cdev, stream, i);
|
||||
@ -937,7 +947,9 @@ static int catpt_stream_volume_put(struct snd_kcontrol *kcontrol,
|
||||
return 0;
|
||||
}
|
||||
|
||||
pm_runtime_get_sync(cdev->dev);
|
||||
ret = pm_runtime_resume_and_get(cdev->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
|
||||
ret = catpt_set_dspvol(cdev, stream->info.stream_hw_id,
|
||||
ucontrol->value.integer.value);
|
||||
@ -1013,7 +1025,9 @@ static int catpt_loopback_switch_put(struct snd_kcontrol *kcontrol,
|
||||
return 0;
|
||||
}
|
||||
|
||||
pm_runtime_get_sync(cdev->dev);
|
||||
ret = pm_runtime_resume_and_get(cdev->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
|
||||
ret = catpt_ipc_mute_loopback(cdev, stream->info.stream_hw_id, mute);
|
||||
|
||||
|
@ -15,7 +15,9 @@ static ssize_t fw_version_show(struct device *dev,
|
||||
struct catpt_fw_version version;
|
||||
int ret;
|
||||
|
||||
pm_runtime_get_sync(cdev->dev);
|
||||
ret = pm_runtime_resume_and_get(cdev->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
|
||||
ret = catpt_ipc_get_fw_version(cdev, &version);
|
||||
|
||||
|
@ -1380,7 +1380,10 @@ static int skl_platform_soc_probe(struct snd_soc_component *component)
|
||||
const struct skl_dsp_ops *ops;
|
||||
int ret;
|
||||
|
||||
pm_runtime_get_sync(component->dev);
|
||||
ret = pm_runtime_resume_and_get(component->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
|
||||
if (bus->ppcap) {
|
||||
skl->component = component;
|
||||
|
||||
|
@ -404,11 +404,9 @@ static int rockchip_i2s_tdm_set_fmt(struct snd_soc_dai *cpu_dai,
|
||||
int ret;
|
||||
bool is_tdm = i2s_tdm->tdm_mode;
|
||||
|
||||
ret = pm_runtime_get_sync(cpu_dai->dev);
|
||||
if (ret < 0 && ret != -EACCES) {
|
||||
pm_runtime_put_noidle(cpu_dai->dev);
|
||||
ret = pm_runtime_resume_and_get(cpu_dai->dev);
|
||||
if (ret < 0 && ret != -EACCES)
|
||||
return ret;
|
||||
}
|
||||
|
||||
mask = I2S_CKR_MSS_MASK;
|
||||
switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
|
||||
|
@ -688,11 +688,9 @@ static int rockchip_pdm_resume(struct device *dev)
|
||||
struct rk_pdm_dev *pdm = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
ret = pm_runtime_get_sync(dev);
|
||||
if (ret < 0) {
|
||||
pm_runtime_put(dev);
|
||||
ret = pm_runtime_resume_and_get(dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regcache_sync(pdm->regmap);
|
||||
|
||||
|
@ -2111,8 +2111,7 @@ static int davinci_mcasp_gpio_request(struct gpio_chip *chip, unsigned offset)
|
||||
}
|
||||
|
||||
/* Do not change the PIN yet */
|
||||
|
||||
return pm_runtime_get_sync(mcasp->dev);
|
||||
return pm_runtime_resume_and_get(mcasp->dev);
|
||||
}
|
||||
|
||||
static void davinci_mcasp_gpio_free(struct gpio_chip *chip, unsigned offset)
|
||||
|
Loading…
x
Reference in New Issue
Block a user