Merge series "ASoC: Intel: machine driver updates for 5.9" from Pierre-Louis Bossart...
[sfrench/cifs-2.6.git] / sound / soc / intel / boards / bdw-rt5677.c
index bed4d5f73d9cffe6887ae74aa718dd03e7d3d084..725304779426066f4261b670b99045562427ecc7 100644 (file)
@@ -272,8 +272,8 @@ static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd)
                        RT5677_CLK_SEL_SYS2);
 
        /* Request rt5677 GPIO for headphone amp control */
-       bdw_rt5677->gpio_hp_en = devm_gpiod_get(component->dev, "headphone-enable",
-                                               GPIOD_OUT_LOW);
+       bdw_rt5677->gpio_hp_en = gpiod_get(component->dev, "headphone-enable",
+                                          GPIOD_OUT_LOW);
        if (IS_ERR(bdw_rt5677->gpio_hp_en)) {
                dev_err(component->dev, "Can't find HP_AMP_SHDN_L gpio\n");
                return PTR_ERR(bdw_rt5677->gpio_hp_en);
@@ -307,6 +307,19 @@ static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd)
        return 0;
 }
 
+static void bdw_rt5677_exit(struct snd_soc_pcm_runtime *rtd)
+{
+       struct bdw_rt5677_priv *bdw_rt5677 =
+                       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(bdw_rt5677->gpio_hp_en))
+               gpiod_put(bdw_rt5677->gpio_hp_en);
+}
+
 /* broadwell digital audio interface glue - connects codec <--> CPU */
 SND_SOC_DAILINK_DEF(dummy,
        DAILINK_COMP_ARRAY(COMP_DUMMY()));
@@ -373,6 +386,7 @@ static struct snd_soc_dai_link bdw_rt5677_dais[] = {
                .dpcm_playback = 1,
                .dpcm_capture = 1,
                .init = bdw_rt5677_init,
+               .exit = bdw_rt5677_exit,
 #if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
                SND_SOC_DAILINK_REG(dummy, be, dummy),
 #else
@@ -405,9 +419,19 @@ static int bdw_rt5677_resume_post(struct snd_soc_card *card)
        return 0;
 }
 
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
+/* use space before codec name to simplify card ID, and simplify driver name */
+#define CARD_NAME "bdw rt5677" /* card name will be 'sof-bdw rt5677' */
+#define DRIVER_NAME "SOF"
+#else
+#define CARD_NAME "bdw-rt5677"
+#define DRIVER_NAME NULL /* card name will be used for driver name */
+#endif
+
 /* ASoC machine driver for Broadwell DSP + RT5677 */
 static struct snd_soc_card bdw_rt5677_card = {
-       .name = "bdw-rt5677",
+       .name = CARD_NAME,
+       .driver_name = DRIVER_NAME,
        .owner = THIS_MODULE,
        .dai_link = bdw_rt5677_dais,
        .num_links = ARRAY_SIZE(bdw_rt5677_dais),