Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 305533
b: refs/heads/master
c: 49575fb
h: refs/heads/master
i:
  305531: a0ab865
v: v3
  • Loading branch information
Liam Girdwood authored and Mark Brown committed Apr 1, 2012
1 parent 469cf1b commit f7611b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a3cc056b64065efaf98d3e3fe8a6b9d508121492
refs/heads/master: 49575fb52bf76bf48e2d29ff034e8dad8d7ba638
34 changes: 28 additions & 6 deletions trunk/sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,23 @@ static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg, int val)
return -1;
}

static int soc_widget_update_bits(struct snd_soc_dapm_widget *w,
static inline void soc_widget_lock(struct snd_soc_dapm_widget *w)
{
if (w->codec)
mutex_lock(&w->codec->mutex);
else if (w->platform)
mutex_lock(&w->platform->mutex);
}

static inline void soc_widget_unlock(struct snd_soc_dapm_widget *w)
{
if (w->codec)
mutex_unlock(&w->codec->mutex);
else if (w->platform)
mutex_unlock(&w->platform->mutex);
}

static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w,
unsigned short reg, unsigned int mask, unsigned int value)
{
bool change;
Expand All @@ -219,18 +235,24 @@ static int soc_widget_update_bits(struct snd_soc_dapm_widget *w,
if (ret != 0)
return ret;
} else {
soc_widget_lock(w);
ret = soc_widget_read(w, reg);
if (ret < 0)
if (ret < 0) {
soc_widget_unlock(w);
return ret;
}

old = ret;
new = (old & ~mask) | (value & mask);
change = old != new;
if (change) {
ret = soc_widget_write(w, reg, new);
if (ret < 0)
if (ret < 0) {
soc_widget_unlock(w);
return ret;
}
}
soc_widget_unlock(w);
}

return change;
Expand Down Expand Up @@ -847,7 +869,7 @@ int dapm_reg_event(struct snd_soc_dapm_widget *w,
else
val = w->off_val;

soc_widget_update_bits(w, -(w->reg + 1),
soc_widget_update_bits_locked(w, -(w->reg + 1),
w->mask << w->shift, val << w->shift);

return 0;
Expand Down Expand Up @@ -1105,7 +1127,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_dapm_context *dapm,
"pop test : Applying 0x%x/0x%x to %x in %dms\n",
value, mask, reg, card->pop_time);
pop_wait(card->pop_time);
soc_widget_update_bits(w, reg, mask, value);
soc_widget_update_bits_locked(w, reg, mask, value);
}

list_for_each_entry(w, pending, power_list) {
Expand Down Expand Up @@ -1235,7 +1257,7 @@ static void dapm_widget_update(struct snd_soc_dapm_context *dapm)
w->name, ret);
}

ret = snd_soc_update_bits(w->codec, update->reg, update->mask,
ret = soc_widget_update_bits_locked(w, update->reg, update->mask,
update->val);
if (ret < 0)
pr_err("%s DAPM update failed: %d\n", w->name, ret);
Expand Down

0 comments on commit f7611b5

Please sign in to comment.