Skip to contentSkip to conversation

ASoC: rt286: add jack detection disable with NULL jack passed

DISCUSSION Dan Carpenter 2 participants 2 messages Feb 26, 2015 – Feb 27, 2015

lore
Share & tools
lore
#0 lore raw

Hello Jie Yang,

The patch e2cef68d5903: "ASoC: rt286: add jack detection disable with NULL jack passed" from Feb 10, 2015, leads to the following static checker warning:

	sound/soc/codecs/rt286.c:400 rt286_mic_detect()
	warn: suspicious bitop condition

sound/soc/codecs/rt286.c
392 int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) 393 {
394 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
395
396 rt286->jack = jack;
397
398 if (jack) {
399 /* enable IRQ */
400 if (rt286->jack->status | SND_JACK_HEADPHONE)

                                                ^^^^^^^^^^^^^^^^^^^^

You probably intended bitwise AND here? Bitwise OR is always true.

   401                          snd_soc_dapm_force_enable_pin(&codec->dapm, "LDO1");
   402                  regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x2);
   403                  /* Send an initial empty report */
   404                  snd_soc_jack_report(rt286->jack, rt286->jack->status,
   405                          SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
   406          } else {
   407                  /* disable IRQ */
   408                  regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x0);
   409                  snd_soc_dapm_disable_pin(&codec->dapm, "LDO1");
   410          }
   411          snd_soc_dapm_sync(&codec->dapm);
   412  
   413          return 0;
   414  }

regards,
dan carpenter

#1 lore raw

Hi Dan Carpenter,

Thanks for reminding, you are right, it should be AND here, will send out patch to fix it soon.

~Keyon

Quoted 49 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Thursday, February 26, 2015 4:15 PM
To: Jie, Yang
Cc: [email protected]
Subject: re: ASoC: rt286: add jack detection disable with NULL jack passed

Hello Jie Yang,

The patch e2cef68d5903: "ASoC: rt286: add jack detection disable with NULL jack passed" from Feb 10, 2015, leads to the following static checker warning:

	sound/soc/codecs/rt286.c:400 rt286_mic_detect()
	warn: suspicious bitop condition

sound/soc/codecs/rt286.c
392 int rt286_mic_detect(struct snd_soc_codec *codec, struct
snd_soc_jack *jack)

   393  {
   394          struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
   395
   396          rt286->jack = jack;
   397
   398          if (jack) {
   399                  /* enable IRQ */
   400                  if (rt286->jack->status | SND_JACK_HEADPHONE)
                                                ^^^^^^^^^^^^^^^^^^^^ You probably intended

bitwise AND here? Bitwise OR is always true.

   401                          snd_soc_dapm_force_enable_pin(&codec->dapm,
"LDO1");
   402                  regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2,
0x2);
   403                  /* Send an initial empty report */
   404                  snd_soc_jack_report(rt286->jack, rt286->jack->status,
   405                          SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
   406          } else {
   407                  /* disable IRQ */
   408                  regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2,
0x0);
   409                  snd_soc_dapm_disable_pin(&codec->dapm, "LDO1");
   410          }
   411          snd_soc_dapm_sync(&codec->dapm);
   412
   413          return 0;
   414  }

regards,
dan carpenter