moto regulator vibrator: fix null pointer bug

vcc is null while chip is pwr_by_gpio
Add condition to avoid the crash.

Change-Id: I3de63bcf0c17954fb0bfc99767326c9dac34742a
Reviewed-on: https://gerrit.mot.com/2136306
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Submit-Approved: Jira Key
Tested-by: Jira Key
Reviewed-by: <tinno15@motorola.com>
SLTApproved: <tinno15@motorola.com>
Submit-Approved: <tinno15@motorola.com>
Tested-by: <tinno15@motorola.com>
Reviewed-by: Zhenghai Pan <panzh2@lenovo.com>
(cherry picked from commit 07fa0fbff4a0fef6b483d35ddf4c4c74daf658d2)
Reviewed-on: https://gerrit.mot.com/2138542
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
This commit is contained in:
tinno15 2021-12-06 21:28:05 +08:00 committed by Zhenghai Pan
parent e75299d77b
commit 144835c5fd

View file

@ -75,8 +75,16 @@ static void ext_vib_work(struct work_struct *work)
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));
if (chip->pwr_by_gpio)
{
pr_info("vib:chip->state = %d,vib_play_ms=%lld\n",chip->state,
chip->vib_play_ms);
}
else
{
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));
}
}
static enum hrtimer_restart vib_stop_timer(struct hrtimer *timer)