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 <wuwl10@motorola.com>
Reviewed-on: https://gerrit.mot.com/2095603
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wuwl10 2021-10-21 15:59:41 +08:00 • committed by Weilong Wu
commit 5ea66e0be4

View file

@ -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;