Skip to contentSkip to conversation

Palm27x-asoc: fix it to work without jack gpio specified

PATCH Marek Vasut 2 participants 4 messages Jun 1, 2009 – Jun 2, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

the patch follows. The problem was with palmz72 which doesn't have the jack detection.

From 4b569013e47b03199d7efda812cb329736723f0a Mon Sep 17 00:00:00 2001
From: Marek Vasut <[email protected]>
Date: Mon, 1 Jun 2009 17:57:15 +0200
Subject: [PATCH 1/2] Palm27x-aSoC: Make it work without jack GPIO specified

---
 sound/soc/pxa/palm27x.c |   41 +++++++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 20 deletions(-)
sound/soc/pxa/palm27x.c +21 -20
index e6102fd..628e13e 100644
@@ -204,25 +204,22 @@ static int palm27x_asoc_probe(struct platform_device *pdev)
 {
 	int ret;
 
-	if (!(machine_is_palmtx() || machine_is_palmt5() ||
-		machine_is_palmld() || machine_is_palmte2()))
-		return -ENODEV;
-
-	if (pdev->dev.platform_data)
+	if (pdev->dev.platform_data) {
 		palm27x_ep_gpio = ((struct palm27x_asoc_info *)
 			(pdev->dev.platform_data))->jack_gpio;
 
-	ret = gpio_request(palm27x_ep_gpio, "Headphone Jack");
-	if (ret)
-		return ret;
-	ret = gpio_direction_input(palm27x_ep_gpio);
-	if (ret)
-		goto err_alloc;
-
-	if (request_irq(gpio_to_irq(palm27x_ep_gpio), palm27x_interrupt,
-			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-			"Headphone jack", NULL))
-		goto err_alloc;
+		ret = gpio_request(palm27x_ep_gpio, "Headphone Jack");
+		if (ret)
+			return ret;
+		ret = gpio_direction_input(palm27x_ep_gpio);
+		if (ret)
+			goto err_alloc;
+
+		if (request_irq(gpio_to_irq(palm27x_ep_gpio), palm27x_interrupt,
+				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+				"Headphone jack", NULL))
+			goto err_alloc;
+	}
 
 	palm27x_snd_device = platform_device_alloc("soc-audio", -1);
 	if (!palm27x_snd_device) {
@@ -242,17 +239,21 @@ static int palm27x_asoc_probe(struct platform_device *pdev)
 put_device:
 	platform_device_put(palm27x_snd_device);
 err_dev:
-	free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
+	if (pdev->dev.platform_data)
+		free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
 err_alloc:
-	gpio_free(palm27x_ep_gpio);
+	if (pdev->dev.platform_data)
+		gpio_free(palm27x_ep_gpio);
 
 	return ret;
 }
 
 static int __devexit palm27x_asoc_remove(struct platform_device *pdev)
 {
-	free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
-	gpio_free(palm27x_ep_gpio);
+	if (pdev->dev.platform_data) {
+		free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
+		gpio_free(palm27x_ep_gpio);
+	}
 	platform_device_unregister(palm27x_snd_device);
 	return 0;
 }
Signature · 1 line
1.6.2.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#1 lore raw

sound/soc/pxa/palm27x.c static int palm27x_asoc_probe(struct platform_device *pdev) · line 211

Quoted 5 lines · Marek Vasut
sound/soc/pxa/palm27x.c +0 -5
-	if (!(machine_is_palmtx() || machine_is_palmt5() ||
-		machine_is_palmld() || machine_is_palmte2()))
-		return -ENODEV;
-
-	if (pdev->dev.platform_data)

These machine_is_() checks don't get re-added elsehwere (and it looks like you generated the diff against a different verison of the file to the one that's in ALSA git). It'd be better to keep them here and just add the { to the platform_data check.

Otherwise this is fine.

#2 lore raw
Quoted 11 lines · On Tuesday 02 of June 2009 00:58:44 Mark Brown wrote:

sound/soc/pxa/palm27x.c static int palm27x_asoc_probe(struct platform_device *pdev) · line 211

Quoted 5 lines · Marek Vasut
sound/soc/pxa/palm27x.c +0 -5
-	if (!(machine_is_palmtx() || machine_is_palmt5() ||
-		machine_is_palmld() || machine_is_palmte2()))
-		return -ENODEV;
-
-	if (pdev->dev.platform_data)

These machine_is_() checks don't get re-added elsehwere (and it looks like you generated the diff against a different verison of the file to the one that's in ALSA git). It'd be better to keep them here and just add the { to the platform_data check.

But do we need those checks? The driver is registered only on those machines anyway.

Quoted 2 lines

Otherwise this is fine.

#3 lore raw
Quoted 9 lines · Marek Vasut
Quoted 4 lines · On Tuesday 02 of June 2009 00:58:44 Mark Brown wrote:

These machine_is_() checks don't get re-added elsehwere (and it looks like you generated the diff against a different verison of the file to the one that's in ALSA git). It'd be better to keep them here and just add the { to the platform_data check.

But do we need those checks? The driver is registered only on those machines anyway.

Yes, they're not needed since it's a platform driver - that's not obvious when looking at the context diffs (this is one of those cases where explaining what you're doing in the changelog helps!).