From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>,
Liam Girdwood <lrg@ti.com>
Cc: alsa-devel@alsa-project.org, Misael Lopez Cruz <misael.lopez@ti.com>
Subject: [PATCH v2 4/4] ASoC: twl6040: Simplify code in out_drv_event for pending work check
Date: Wed, 28 Sep 2011 14:16:33 +0300 [thread overview]
Message-ID: <1317208593-21142-5-git-send-email-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <1317208593-21142-1-git-send-email-peter.ujfalusi@ti.com>
Check for pending work before the DAPM event switch case, and return,
if the work is pending.
This way we can remove the two additional checks in POST_PMU, and
PRE_PMD for non pending works.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
sound/soc/codecs/twl6040.c | 25 +++++++++++--------------
1 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index c2b5829..e2e6c66 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -585,37 +585,34 @@ static int out_drv_event(struct snd_soc_dapm_widget *w,
work = &out->work;
+ if (delayed_work_pending(work))
+ return 0;
+
switch (event) {
case SND_SOC_DAPM_POST_PMU:
if (out->active)
break;
/* don't use volume ramp for power-up */
+ out->ramp = TWL6040_RAMP_UP;
out->left_step = out->left_vol;
out->right_step = out->right_vol;
- if (!delayed_work_pending(work)) {
- out->ramp = TWL6040_RAMP_UP;
- queue_delayed_work(priv->workqueue, work,
- msecs_to_jiffies(1));
- }
+ queue_delayed_work(priv->workqueue, work, msecs_to_jiffies(1));
break;
case SND_SOC_DAPM_PRE_PMD:
if (!out->active)
break;
- if (!delayed_work_pending(work)) {
- /* use volume ramp for power-down */
- out->ramp = TWL6040_RAMP_DOWN;
- INIT_COMPLETION(out->ramp_done);
+ /* use volume ramp for power-down */
+ out->ramp = TWL6040_RAMP_DOWN;
+ INIT_COMPLETION(out->ramp_done);
- queue_delayed_work(priv->workqueue, work,
- msecs_to_jiffies(1));
+ queue_delayed_work(priv->workqueue, work, msecs_to_jiffies(1));
- wait_for_completion_timeout(&out->ramp_done,
- msecs_to_jiffies(2000));
- }
+ wait_for_completion_timeout(&out->ramp_done,
+ msecs_to_jiffies(2000));
break;
}
--
1.7.6.1
next prev parent reply other threads:[~2011-09-28 11:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-28 11:16 [PATCH v2 0/4] ASoC: twl6040: Gain ramp code cleanups Peter Ujfalusi
2011-09-28 11:16 ` [PATCH v2 1/4] ASoC: twl6040: One workqueue should be enough Peter Ujfalusi
2011-09-28 11:16 ` [PATCH v2 2/4] ASoC: twl6040: correct loop counters for HS/HF ramp code Peter Ujfalusi
2011-09-28 11:16 ` [PATCH v2 3/4] ASoC: twl6040: Shift 2 identifies the HS output in out_drv_event Peter Ujfalusi
2011-09-28 11:16 ` Peter Ujfalusi [this message]
2011-09-29 12:11 ` [PATCH v2 4/4] ASoC: twl6040: Simplify code in out_drv_event for pending work check Péter Ujfalusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1317208593-21142-5-git-send-email-peter.ujfalusi@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lrg@ti.com \
--cc=misael.lopez@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.