diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index fefb8563db9eb760a1941483092b535022225e14..f36debffe6e8c8b2c21dd825626b9be08c7fc5d0 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) mutex_lock(&info->lock); + /* If the cable was removed while measuring ignore the result */ + ret = extcon_get_cable_state_(&info->edev, ARIZONA_CABLE_MECHANICAL); + if (ret < 0) { + dev_err(arizona->dev, "Failed to check cable state: %d\n", + ret); + mutex_unlock(&info->lock); + return; + } else if (!ret) { + dev_dbg(arizona->dev, "Ignoring MICDET for removed cable\n"); + mutex_unlock(&info->lock); + return; + } + for (i = 0; i < 10 && !(val & MICD_LVL_0_TO_8); i++) { ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); if (ret != 0) {