All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: da7219: Fix change notifications for tone generator frequency
@ 2022-04-16 12:52 Mark Brown
  2022-04-16 19:25 ` Adam Ward
  2022-04-20 22:55 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2022-04-16 12:52 UTC (permalink / raw)
  To: Support Opensource, Liam Girdwood; +Cc: alsa-devel, Mark Brown

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.

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..166a3cad3445 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)
+		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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] ASoC: da7219: Fix change notifications for tone generator frequency
  2022-04-16 12:52 [PATCH] ASoC: da7219: Fix change notifications for tone generator frequency Mark Brown
@ 2022-04-16 19:25 ` Adam Ward
  2022-04-17 19:20   ` Mark Brown
  2022-04-20 22:55 ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Adam Ward @ 2022-04-16 19:25 UTC (permalink / raw)
  To: Mark Brown, Support Opensource, Liam Girdwood; +Cc: alsa-devel

On 16 April 2022 13:53, Mark Brown wrote:
>  	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)
I think you may have intended to confirm success here

> +		ret = regmap_raw_write(da7219->regmap, reg,
> +				&val_new, sizeof(val_new));
>  	mutex_unlock(&da7219->ctrl_lock);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: da7219: Fix change notifications for tone generator frequency
  2022-04-16 19:25 ` Adam Ward
@ 2022-04-17 19:20   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-04-17 19:20 UTC (permalink / raw)
  To: Adam Ward; +Cc: alsa-devel, Support Opensource, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

On Sat, Apr 16, 2022 at 07:25:20PM +0000, Adam Ward wrote:
> On 16 April 2022 13:53, Mark Brown wrote:
> >  	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)
> I think you may have intended to confirm success here

Yes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: da7219: Fix change notifications for tone generator frequency
  2022-04-16 12:52 [PATCH] ASoC: da7219: Fix change notifications for tone generator frequency Mark Brown
  2022-04-16 19:25 ` Adam Ward
@ 2022-04-20 22:55 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-04-20 22:55 UTC (permalink / raw)
  To: lgirdwood, support.opensource, broonie; +Cc: alsa-devel

On Sat, 16 Apr 2022 13:52:56 +0100, 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.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: da7219: Fix change notifications for tone generator frequency
      commit: 08ef48404965cfef99343d6bbbcf75b88c74aa0e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-20 22:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-16 12:52 [PATCH] ASoC: da7219: Fix change notifications for tone generator frequency Mark Brown
2022-04-16 19:25 ` Adam Ward
2022-04-17 19:20   ` Mark Brown
2022-04-20 22:55 ` Mark Brown

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.