From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B80AC433EF for ; Thu, 18 Nov 2021 13:32:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17D426140D for ; Thu, 18 Nov 2021 13:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbhKRNfK (ORCPT ); Thu, 18 Nov 2021 08:35:10 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:44748 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbhKRNfJ (ORCPT ); Thu, 18 Nov 2021 08:35:09 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DE56E1FD29; Thu, 18 Nov 2021 13:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1637242327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vJPpmSqwfQ+E7wyd/Ugvv0kRl9SOxF8b6yI9zshXapU=; b=coMFhzHHTNQpqP1vGLhw2kauOIpNkdWyBHBsqcWy9r4oHA9e68LtK1QoLLxzYzAiU6NtGj x2NUoxsicqy/j+e1B6vDvB/EM69jn9wLdI3wlqK35mUMvybrgWMMzMsXILsnoNE3qus2NR rls9WDtUkoFvCtON7XpNWB03Q9b1pSw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1637242327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vJPpmSqwfQ+E7wyd/Ugvv0kRl9SOxF8b6yI9zshXapU=; b=yU4K9TSDyOFY52UmX/MihBq1XfW8lh/RgMb9KD91z2TRONEEnOwARA5K/c1N63b6uzB7QM wN4j1FTX+8eEHQCA== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id B17A4A3B81; Thu, 18 Nov 2021 13:32:07 +0000 (UTC) Date: Thu, 18 Nov 2021 14:32:07 +0100 Message-ID: From: Takashi Iwai To: Sameer Pujar Cc: , , , , , , , , Subject: Re: [PATCH v3 12/16] ASoC: tegra: Fix kcontrol put callback in MVC In-Reply-To: <1637219231-406-13-git-send-email-spujar@nvidia.com> References: <1637219231-406-1-git-send-email-spujar@nvidia.com> <1637219231-406-13-git-send-email-spujar@nvidia.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Nov 2021 08:07:07 +0100, Sameer Pujar wrote: > > The kcontrol put callback is expected to return 1 when there is change > in HW or when the update is acknowledged by driver. This would ensure > that change notifications are sent to subscribed applications. Filter > out duplicate updates in MVC driver. > > Fixes: e539891f9687 ("ASoC: tegra: Add Tegra210 based MVC driver") > Signed-off-by: Sameer Pujar > Suggested-by: Jaroslav Kysela > Suggested-by: Mark Brown > --- > sound/soc/tegra/tegra210_mvc.c | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/sound/soc/tegra/tegra210_mvc.c b/sound/soc/tegra/tegra210_mvc.c > index b7e3170..85b1558 100644 > --- a/sound/soc/tegra/tegra210_mvc.c > +++ b/sound/soc/tegra/tegra210_mvc.c > @@ -136,7 +136,7 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol, > struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); > struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); > unsigned int value; > - u8 mute_mask; > + u8 new_mask, old_mask; > int err; > > pm_runtime_get_sync(cmpnt->dev); > @@ -148,11 +148,19 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol, > if (err < 0) > goto end; > > - mute_mask = ucontrol->value.integer.value[0]; > + regmap_read(mvc->regmap, TEGRA210_MVC_CTRL, &value); > + > + old_mask = (value >> TEGRA210_MVC_MUTE_SHIFT) & TEGRA210_MUTE_MASK_EN; > + new_mask = ucontrol->value.integer.value[0]; > + > + if (new_mask == old_mask) { > + err = 0; > + goto end; > + } > > err = regmap_update_bits(mvc->regmap, mc->reg, > TEGRA210_MVC_MUTE_MASK, > - mute_mask << TEGRA210_MVC_MUTE_SHIFT); > + new_mask << TEGRA210_MVC_MUTE_SHIFT); I guess this test-and-update procedure can be simplified with regmap_update_bits_check(). thanks, Takashi