Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: sirf-audio-codec: Simplify the new bitmask value in regmap_update_bits
@ 2014-05-08  8:29 Axel Lin
  2014-05-08  8:31 ` Axel Lin
  2014-05-26 16:00 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2014-05-08  8:29 UTC (permalink / raw)
  To: Mark Brown; +Cc: Rongjun Ying, Barry Song, Liam Girdwood, alsa-devel

Having the binary ones complement operator in the new bitmak value makes the
code hard to read.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
I think the binary ones complement operator in such use case is error prone:
For example:
To set BIT(1) and clear both BIT(2) and BIT(3):
The following code has wrong result:
regmap_update_bits(regmap, the_register, BIT(1), BIT(2), BIT(3),
                   BIT(1) | ~BIT(2) | ~BIT(3));

Axel
 sound/soc/codecs/sirf-audio-codec.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c
index c5177bc..d90cb0f 100644
--- a/sound/soc/codecs/sirf-audio-codec.c
+++ b/sound/soc/codecs/sirf-audio-codec.c
@@ -109,7 +109,7 @@ static void enable_and_reset_codec(struct regmap *regmap,
 {
 	regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1,
 			codec_enable_bits | codec_reset_bits,
-			codec_enable_bits | ~codec_reset_bits);
+			codec_enable_bits);
 	msleep(20);
 	regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1,
 			codec_reset_bits, codec_reset_bits);
@@ -128,8 +128,7 @@ static int atlas6_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w,
 		break;
 	case SND_SOC_DAPM_POST_PMD:
 		regmap_update_bits(sirf_audio_codec->regmap,
-			AUDIO_IC_CODEC_CTRL1, ATLAS6_CODEC_ENABLE_BITS,
-			~ATLAS6_CODEC_ENABLE_BITS);
+			AUDIO_IC_CODEC_CTRL1, ATLAS6_CODEC_ENABLE_BITS, 0);
 		break;
 	default:
 		break;
@@ -151,8 +150,7 @@ static int prima2_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w,
 		break;
 	case SND_SOC_DAPM_POST_PMD:
 		regmap_update_bits(sirf_audio_codec->regmap,
-			AUDIO_IC_CODEC_CTRL1, PRIMA2_CODEC_ENABLE_BITS,
-			~PRIMA2_CODEC_ENABLE_BITS);
+			AUDIO_IC_CODEC_CTRL1, PRIMA2_CODEC_ENABLE_BITS, 0);
 		break;
 	default:
 		break;
-- 
1.8.3.2

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

* Re: [PATCH] ASoC: sirf-audio-codec: Simplify the new bitmask value in regmap_update_bits
  2014-05-08  8:29 [PATCH] ASoC: sirf-audio-codec: Simplify the new bitmask value in regmap_update_bits Axel Lin
@ 2014-05-08  8:31 ` Axel Lin
  2014-05-26 16:00 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2014-05-08  8:31 UTC (permalink / raw)
  To: Mark Brown; +Cc: Rongjun Ying, Barry Song, Liam Girdwood, alsa-devel

On 四, 2014-05-08 at 16:29 +0800, Axel Lin wrote:
> Having the binary ones complement operator in the new bitmak value makes the
> code hard to read.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> I think the binary ones complement operator in such use case is error prone:
> For example:
> To set BIT(1) and clear both BIT(2) and BIT(3):
> The following code has wrong result:
> regmap_update_bits(regmap, the_register, BIT(1), BIT(2), BIT(3),
>                    BIT(1) | ~BIT(2) | ~BIT(3));
Oops, I mean:
regmap_update_bits(regmap, the_register, BIT(1) | BIT(2)| BIT(3),
                   BIT(1) | ~BIT(2) | ~BIT(3));
Axel

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH] ASoC: sirf-audio-codec: Simplify the new bitmask value in regmap_update_bits
  2014-05-08  8:29 [PATCH] ASoC: sirf-audio-codec: Simplify the new bitmask value in regmap_update_bits Axel Lin
  2014-05-08  8:31 ` Axel Lin
@ 2014-05-26 16:00 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2014-05-26 16:00 UTC (permalink / raw)
  To: Axel Lin; +Cc: Rongjun Ying, Barry Song, Liam Girdwood, alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 176 bytes --]

On Thu, May 08, 2014 at 04:29:49PM +0800, Axel Lin wrote:
> Having the binary ones complement operator in the new bitmak value makes the
> code hard to read.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2014-05-26 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-08  8:29 [PATCH] ASoC: sirf-audio-codec: Simplify the new bitmask value in regmap_update_bits Axel Lin
2014-05-08  8:31 ` Axel Lin
2014-05-26 16:00 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox