ASoC: twl6040: One workqueue should be enough
It is a bit overkill to have three (3) separate workqueue for a single driver. We can manage things with one workqueue nicely. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
91a18ae8ff
commit
a46737aee5
|
@ -103,8 +103,6 @@ struct twl6040_data {
|
||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
struct twl6040_output headset;
|
struct twl6040_output headset;
|
||||||
struct twl6040_output handsfree;
|
struct twl6040_output handsfree;
|
||||||
struct workqueue_struct *hf_workqueue;
|
|
||||||
struct workqueue_struct *hs_workqueue;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -562,20 +560,17 @@ static int out_drv_event(struct snd_soc_dapm_widget *w,
|
||||||
struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
|
struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
|
||||||
struct twl6040_output *out;
|
struct twl6040_output *out;
|
||||||
struct delayed_work *work;
|
struct delayed_work *work;
|
||||||
struct workqueue_struct *queue;
|
|
||||||
|
|
||||||
switch (w->shift) {
|
switch (w->shift) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
out = &priv->headset;
|
out = &priv->headset;
|
||||||
queue = priv->hs_workqueue;
|
|
||||||
out->left_step = priv->hs_left_step;
|
out->left_step = priv->hs_left_step;
|
||||||
out->right_step = priv->hs_right_step;
|
out->right_step = priv->hs_right_step;
|
||||||
out->step_delay = 5; /* 5 ms between volume ramp steps */
|
out->step_delay = 5; /* 5 ms between volume ramp steps */
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
out = &priv->handsfree;
|
out = &priv->handsfree;
|
||||||
queue = priv->hf_workqueue;
|
|
||||||
out->left_step = priv->hf_left_step;
|
out->left_step = priv->hf_left_step;
|
||||||
out->right_step = priv->hf_right_step;
|
out->right_step = priv->hf_right_step;
|
||||||
out->step_delay = 5; /* 5 ms between volume ramp steps */
|
out->step_delay = 5; /* 5 ms between volume ramp steps */
|
||||||
|
@ -601,7 +596,7 @@ static int out_drv_event(struct snd_soc_dapm_widget *w,
|
||||||
|
|
||||||
if (!delayed_work_pending(work)) {
|
if (!delayed_work_pending(work)) {
|
||||||
out->ramp = TWL6040_RAMP_UP;
|
out->ramp = TWL6040_RAMP_UP;
|
||||||
queue_delayed_work(queue, work,
|
queue_delayed_work(priv->workqueue, work,
|
||||||
msecs_to_jiffies(1));
|
msecs_to_jiffies(1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -615,7 +610,7 @@ static int out_drv_event(struct snd_soc_dapm_widget *w,
|
||||||
out->ramp = TWL6040_RAMP_DOWN;
|
out->ramp = TWL6040_RAMP_DOWN;
|
||||||
INIT_COMPLETION(out->ramp_done);
|
INIT_COMPLETION(out->ramp_done);
|
||||||
|
|
||||||
queue_delayed_work(queue, work,
|
queue_delayed_work(priv->workqueue, work,
|
||||||
msecs_to_jiffies(1));
|
msecs_to_jiffies(1));
|
||||||
|
|
||||||
wait_for_completion_timeout(&out->ramp_done,
|
wait_for_completion_timeout(&out->ramp_done,
|
||||||
|
@ -1512,33 +1507,21 @@ static int twl6040_probe(struct snd_soc_codec *codec)
|
||||||
goto work_err;
|
goto work_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->workqueue = create_singlethread_workqueue("twl6040-codec");
|
priv->workqueue = alloc_workqueue("twl6040-codec", 0, 0);
|
||||||
if (!priv->workqueue) {
|
if (!priv->workqueue) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto work_err;
|
goto work_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work);
|
INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work);
|
||||||
|
INIT_DELAYED_WORK(&priv->headset.work, twl6040_pga_hs_work);
|
||||||
|
INIT_DELAYED_WORK(&priv->handsfree.work, twl6040_pga_hf_work);
|
||||||
|
|
||||||
mutex_init(&priv->mutex);
|
mutex_init(&priv->mutex);
|
||||||
|
|
||||||
init_completion(&priv->headset.ramp_done);
|
init_completion(&priv->headset.ramp_done);
|
||||||
init_completion(&priv->handsfree.ramp_done);
|
init_completion(&priv->handsfree.ramp_done);
|
||||||
|
|
||||||
priv->hf_workqueue = create_singlethread_workqueue("twl6040-hf");
|
|
||||||
if (priv->hf_workqueue == NULL) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto hfwq_err;
|
|
||||||
}
|
|
||||||
priv->hs_workqueue = create_singlethread_workqueue("twl6040-hs");
|
|
||||||
if (priv->hs_workqueue == NULL) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto hswq_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&priv->headset.work, twl6040_pga_hs_work);
|
|
||||||
INIT_DELAYED_WORK(&priv->handsfree.work, twl6040_pga_hf_work);
|
|
||||||
|
|
||||||
ret = request_threaded_irq(priv->plug_irq, NULL, twl6040_audio_handler,
|
ret = request_threaded_irq(priv->plug_irq, NULL, twl6040_audio_handler,
|
||||||
0, "twl6040_irq_plug", codec);
|
0, "twl6040_irq_plug", codec);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -1562,10 +1545,6 @@ static int twl6040_probe(struct snd_soc_codec *codec)
|
||||||
bias_err:
|
bias_err:
|
||||||
free_irq(priv->plug_irq, codec);
|
free_irq(priv->plug_irq, codec);
|
||||||
plugirq_err:
|
plugirq_err:
|
||||||
destroy_workqueue(priv->hs_workqueue);
|
|
||||||
hswq_err:
|
|
||||||
destroy_workqueue(priv->hf_workqueue);
|
|
||||||
hfwq_err:
|
|
||||||
destroy_workqueue(priv->workqueue);
|
destroy_workqueue(priv->workqueue);
|
||||||
work_err:
|
work_err:
|
||||||
kfree(priv);
|
kfree(priv);
|
||||||
|
@ -1579,8 +1558,6 @@ static int twl6040_remove(struct snd_soc_codec *codec)
|
||||||
twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF);
|
twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF);
|
||||||
free_irq(priv->plug_irq, codec);
|
free_irq(priv->plug_irq, codec);
|
||||||
destroy_workqueue(priv->workqueue);
|
destroy_workqueue(priv->workqueue);
|
||||||
destroy_workqueue(priv->hf_workqueue);
|
|
||||||
destroy_workqueue(priv->hs_workqueue);
|
|
||||||
kfree(priv);
|
kfree(priv);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue