summary refs log tree commit diff
path: root/sound/soc/codecs/rt298.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2015-10-05 21:23:48 +0800
committerMark Brown <broonie@kernel.org>2015-10-16 18:13:35 +0100
commit3943b9efb381531b99bf9c545736f9e1e2715b9c (patch)
tree8d60bc6a54082932150f869dc5112de197c9e412 /sound/soc/codecs/rt298.c
parenta5fe58fd2836987387a6ee8854c529db7f5be650 (diff)
downloadlinux-3943b9efb381531b99bf9c545736f9e1e2715b9c.tar.gz
ASoC: rt298: Make rt298_index_def const
The index_cache is per instance run time state but rt298_index_def is not.
Make rt298_index_def const and make a copy of memory for index_cache rather
than directly use the rt298_index_def.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt298.c')
-rw-r--r--sound/soc/codecs/rt298.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index ff126a7cee76..d039c995c051 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -49,7 +49,7 @@ struct rt298_priv {
 	int is_hp_in;
 };
 
-static struct reg_default rt298_index_def[] = {
+static const struct reg_default rt298_index_def[] = {
 	{ 0x01, 0xaaaa },
 	{ 0x02, 0x8aaa },
 	{ 0x03, 0x0002 },
@@ -1165,7 +1165,11 @@ static int rt298_i2c_probe(struct i2c_client *i2c,
 		return -ENODEV;
 	}
 
-	rt298->index_cache = rt298_index_def;
+	rt298->index_cache = devm_kmemdup(&i2c->dev, rt298_index_def,
+					  sizeof(rt298_index_def), GFP_KERNEL);
+	if (!rt298->index_cache)
+		return -ENOMEM;
+
 	rt298->index_cache_size = INDEX_CACHE_SIZE;
 	rt298->i2c = i2c;
 	i2c_set_clientdata(i2c, rt298);