ASoC: wm97xx: fix uninitialized regmap pointer problem
[linux-2.6-block.git] / sound / soc / codecs / wm9712.c
index e873baa9e7780fdc6286b40d703615319ce7284a..01949eaba4fd49f4f6980e3092e1abb233165734 100644 (file)
@@ -642,8 +642,7 @@ static int wm9712_soc_probe(struct snd_soc_component *component)
        if (wm9712->mfd_pdata) {
                wm9712->ac97 = wm9712->mfd_pdata->ac97;
                regmap = wm9712->mfd_pdata->regmap;
-       } else {
-#ifdef CONFIG_SND_SOC_AC97_BUS
+       } else if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS)) {
                int ret;
 
                wm9712->ac97 = snd_soc_new_ac97_component(component, WM9712_VENDOR_ID,
@@ -660,7 +659,8 @@ static int wm9712_soc_probe(struct snd_soc_component *component)
                        snd_soc_free_ac97_component(wm9712->ac97);
                        return PTR_ERR(regmap);
                }
-#endif
+       } else {
+               return -ENXIO;
        }
 
        snd_soc_component_init_regmap(component, regmap);
@@ -673,14 +673,12 @@ static int wm9712_soc_probe(struct snd_soc_component *component)
 
 static void wm9712_soc_remove(struct snd_soc_component *component)
 {
-#ifdef CONFIG_SND_SOC_AC97_BUS
        struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
 
-       if (!wm9712->mfd_pdata) {
+       if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS) && !wm9712->mfd_pdata) {
                snd_soc_component_exit_regmap(component);
                snd_soc_free_ac97_component(wm9712->ac97);
        }
-#endif
 }
 
 static const struct snd_soc_component_driver soc_component_dev_wm9712 = {