diff options
-rw-r--r-- | sound/soc/codecs/tlv320dac33.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 80a26418827c..675f5b1b90a6 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c | |||
@@ -106,6 +106,7 @@ struct tlv320dac33_priv { | |||
106 | int mode1_latency; /* latency caused by the i2c writes in | 106 | int mode1_latency; /* latency caused by the i2c writes in |
107 | * us */ | 107 | * us */ |
108 | u8 burst_bclkdiv; /* BCLK divider value in burst mode */ | 108 | u8 burst_bclkdiv; /* BCLK divider value in burst mode */ |
109 | u8 *reg_cache; | ||
109 | unsigned int burst_rate; /* Interface speed in Burst modes */ | 110 | unsigned int burst_rate; /* Interface speed in Burst modes */ |
110 | 111 | ||
111 | int keep_bclk; /* Keep the BCLK continuously running | 112 | int keep_bclk; /* Keep the BCLK continuously running |
@@ -173,7 +174,8 @@ static const u8 dac33_reg[DAC33_CACHEREGNUM] = { | |||
173 | static inline unsigned int dac33_read_reg_cache(struct snd_soc_codec *codec, | 174 | static inline unsigned int dac33_read_reg_cache(struct snd_soc_codec *codec, |
174 | unsigned reg) | 175 | unsigned reg) |
175 | { | 176 | { |
176 | u8 *cache = codec->reg_cache; | 177 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
178 | u8 *cache = dac33->reg_cache; | ||
177 | if (reg >= DAC33_CACHEREGNUM) | 179 | if (reg >= DAC33_CACHEREGNUM) |
178 | return 0; | 180 | return 0; |
179 | 181 | ||
@@ -183,7 +185,8 @@ static inline unsigned int dac33_read_reg_cache(struct snd_soc_codec *codec, | |||
183 | static inline void dac33_write_reg_cache(struct snd_soc_codec *codec, | 185 | static inline void dac33_write_reg_cache(struct snd_soc_codec *codec, |
184 | u8 reg, u8 value) | 186 | u8 reg, u8 value) |
185 | { | 187 | { |
186 | u8 *cache = codec->reg_cache; | 188 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
189 | u8 *cache = dac33->reg_cache; | ||
187 | if (reg >= DAC33_CACHEREGNUM) | 190 | if (reg >= DAC33_CACHEREGNUM) |
188 | return; | 191 | return; |
189 | 192 | ||
@@ -243,19 +246,6 @@ static int dac33_write(struct snd_soc_codec *codec, unsigned int reg, | |||
243 | return ret; | 246 | return ret; |
244 | } | 247 | } |
245 | 248 | ||
246 | static int dac33_write_locked(struct snd_soc_codec *codec, unsigned int reg, | ||
247 | unsigned int value) | ||
248 | { | ||
249 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | ||
250 | int ret; | ||
251 | |||
252 | mutex_lock(&dac33->mutex); | ||
253 | ret = dac33_write(codec, reg, value); | ||
254 | mutex_unlock(&dac33->mutex); | ||
255 | |||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | #define DAC33_I2C_ADDR_AUTOINC 0x80 | 249 | #define DAC33_I2C_ADDR_AUTOINC 0x80 |
260 | static int dac33_write16(struct snd_soc_codec *codec, unsigned int reg, | 250 | static int dac33_write16(struct snd_soc_codec *codec, unsigned int reg, |
261 | unsigned int value) | 251 | unsigned int value) |
@@ -1432,13 +1422,9 @@ static int dac33_soc_remove(struct snd_soc_codec *codec) | |||
1432 | } | 1422 | } |
1433 | 1423 | ||
1434 | static const struct snd_soc_codec_driver soc_codec_dev_tlv320dac33 = { | 1424 | static const struct snd_soc_codec_driver soc_codec_dev_tlv320dac33 = { |
1435 | .read = dac33_read_reg_cache, | ||
1436 | .write = dac33_write_locked, | ||
1437 | .set_bias_level = dac33_set_bias_level, | 1425 | .set_bias_level = dac33_set_bias_level, |
1438 | .idle_bias_off = true, | 1426 | .idle_bias_off = true, |
1439 | .reg_cache_size = ARRAY_SIZE(dac33_reg), | 1427 | |
1440 | .reg_word_size = sizeof(u8), | ||
1441 | .reg_cache_default = dac33_reg, | ||
1442 | .probe = dac33_soc_probe, | 1428 | .probe = dac33_soc_probe, |
1443 | .remove = dac33_soc_remove, | 1429 | .remove = dac33_soc_remove, |
1444 | 1430 | ||
@@ -1497,6 +1483,13 @@ static int dac33_i2c_probe(struct i2c_client *client, | |||
1497 | if (dac33 == NULL) | 1483 | if (dac33 == NULL) |
1498 | return -ENOMEM; | 1484 | return -ENOMEM; |
1499 | 1485 | ||
1486 | dac33->reg_cache = devm_kmemdup(&client->dev, | ||
1487 | dac33_reg, | ||
1488 | ARRAY_SIZE(dac33_reg) * sizeof(u8), | ||
1489 | GFP_KERNEL); | ||
1490 | if (!dac33->reg_cache) | ||
1491 | return -ENOMEM; | ||
1492 | |||
1500 | dac33->i2c = client; | 1493 | dac33->i2c = client; |
1501 | mutex_init(&dac33->mutex); | 1494 | mutex_init(&dac33->mutex); |
1502 | spin_lock_init(&dac33->lock); | 1495 | spin_lock_init(&dac33->lock); |