From patchwork Mon Oct 5 13:23:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 7327511 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7CADABEEA4 for ; Mon, 5 Oct 2015 13:24:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7CA42068D for ; Mon, 5 Oct 2015 13:24:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 71A9320687 for ; Mon, 5 Oct 2015 13:24:09 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1562F2605C7; Mon, 5 Oct 2015 15:24:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id F109926059A; Mon, 5 Oct 2015 15:24:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 37520260547; Mon, 5 Oct 2015 15:24:01 +0200 (CEST) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by alsa0.perex.cz (Postfix) with ESMTP id 2DA9E260547 for ; Mon, 5 Oct 2015 15:23:55 +0200 (CEST) Received: by pacfv12 with SMTP id fv12so180900679pac.2 for ; Mon, 05 Oct 2015 06:23:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:mime-version:content-transfer-encoding; bh=2uIz6h5BJK7iRJjj5/YufkvFQ6J+vnrNvWnZkEfqLf4=; b=exPsW8I101fiwK9hIus17PNn2kyHph5CQnvNl91d+tO3gogkE29qRtAjGt1zJ4QBWp rF7V9wB+4rW4uJmA1+51NhfiXJeHfV496N02QRrZGpFsbzaMlPAFBSIkEYOmPz06qS3I ++FjZgzRza1gKGl32uzPwW9TnPcWQ+k/B8uXC4XHZEJAOg1Jdq6ZBERWjDs2QaA5HoOd 22pWhGcFrsWJR0shN52FAAI2uU/phFcRu5tYNL2xuOpDGtndj5tmxfngCZLpkLjTOCX9 kaFlS2M39sAny3nFWIWEtexzyuonWyLMO3CeV9T3jtuI2jqUV/qqqWTUVepNnhs3QY7O HGvQ== X-Gm-Message-State: ALoCoQm8JDHW2U+IsS6FsF3G2ovq6D4pr94y69ErGc29tcdxVG7g7uTkzqKxdae+z6pMHkRkKYmk X-Received: by 10.68.65.37 with SMTP id u5mr40738743pbs.154.1444051433884; Mon, 05 Oct 2015 06:23:53 -0700 (PDT) Received: from phoenix ([60.245.65.112]) by smtp.gmail.com with ESMTPSA id gd2sm27747901pbb.41.2015.10.05.06.23.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Oct 2015 06:23:52 -0700 (PDT) Message-ID: <1444051428.13473.2.camel@ingics.com> From: Axel Lin To: Mark Brown Date: Mon, 05 Oct 2015 21:23:48 +0800 In-Reply-To: <1444051360.13473.1.camel@ingics.com> References: <1444051360.13473.1.camel@ingics.com> X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Cc: Oder Chiou , Bard Liao , alsa-devel@alsa-project.org, Liam Girdwood Subject: [alsa-devel] [RFT][PATCH 2/2] ASoC: rt298: Make rt298_index_def const X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);