From 5ea66e0be4c3a2a04cd713fcf855db5968b9efe0 Mon Sep 17 00:00:00 2001 From: wuwl10 Date: Thu, 21 Oct 2021 15:59:41 +0800 Subject: [PATCH] dlkm: fix vibrator stop fail issue Cyprus IP68 use regulator to driver vibrator. Fix regulator unblance and disable faild issue. Change-Id: I17cab4b196725794c34f73d4ee4eccfeeac75f89 Signed-off-by: wuwl10 Reviewed-on: https://gerrit.mot.com/2095603 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- .../moto_regulator_vibrator.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/misc/regulator_vibrator_mmi/moto_regulator_vibrator.c b/drivers/misc/regulator_vibrator_mmi/moto_regulator_vibrator.c index f4c1cd9bfeeb..4530663d4033 100644 --- a/drivers/misc/regulator_vibrator_mmi/moto_regulator_vibrator.c +++ b/drivers/misc/regulator_vibrator_mmi/moto_regulator_vibrator.c @@ -50,26 +50,30 @@ static void ext_vib_work(struct work_struct *work) vib_work); int ret = 0; + static bool regulator_en_flag = false; if (chip->state) { - if (chip->pwr_by_gpio){ + if (chip->pwr_by_gpio) { ret = gpio_direction_output(chip->vcc_3v0_Pin, chip->state); ret = gpio_direction_output(chip->vcc_2v6_Pin, chip->state); } - else + else if (!regulator_en_flag) { ret = regulator_enable(chip->vcc); - + regulator_en_flag = true; + } if (ret == 0) hrtimer_start(&chip->stop_timer, ms_to_ktime(chip->vib_play_ms), HRTIMER_MODE_REL); } else { - if (chip->pwr_by_gpio){ + if (chip->pwr_by_gpio) { gpio_direction_output(chip->vcc_2v6_Pin, chip->state); gpio_direction_output(chip->vcc_3v0_Pin, chip->state); } - else + else if (regulator_en_flag) { + regulator_en_flag = false; ret = regulator_disable(chip->vcc); + } } pr_info("vib:chip->state = %d,vib_play_ms=%lld vib_vol=%d\n",chip->state, chip->vib_play_ms, regulator_get_voltage(chip->vcc)); @@ -176,8 +180,8 @@ static ssize_t ext_vib_store_activate(struct device *dev, hrtimer_cancel(&chip->stop_timer); chip->state = val; pr_info("vib: state = %d, time = %llu ms\n", chip->state, chip->vib_play_ms); - mutex_unlock(&chip->lock); + schedule_work(&chip->vib_work); return count;