From 1eafe6d9fe9e5da0ebad54b8513e23d552336d36 Mon Sep 17 00:00:00 2001 From: tinno15 Date: Mon, 6 Dec 2021 21:28:05 +0800 Subject: [PATCH] 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: SLTApproved: Submit-Approved: Tested-by: Reviewed-by: Zhenghai Pan (cherry picked from commit 07fa0fbff4a0fef6b483d35ddf4c4c74daf658d2) Reviewed-on: https://gerrit.mot.com/2138542 Reviewed-by: Xiangpo Zhao --- .../regulator_vibrator_mmi/moto_regulator_vibrator.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/misc/regulator_vibrator_mmi/moto_regulator_vibrator.c b/drivers/misc/regulator_vibrator_mmi/moto_regulator_vibrator.c index 4530663d4033..83e2b7d022cd 100644 --- a/drivers/misc/regulator_vibrator_mmi/moto_regulator_vibrator.c +++ b/drivers/misc/regulator_vibrator_mmi/moto_regulator_vibrator.c @@ -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)