LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] ASoC: rx51: do not fail if could not get jack detection gpio
@ 2015-01-26 20:51 Pali Rohár
  2015-01-27 13:27 ` Peter Ujfalusi
  0 siblings, 1 reply; 6+ messages in thread
From: Pali Rohár @ 2015-01-26 20:51 UTC (permalink / raw)
  To: Peter Ujfalusi, Jarkko Nikula, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai
  Cc: linux-omap, alsa-devel, linux-kernel, Pavel Machek,
	Sebastian Reichel, Ivaylo Dimitrov, Aaro Koskinen,
	Pali Rohár

qemu does not emulate it

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 sound/soc/omap/rx51.c |   45 +++++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c
index 04896d6..a689021 100644
--- a/sound/soc/omap/rx51.c
+++ b/sound/soc/omap/rx51.c
@@ -310,25 +310,27 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
 		return err;
 	}
 
-	/* AV jack detection */
-	err = snd_soc_jack_new(codec, "AV Jack",
-			       SND_JACK_HEADSET | SND_JACK_VIDEOOUT,
-			       &rx51_av_jack);
-	if (err) {
-		dev_err(card->dev, "Failed to add AV Jack\n");
-		return err;
-	}
+	if (!IS_ERR(pdata->jack_detection_gpio)) {
+		/* AV jack detection */
+		err = snd_soc_jack_new(codec, "AV Jack",
+				       SND_JACK_HEADSET | SND_JACK_VIDEOOUT,
+				       &rx51_av_jack);
+		if (err) {
+			dev_err(card->dev, "Failed to add AV Jack\n");
+			return err;
+		}
 
-	/* prepare gpio for snd_soc_jack_add_gpios */
-	rx51_av_jack_gpios[0].gpio = desc_to_gpio(pdata->jack_detection_gpio);
-	devm_gpiod_put(card->dev, pdata->jack_detection_gpio);
+		/* prepare gpio for snd_soc_jack_add_gpios */
+		rx51_av_jack_gpios[0].gpio = desc_to_gpio(pdata->jack_detection_gpio);
+		devm_gpiod_put(card->dev, pdata->jack_detection_gpio);
 
-	err = snd_soc_jack_add_gpios(&rx51_av_jack,
-				     ARRAY_SIZE(rx51_av_jack_gpios),
-				     rx51_av_jack_gpios);
-	if (err) {
-		dev_err(card->dev, "Failed to add GPIOs\n");
-		return err;
+		err = snd_soc_jack_add_gpios(&rx51_av_jack,
+					     ARRAY_SIZE(rx51_av_jack_gpios),
+					     rx51_av_jack_gpios);
+		if (err) {
+			dev_err(card->dev, "Failed to add GPIOs\n");
+			return err;
+		}
 	}
 
 	return err;
@@ -336,8 +338,11 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
 
 static int rx51_card_remove(struct snd_soc_card *card)
 {
-	snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios),
-				rx51_av_jack_gpios);
+	struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card);
+
+	if (!IS_ERR(pdata->jack_detection_gpio))
+		snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios),
+					rx51_av_jack_gpios);
 
 	return 0;
 }
@@ -470,8 +475,8 @@ static int rx51_soc_probe(struct platform_device *pdev)
 	pdata->jack_detection_gpio = devm_gpiod_get(card->dev,
 						    "jack-detection");
 	if (IS_ERR(pdata->jack_detection_gpio)) {
+		/* Do not fail, qemu does not emulate jack detection gpio */
 		dev_err(card->dev, "could not get jack detection gpio\n");
-		return PTR_ERR(pdata->jack_detection_gpio);
 	}
 
 	pdata->eci_sw_gpio = devm_gpiod_get(card->dev, "eci-switch");
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-28 20:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-26 20:51 [PATCH] ASoC: rx51: do not fail if could not get jack detection gpio Pali Rohár
2015-01-27 13:27 ` Peter Ujfalusi
2015-01-27 13:32   ` Pavel Machek
2015-01-27 13:41     ` Peter Ujfalusi
2015-01-27 14:11       ` Pali Rohár
2015-01-28 14:09         ` Pali Rohár

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).