From patchwork Mon Jul 13 10:26:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 6777771 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 89858C05AC for ; Mon, 13 Jul 2015 10:27:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DC26205C2 for ; Mon, 13 Jul 2015 10:27:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 48EFA205B5 for ; Mon, 13 Jul 2015 10:27:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3F5AB261A5E; Mon, 13 Jul 2015 12:27:45 +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=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D17102605A9; Mon, 13 Jul 2015 12:27:07 +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 292462604D6; Mon, 13 Jul 2015 12:27:06 +0200 (CEST) Received: from smtp-out-236.synserver.de (smtp-out-236.synserver.de [212.40.185.236]) by alsa0.perex.cz (Postfix) with ESMTP id F0CF32604D6 for ; Mon, 13 Jul 2015 12:27:00 +0200 (CEST) Received: (qmail 10575 invoked by uid 0); 13 Jul 2015 10:26:59 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 10289 Received: from ppp-188-174-59-27.dynamic.mnet-online.de (HELO lars-laptop.fritz.box) [188.174.59.27] by 217.119.54.77 with SMTP; 13 Jul 2015 10:26:58 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Date: Mon, 13 Jul 2015 12:26:48 +0200 Message-Id: <1436783208-1529-5-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436783208-1529-1-git-send-email-lars@metafoo.de> References: <1436783208-1529-1-git-send-email-lars@metafoo.de> Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen Subject: [alsa-devel] [PATCH 5/5] ASoC: uda134x: Use regmap_update_bits() were appropriate 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of doing the read-modify-update cycle by hand when updating a register use regmap_update_bits(). This also means we can now remove uda134x_read_reg_cache() and uda134x_write() since they are unused. Signed-off-by: Lars-Peter Clausen --- sound/soc/codecs/uda134x.c | 57 ++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index d25a9f3..e190263 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c @@ -61,31 +61,6 @@ static const struct reg_default uda134x_reg_defaults[] = { }; /* - * The codec has no support for reading its registers except for peak level... - */ -static inline unsigned int uda134x_read_reg_cache(struct snd_soc_codec *codec, - unsigned int reg) -{ - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); - unsigned int val; - int ret; - - ret = regmap_read(uda134x->regmap, reg, &val); - if (ret) - return -1; - - return val; -} - -static void uda134x_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int val) -{ - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); - - regmap_write(uda134x->regmap, reg, val); -} - -/* * Write to the uda134x registers * */ @@ -137,27 +112,28 @@ static int uda134x_regmap_write(void *context, unsigned int reg, static inline void uda134x_reset(struct snd_soc_codec *codec) { - u8 reset_reg = uda134x_read_reg_cache(codec, UDA134X_STATUS0); - uda134x_write(codec, UDA134X_STATUS0, reset_reg | (1<<6)); + struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + unsigned int mask = 1<<6; + + regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, mask, mask); msleep(1); - uda134x_write(codec, UDA134X_STATUS0, reset_reg & ~(1<<6)); + regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, mask, 0); } static int uda134x_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u8 mute_reg = uda134x_read_reg_cache(codec, UDA134X_DATA010); + struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(dai->codec); + unsigned int mask = 1<<2; + unsigned int val; pr_debug("%s mute: %d\n", __func__, mute); if (mute) - mute_reg |= (1<<2); + val = mask; else - mute_reg &= ~(1<<2); - - uda134x_write(codec, UDA134X_DATA010, mute_reg); + val = 0; - return 0; + return regmap_update_bits(uda134x->regmap, UDA134X_DATA010, mask, val); } static int uda134x_startup(struct snd_pcm_substream *substream, @@ -209,7 +185,7 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_codec *codec = dai->codec; struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); - u8 hw_params; + unsigned int hw_params = 0; if (substream == uda134x->slave_substream) { pr_debug("%s ignoring hw_params for slave substream\n", @@ -217,10 +193,6 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream, return 0; } - hw_params = uda134x_read_reg_cache(codec, UDA134X_STATUS0); - hw_params &= STATUS0_SYSCLK_MASK; - hw_params &= STATUS0_DAIFMT_MASK; - pr_debug("%s sysclk: %d, rate:%d\n", __func__, uda134x->sysclk, params_rate(params)); @@ -271,9 +243,8 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - uda134x_write(codec, UDA134X_STATUS0, hw_params); - - return 0; + return regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, + STATUS0_SYSCLK_MASK | STATUS0_DAIFMT_MASK, hw_params); } static int uda134x_set_dai_sysclk(struct snd_soc_dai *codec_dai,