All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Mark Brown <broonie@kernel.org>
Cc: Oder Chiou <oder_chiou@realtek.com>,
	Bard Liao <bardliao@realtek.com>,
	alsa-devel@alsa-project.org, Liam Girdwood <lgirdwood@gmail.com>
Subject: [RFT][PATCH 2/2] ASoC: rt298: Make rt298_index_def const
Date: Mon, 05 Oct 2015 21:23:48 +0800	[thread overview]
Message-ID: <1444051428.13473.2.camel@ingics.com> (raw)
In-Reply-To: <1444051360.13473.1.camel@ingics.com>

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>
---
 sound/soc/codecs/rt298.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index 2a6c2ba..83bbc62 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -48,7 +48,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 },
@@ -1164,7 +1164,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);
-- 
2.1.4

  reply	other threads:[~2015-10-05 13:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-05 13:22 [RFT][PATCH 1/2] ASoC: rt286: Fix run time error while modifying const data Axel Lin
2015-10-05 13:23 ` Axel Lin [this message]
2015-10-07  9:48   ` Applied "ASoC: rt298: Make rt298_index_def const" to the asoc tree Mark Brown
2015-10-21 12:34   ` Mark Brown
2015-11-03 15:15   ` Mark Brown
2015-10-07  9:48 ` Applied "ASoC: rt286: Fix run time error while modifying const data" " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444051428.13473.2.camel@ingics.com \
    --to=axel.lin@ingics.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bardliao@realtek.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=oder_chiou@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.