aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2013-11-14 11:18:23 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2014-01-06 21:54:28 -0500
commit31a847e6e1ed4db5002a4af191988aa85008c407 (patch)
treeb8e21584379518dccec958077678434869a12d9e
parenta3e00d4bd8011f2fe5100e1a0d3a01cc2afaa187 (diff)
extcon: arizona: Fix race with microphone detection and removal
The microphone detection code is run as delayed work to provide additional debounce, it is possible that the jack could have been removed by the time we process the microphone detection. Turn this case into a no op. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r--drivers/extcon/extcon-arizona.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index fefb8563db9e..f36debffe6e8 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -780,6 +780,19 @@ static void arizona_micd_detect(struct work_struct *work)
780 780
781 mutex_lock(&info->lock); 781 mutex_lock(&info->lock);
782 782
783 /* If the cable was removed while measuring ignore the result */
784 ret = extcon_get_cable_state_(&info->edev, ARIZONA_CABLE_MECHANICAL);
785 if (ret < 0) {
786 dev_err(arizona->dev, "Failed to check cable state: %d\n",
787 ret);
788 mutex_unlock(&info->lock);
789 return;
790 } else if (!ret) {
791 dev_dbg(arizona->dev, "Ignoring MICDET for removed cable\n");
792 mutex_unlock(&info->lock);
793 return;
794 }
795
783 for (i = 0; i < 10 && !(val & MICD_LVL_0_TO_8); i++) { 796 for (i = 0; i < 10 && !(val & MICD_LVL_0_TO_8); i++) {
784 ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); 797 ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
785 if (ret != 0) { 798 if (ret != 0) {