Unverified Commit 1e0ec034 authored by Mark Brown's avatar Mark Brown
Browse files

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.
parents bd10b0da cecc81d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+4 −6
Original line number Diff line number Diff line
@@ -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);
+2 −4
Original line number Diff line number Diff line
@@ -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;
	/*
+2 −4
Original line number Diff line number Diff line
@@ -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);
+4 −8
Original line number Diff line number Diff line
@@ -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);
Loading