Skip to contentSkip to conversation

ASoC: twl6040: Updates for 3.9

PATCH Applied Peter Ujfalusi 2 participants 7 messages Jan 11, 2013

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

v2 cover ASoC: twl6040: Updates for 3.9

Hi Mark, Liam,

Changes since v1:
- patch 2 for twl6040_resume() has been replaced with a simpler one

Cover letter from v1:

Small fixe from Misael for twl6040 codec driver and devm_* conversion, switch to system workqueue and dead code removal.

Regards,
Peter
---
Misael Lopez Cruz (1):
ASoC: twl6040: Convert PLUGINT to no-suspend irq

Peter Ujfalusi (4):
ASoC: twl6040: Only set the bias_level once in twl6040_resume()
ASoC: twl6040: Convert to use devm_* when possible
ASoC: twl6040: Switch to use system workqueue for jack reporting
ASoC: twl6040: Remove leftover code from hs/hf ramp implementation

 sound/soc/codecs/twl6040.c | 62 +++++++---------------------------------------
 1 file changed, 9 insertions(+), 53 deletions(-)
Signature · 1 line
1.8.1
#1 lore raw

PATCH v2 1/5 ASoC: twl6040: Convert PLUGINT to no-suspend irq

From: Misael Lopez Cruz <[email protected]>

Convert headset PLUGINT interrupt to NO_SUSPEND type in order to allow handling of insertion/removal events while device is suspended.

---
 sound/soc/codecs/twl6040.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/twl6040.c +1 -1
index 3fc3fc6..ef31ace 100644
@@ -1174,7 +1174,7 @@ static int twl6040_probe(struct snd_soc_codec *codec)
 	mutex_init(&priv->mutex);
 
 	ret = request_threaded_irq(priv->plug_irq, NULL, twl6040_audio_handler,
-				   0, "twl6040_irq_plug", codec);
+				   IRQF_NO_SUSPEND, "twl6040_irq_plug", codec);
 	if (ret) {
 		dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret);
 		goto plugirq_err;
Signature · 1 line
1.8.1
#2 lore raw

PATCH v2 2/5 ASoC: twl6040: Only set the bias_level once in twl6040_resume()

In reply to Peter Ujfalusi

No need to set the bias_level twice to _STANDBY - since this is the only state the device could be at suspend time. The driver do not support idle_bias_off yet.

---
 sound/soc/codecs/twl6040.c | 1 -
 1 file changed, 1 deletion(-)
sound/soc/codecs/twl6040.c +0 -1
index ef31ace..86f12a4 100644
@@ -1115,7 +1115,6 @@ static int twl6040_suspend(struct snd_soc_codec *codec)
 static int twl6040_resume(struct snd_soc_codec *codec)
 {
 	twl6040_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-	twl6040_set_bias_level(codec, codec->dapm.suspend_bias_level);
 
 	return 0;
 }
Signature · 1 line
1.8.1
#3 lore raw

PATCH v2 3/5 ASoC: twl6040: Convert to use devm_* when possible

In reply to Peter Ujfalusi

In this way we can clean up the probe and remove paths

---
 sound/soc/codecs/twl6040.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
sound/soc/codecs/twl6040.c +10 -17
index 86f12a4..90b721e 100644
@@ -1131,9 +1131,10 @@ static int twl6040_probe(struct snd_soc_codec *codec)
 						   struct platform_device, dev);
 	int ret = 0;
 
-	priv = kzalloc(sizeof(struct twl6040_data), GFP_KERNEL);
+	priv = devm_kzalloc(codec->dev, sizeof(*priv), GFP_KERNEL);
 	if (priv == NULL)
 		return -ENOMEM;
+
 	snd_soc_codec_set_drvdata(codec, priv);
 
 	priv->codec = codec;
@@ -1158,25 +1159,23 @@ static int twl6040_probe(struct snd_soc_codec *codec)
 	priv->plug_irq = platform_get_irq(pdev, 0);
 	if (priv->plug_irq < 0) {
 		dev_err(codec->dev, "invalid irq\n");
-		ret = -EINVAL;
-		goto work_err;
+		return -EINVAL;
 	}
 
 	priv->workqueue = alloc_workqueue("twl6040-codec", 0, 0);
-	if (!priv->workqueue) {
-		ret = -ENOMEM;
-		goto work_err;
-	}
+	if (!priv->workqueue)
+		return -ENOMEM;
 
 	INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work);
 
 	mutex_init(&priv->mutex);
 
-	ret = request_threaded_irq(priv->plug_irq, NULL, twl6040_audio_handler,
-				   IRQF_NO_SUSPEND, "twl6040_irq_plug", codec);
+	ret = devm_request_threaded_irq(codec->dev, priv->plug_irq, NULL,
+					twl6040_audio_handler, IRQF_NO_SUSPEND,
+					"twl6040_irq_plug", codec);
 	if (ret) {
 		dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret);
-		goto plugirq_err;
+		goto err;
 	}
 
 	twl6040_init_chip(codec);
@@ -1186,12 +1185,8 @@ static int twl6040_probe(struct snd_soc_codec *codec)
 	if (!ret)
 		return 0;
 
-	/* Error path */
-	free_irq(priv->plug_irq, codec);
-plugirq_err:
+err:
 	destroy_workqueue(priv->workqueue);
-work_err:
-	kfree(priv);
 	return ret;
 }
 
@@ -1200,9 +1195,7 @@ static int twl6040_remove(struct snd_soc_codec *codec)
 	struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
 
 	twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF);
-	free_irq(priv->plug_irq, codec);
 	destroy_workqueue(priv->workqueue);
-	kfree(priv);
 
 	return 0;
 }
Signature · 1 line
1.8.1
#4 lore raw

PATCH v2 4/5 ASoC: twl6040: Switch to use system workqueue for jack reporting

In reply to Peter Ujfalusi

There's no need to create a queue for this anymore

---
 sound/soc/codecs/twl6040.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)
sound/soc/codecs/twl6040.c +3 -18
index 90b721e..984911b 100644
@@ -75,7 +75,6 @@ struct twl6040_data {
 	u16 hf_right_step;
 	struct twl6040_jack_data hs_jack;
 	struct snd_soc_codec *codec;
-	struct workqueue_struct *workqueue;
 	struct mutex mutex;
 };
 
@@ -404,8 +403,7 @@ static irqreturn_t twl6040_audio_handler(int irq, void *data)
 	struct snd_soc_codec *codec = data;
 	struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
 
-	queue_delayed_work(priv->workqueue, &priv->hs_jack.work,
-			   msecs_to_jiffies(200));
+	schedule_delayed_work(&priv->hs_jack.work, msecs_to_jiffies(200));
 
 	return IRQ_HANDLED;
 }
@@ -1162,10 +1160,6 @@ static int twl6040_probe(struct snd_soc_codec *codec)
 		return -EINVAL;
 	}
 
-	priv->workqueue = alloc_workqueue("twl6040-codec", 0, 0);
-	if (!priv->workqueue)
-		return -ENOMEM;
-
 	INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work);
 
 	mutex_init(&priv->mutex);
@@ -1175,27 +1169,18 @@ static int twl6040_probe(struct snd_soc_codec *codec)
 					"twl6040_irq_plug", codec);
 	if (ret) {
 		dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret);
-		goto err;
+		return ret;
 	}
 
 	twl6040_init_chip(codec);
 
 	/* power on device */
-	ret = twl6040_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-	if (!ret)
-		return 0;
-
-err:
-	destroy_workqueue(priv->workqueue);
-	return ret;
+	return twl6040_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 }
 
 static int twl6040_remove(struct snd_soc_codec *codec)
 {
-	struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
-
 	twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF);
-	destroy_workqueue(priv->workqueue);
 
 	return 0;
 }
Signature · 1 line
1.8.1
#5 lore raw

PATCH v2 5/5 ASoC: twl6040: Remove leftover code from hs/hf ramp implementation

In reply to Peter Ujfalusi

The code to do the ramp has been removed a long time ago. Remove the remaining code as well since this is not needed.

---
 sound/soc/codecs/twl6040.c | 21 ---------------------
 1 file changed, 21 deletions(-)
sound/soc/codecs/twl6040.c +0 -21
index 984911b..9b9a6e5 100644
@@ -69,10 +69,6 @@ struct twl6040_data {
 	int hs_power_mode_locked;
 	unsigned int clk_in;
 	unsigned int sysclk;
-	u16 hs_left_step;
-	u16 hs_right_step;
-	u16 hf_left_step;
-	u16 hf_right_step;
 	struct twl6040_jack_data hs_jack;
 	struct snd_soc_codec *codec;
 	struct mutex mutex;
@@ -1124,7 +1120,6 @@ static int twl6040_resume(struct snd_soc_codec *codec)
 static int twl6040_probe(struct snd_soc_codec *codec)
 {
 	struct twl6040_data *priv;
-	struct twl6040_codec_data *pdata = dev_get_platdata(codec->dev);
 	struct platform_device *pdev = container_of(codec->dev,
 						   struct platform_device, dev);
 	int ret = 0;
@@ -1138,22 +1133,6 @@ static int twl6040_probe(struct snd_soc_codec *codec)
 	priv->codec = codec;
 	codec->control_data = dev_get_drvdata(codec->dev->parent);
 
-	if (pdata && pdata->hs_left_step && pdata->hs_right_step) {
-		priv->hs_left_step = pdata->hs_left_step;
-		priv->hs_right_step = pdata->hs_right_step;
-	} else {
-		priv->hs_left_step = 1;
-		priv->hs_right_step = 1;
-	}
-
-	if (pdata && pdata->hf_left_step && pdata->hf_right_step) {
-		priv->hf_left_step = pdata->hf_left_step;
-		priv->hf_right_step = pdata->hf_right_step;
-	} else {
-		priv->hf_left_step = 1;
-		priv->hf_right_step = 1;
-	}
-
 	priv->plug_irq = platform_get_irq(pdev, 0);
 	if (priv->plug_irq < 0) {
 		dev_err(codec->dev, "invalid irq\n");
Signature · 1 line
1.8.1
Applied
#6 lore raw
In reply to Peter Ujfalusi
Quoted 4 lines · Peter Ujfalusi

Hi Mark, Liam,

Changes since v1:
- patch 2 for twl6040_resume() has been replaced with a simpler one

Applied, thanks.