All of lore.kernel.org
 help / color / mirror / Atom feed
From: yang.a.fang@intel.com
To: broonie@kernel.org, lgirdwood@gmail.com
Cc: alsa-devel@alsa-project.org, srinivas.sripathi@intel.com, "Fang,
	Yang A" <yang.a.fang@intel.com>,
	praveen.k.jain@intel.com, denny.iriawan@intel.com,
	sathyanarayana.nujella@intel.com, kevin.strasser@linux.intel.com,
	dgreid@chromium.org
Subject: [PATCH] ASoC: ts3a227e: do not report jack status when there is i2c read err
Date: Tue, 30 Jun 2015 21:18:02 -0700	[thread overview]
Message-ID: <1435724282-109761-1-git-send-email-yang.a.fang@intel.com> (raw)

From: "Fang, Yang A" <yang.a.fang@intel.com>

After suspend -> resume the ts3a227e_interrupt sometimes comes before i2c
controller resume is called .regmap_read will return incorrect status
and report a wrong jack status.We should return if there is read err,the
interrupt will come again since it is level triggered and we are not yet
clear the interrupt. In addtion,cht_bsw_max98090_ti machine driver
registered additional notifier base on jack event which will program
the audio codec.there will be codec timeout err if such event occurs
prior to i2c controller is resumed.

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/codecs/ts3a227e.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c
index 12232d7..12d0f2a 100644
--- a/sound/soc/codecs/ts3a227e.c
+++ b/sound/soc/codecs/ts3a227e.c
@@ -23,6 +23,7 @@
 #include "ts3a227e.h"
 
 struct ts3a227e {
+	struct device *dev;
 	struct regmap *regmap;
 	struct snd_soc_jack *jack;
 	bool plugged;
@@ -189,16 +190,28 @@ static irqreturn_t ts3a227e_interrupt(int irq, void *data)
 	struct ts3a227e *ts3a227e = (struct ts3a227e *)data;
 	struct regmap *regmap = ts3a227e->regmap;
 	unsigned int int_reg, kp_int_reg, acc_reg, i;
+	struct device *dev = ts3a227e->dev;
+	int ret;
 
 	/* Check for plug/unplug. */
-	regmap_read(regmap, TS3A227E_REG_INTERRUPT, &int_reg);
+	ret = regmap_read(regmap, TS3A227E_REG_INTERRUPT, &int_reg);
+	if (ret) {
+		dev_err(dev, "failed to clear interrupt ret=%d\n", ret);
+		return IRQ_HANDLED;
+	}
+
 	if (int_reg & (DETECTION_COMPLETE_EVENT | INS_REM_EVENT)) {
 		regmap_read(regmap, TS3A227E_REG_ACCESSORY_STATUS, &acc_reg);
 		ts3a227e_new_jack_state(ts3a227e, acc_reg);
 	}
 
 	/* Report any key events. */
-	regmap_read(regmap, TS3A227E_REG_KP_INTERRUPT, &kp_int_reg);
+	ret = regmap_read(regmap, TS3A227E_REG_KP_INTERRUPT, &kp_int_reg);
+	if (ret) {
+		dev_err(dev, "failed to clear key interrupt ret=%d\n", ret);
+		return IRQ_HANDLED;
+	}
+
 	for (i = 0; i < TS3A227E_NUM_BUTTONS; i++) {
 		if (kp_int_reg & PRESS_MASK(i))
 			ts3a227e->buttons_held |= (1 << i);
@@ -283,6 +296,7 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 		return -ENOMEM;
 
 	i2c_set_clientdata(i2c, ts3a227e);
+	ts3a227e->dev = dev;
 
 	ts3a227e->regmap = devm_regmap_init_i2c(i2c, &ts3a227e_regmap_config);
 	if (IS_ERR(ts3a227e->regmap))
-- 
1.7.9.5

             reply	other threads:[~2015-07-01  4:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01  4:18 yang.a.fang [this message]
2015-07-01 17:12 ` [PATCH] ASoC: ts3a227e: do not report jack status when there is i2c read err Dylan Reid
2015-07-01 17:34   ` Yang Fang
2015-07-01 18:05     ` Mark Brown
2015-07-01 18:24       ` Fang, Yang A
2015-07-01 23:20         ` Fang, Yang A
2015-07-01 23:24 ` [PATCH v2] " yang.a.fang
2015-07-07 13:47   ` Mark Brown
2015-07-07 21:21   ` [PATCH v3] " yang.a.fang

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=1435724282-109761-1-git-send-email-yang.a.fang@intel.com \
    --to=yang.a.fang@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=denny.iriawan@intel.com \
    --cc=dgreid@chromium.org \
    --cc=kevin.strasser@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=praveen.k.jain@intel.com \
    --cc=sathyanarayana.nujella@intel.com \
    --cc=srinivas.sripathi@intel.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.