Unverified Commit e56054e7 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown
Browse files

ASoC: Intel: kbl-rt5660: use .exit() dailink callback to release gpiod



The gpiod handling is inspired from the bdw-rt5677 code. Apply same
fix to avoid reference count issue while removing modules for
consistency.

Suggested-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: default avatarCurtis Malainey <curtis@malainey.com>
Link: https://lore.kernel.org/r/20200622154241.29053-4-pierre-louis.bossart@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bcb43fda
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ static int kabylake_rt5660_codec_init(struct snd_soc_pcm_runtime *rtd)
		dev_warn(component->dev, "Failed to add driver gpios\n");

	/* Request rt5660 GPIO for lineout mute control, return if fails */
	ctx->gpio_lo_mute = devm_gpiod_get(component->dev, "lineout-mute",
	ctx->gpio_lo_mute = gpiod_get(component->dev, "lineout-mute",
				      GPIOD_OUT_HIGH);
	if (IS_ERR(ctx->gpio_lo_mute)) {
		dev_err(component->dev, "Can't find GPIO_MUTE# gpio\n");
@@ -207,6 +207,18 @@ static int kabylake_rt5660_codec_init(struct snd_soc_pcm_runtime *rtd)
	return 0;
}

static void kabylake_rt5660_codec_exit(struct snd_soc_pcm_runtime *rtd)
{
	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);

	/*
	 * The .exit() can be reached without going through the .init()
	 * so explicitly test if the gpiod is valid
	 */
	if (!IS_ERR_OR_NULL(ctx->gpio_lo_mute))
		gpiod_put(ctx->gpio_lo_mute);
}

static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device)
{
	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
@@ -421,6 +433,7 @@ static struct snd_soc_dai_link kabylake_rt5660_dais[] = {
		.id = 0,
		.no_pcm = 1,
		.init = kabylake_rt5660_codec_init,
		.exit = kabylake_rt5660_codec_exit,
		.dai_fmt = SND_SOC_DAIFMT_I2S |
		SND_SOC_DAIFMT_NB_NF |
		SND_SOC_DAIFMT_CBS_CFS,