aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorEero Nurkkala <ext-eero.nurkkala@nokia.com>2009-10-30 07:34:03 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-10-30 13:49:12 -0400
commit6c508c62f90240ef58300a5e12093ee769a44364 (patch)
tree73ae38fea98a5d10e82e70258ccf95fe1064d9ee /sound
parent8538a119bfb9031c402a33fc65c276ab9bfafdd5 (diff)
ASoC: refactor snd_soc_update_bits()
Introduce a wrapper call snd_soc_update_bits_locked() that will take the codec mutex. This call is used when the codec mutex is not already taken. Drivers calling snd_soc_update_bits() may wish to make sure the codec mutex is taken from the driver. Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-core.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 025c5a7f8b72..6e24654194ee 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1356,6 +1356,30 @@ int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
1356EXPORT_SYMBOL_GPL(snd_soc_update_bits); 1356EXPORT_SYMBOL_GPL(snd_soc_update_bits);
1357 1357
1358/** 1358/**
1359 * snd_soc_update_bits_locked - update codec register bits
1360 * @codec: audio codec
1361 * @reg: codec register
1362 * @mask: register mask
1363 * @value: new value
1364 *
1365 * Writes new register value, and takes the codec mutex.
1366 *
1367 * Returns 1 for change else 0.
1368 */
1369static int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
1370 unsigned short reg, unsigned int mask,
1371 unsigned int value)
1372{
1373 int change;
1374
1375 mutex_lock(&codec->mutex);
1376 change = snd_soc_update_bits(codec, reg, mask, value);
1377 mutex_unlock(&codec->mutex);
1378
1379 return change;
1380}
1381
1382/**
1359 * snd_soc_test_bits - test register for change 1383 * snd_soc_test_bits - test register for change
1360 * @codec: audio codec 1384 * @codec: audio codec
1361 * @reg: codec register 1385 * @reg: codec register
@@ -1706,7 +1730,7 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
1706 mask |= (bitmask - 1) << e->shift_r; 1730 mask |= (bitmask - 1) << e->shift_r;
1707 } 1731 }
1708 1732
1709 return snd_soc_update_bits(codec, e->reg, mask, val); 1733 return snd_soc_update_bits_locked(codec, e->reg, mask, val);
1710} 1734}
1711EXPORT_SYMBOL_GPL(snd_soc_put_enum_double); 1735EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
1712 1736
@@ -1780,7 +1804,7 @@ int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
1780 mask |= e->mask << e->shift_r; 1804 mask |= e->mask << e->shift_r;
1781 } 1805 }
1782 1806
1783 return snd_soc_update_bits(codec, e->reg, mask, val); 1807 return snd_soc_update_bits_locked(codec, e->reg, mask, val);
1784} 1808}
1785EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double); 1809EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double);
1786 1810
@@ -1941,7 +1965,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
1941 val_mask |= mask << rshift; 1965 val_mask |= mask << rshift;
1942 val |= val2 << rshift; 1966 val |= val2 << rshift;
1943 } 1967 }
1944 return snd_soc_update_bits(codec, reg, val_mask, val); 1968 return snd_soc_update_bits_locked(codec, reg, val_mask, val);
1945} 1969}
1946EXPORT_SYMBOL_GPL(snd_soc_put_volsw); 1970EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
1947 1971
@@ -2047,11 +2071,11 @@ int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
2047 val = val << shift; 2071 val = val << shift;
2048 val2 = val2 << shift; 2072 val2 = val2 << shift;
2049 2073
2050 err = snd_soc_update_bits(codec, reg, val_mask, val); 2074 err = snd_soc_update_bits_locked(codec, reg, val_mask, val);
2051 if (err < 0) 2075 if (err < 0)
2052 return err; 2076 return err;
2053 2077
2054 err = snd_soc_update_bits(codec, reg2, val_mask, val2); 2078 err = snd_soc_update_bits_locked(codec, reg2, val_mask, val2);
2055 return err; 2079 return err;
2056} 2080}
2057EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r); 2081EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r);
@@ -2130,7 +2154,7 @@ int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
2130 val = (ucontrol->value.integer.value[0]+min) & 0xff; 2154 val = (ucontrol->value.integer.value[0]+min) & 0xff;
2131 val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8; 2155 val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8;
2132 2156
2133 return snd_soc_update_bits(codec, reg, 0xffff, val); 2157 return snd_soc_update_bits_locked(codec, reg, 0xffff, val);
2134} 2158}
2135EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8); 2159EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8);
2136 2160