All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
To: Mark Brown <broonie@kernel.org>,
	Support Opensource <Support.Opensource@diasemi.com>,
	Liam Girdwood <lgirdwood@gmail.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: RE: [PATCH v2] ASoC: da7219: Fix change notifications for tone generator frequency
Date: Wed, 20 Apr 2022 08:40:58 +0000	[thread overview]
Message-ID: <GV1PR10MB61247C557BBF9A6770A4594080F59@GV1PR10MB6124.EURPRD10.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20220417192733.7382-1-broonie@kernel.org>

On 17 April 2022 20:28, Mark Brown wrote:

> The tone generator frequency control just returns 0 on successful write,
> not a boolean value indicating if there was a change or not.  Compare
> what was written with the value that was there previously so that
> notifications are generated appropraitely when the value changes.

s/appropraitely/appropriately/

Thanks for the update. Good spot.

> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  sound/soc/codecs/da7219.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
> index a28d3601b932..c08e15830cec 100644
> --- a/sound/soc/codecs/da7219.c
> +++ b/sound/soc/codecs/da7219.c
> @@ -446,7 +446,7 @@ static int da7219_tonegen_freq_put(struct snd_kcontrol
> *kcontrol,
>  	struct soc_mixer_control *mixer_ctrl =
>  		(struct soc_mixer_control *) kcontrol->private_value;
>  	unsigned int reg = mixer_ctrl->reg;
> -	__le16 val;
> +	__le16 val_new, val_old;
>  	int ret;
> 
>  	/*
> @@ -454,13 +454,19 @@ static int da7219_tonegen_freq_put(struct
> snd_kcontrol *kcontrol,
>  	 * Therefore we need to convert to little endian here to align with
>  	 * HW registers.
>  	 */
> -	val = cpu_to_le16(ucontrol->value.integer.value[0]);
> +	val_new = cpu_to_le16(ucontrol->value.integer.value[0]);
> 
>  	mutex_lock(&da7219->ctrl_lock);
> -	ret = regmap_raw_write(da7219->regmap, reg, &val, sizeof(val));
> +	ret = regmap_raw_read(da7219->regmap, reg, &val_old, sizeof(val_old));
> +	if (ret == 0)

Wouldn't it make sense here to only perform the write if the values weren't the
same?

> +		ret = regmap_raw_write(da7219->regmap, reg,
> +				&val_new, sizeof(val_new));
>  	mutex_unlock(&da7219->ctrl_lock);
> 
> -	return ret;
> +	if (ret < 0)
> +		return ret;
> +
> +	return val_old != val_new;
>  }
> 
> 
> --
> 2.30.2


  reply	other threads:[~2022-04-20  8:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-17 19:27 [PATCH v2] ASoC: da7219: Fix change notifications for tone generator frequency Mark Brown
2022-04-20  8:40 ` Adam Thomson [this message]
2022-04-20 22:55 ` 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=GV1PR10MB61247C557BBF9A6770A4594080F59@GV1PR10MB6124.EURPRD10.PROD.OUTLOOK.COM \
    --to=adam.thomson.opensource@diasemi.com \
    --cc=Support.Opensource@diasemi.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.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.