14 Oct
2009
14 Oct
'09
6:50 a.m.
On Tue, 2009-10-13 at 14:03 +0200, Ujfalusi Peter (Nokia-D/Tampere) wrote:
Having two almost identical functions probably "rang the bells" with you also.
How about:
static int dac33_write_locked(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { int ret;
mutex_lock(); ret = dac33_write(codec, reg, value); mutex_unlock();
return ret; }
(one way around it)
+static int dac33_write_locked(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value)
+{
struct tlv320dac33_priv *dac33 = codec->private_data;
u8 data[2];
int ret = 0;
/*
* data is
* D15..D8 dac33 register offset
* D7...D0 register data
*/
data[0] = reg & 0xff;
data[1] = value & 0xff;
dac33_write_reg_cache(codec, data[0], data[1]);
mutex_lock(&dac33->mutex);
if (dac33->chip_power) {
ret = codec->hw_write(codec->control_data, data, 2);
if (ret != 2)
dev_err(codec->dev, "Write failed (%d)\n", ret);
else
ret = 0;
}
mutex_unlock(&dac33->mutex);
return ret;
+}
+static int dac33_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value)
+{
struct tlv320dac33_priv *dac33 = codec->private_data;
u8 data[2];
int ret = 0;
/*
* data is
* D15..D8 dac33 register offset
* D7...D0 register data
*/
data[0] = reg & 0xff;
data[1] = value & 0xff;
dac33_write_reg_cache(codec, data[0], data[1]);
if (dac33->chip_power) {
ret = codec->hw_write(codec->control_data, data, 2);
if (ret != 2)
dev_err(codec->dev, "Write failed (%d)\n", ret);
else
ret = 0;
}
return ret;
+}