diff --git a/drivers/power/qpnp-charger.c b/drivers/power/qpnp-charger.c index 74c250dc1e5..46704366fa7 100644 --- a/drivers/power/qpnp-charger.c +++ b/drivers/power/qpnp-charger.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -420,7 +420,7 @@ struct qpnp_chg_chip { struct mutex jeita_configure_lock; spinlock_t usbin_health_monitor_lock; struct mutex batfet_vreg_lock; - struct alarm reduce_power_stage_alarm; + struct hrtimer hrtimer_reduce_power_stage_alarm; struct work_struct reduce_power_stage_work; bool power_stage_workaround_running; bool power_stage_workaround_enable; @@ -4483,9 +4483,9 @@ qpnp_chg_reduce_power_stage(struct qpnp_chg_chip *chip) if (usb_present && usb_ma_above_wall) { getnstimeofday(&ts); ts.tv_sec += POWER_STAGE_REDUCE_CHECK_PERIOD_SECONDS; - alarm_start_range(&chip->reduce_power_stage_alarm, + hrtimer_start_range_ns(&chip->hrtimer_reduce_power_stage_alarm, timespec_to_ktime(ts), - timespec_to_ktime(ts)); + ULONG_MAX, HRTIMER_MODE_ABS); } else { pr_debug("stopping power stage workaround\n"); chip->power_stage_workaround_running = false; @@ -4522,13 +4522,15 @@ qpnp_chg_reduce_power_stage_work(struct work_struct *work) qpnp_chg_reduce_power_stage(chip); } -static void -qpnp_chg_reduce_power_stage_callback(struct alarm *alarm) +enum hrtimer_restart +qpnp_chg_reduce_power_stage_callback(struct hrtimer *hrtimer) { - struct qpnp_chg_chip *chip = container_of(alarm, struct qpnp_chg_chip, - reduce_power_stage_alarm); + struct qpnp_chg_chip *chip = container_of(hrtimer, struct qpnp_chg_chip, + hrtimer_reduce_power_stage_alarm); schedule_work(&chip->reduce_power_stage_work); + + return HRTIMER_NORESTART; } static int @@ -5917,8 +5919,9 @@ qpnp_charger_probe(struct spmi_device *spmi) mutex_init(&chip->jeita_configure_lock); spin_lock_init(&chip->usbin_health_monitor_lock); - alarm_init(&chip->reduce_power_stage_alarm, ANDROID_ALARM_RTC_WAKEUP, - qpnp_chg_reduce_power_stage_callback); + hrtimer_init(&chip->hrtimer_reduce_power_stage_alarm, CLOCK_BOOTTIME, + HRTIMER_MODE_ABS); + chip->hrtimer_reduce_power_stage_alarm.function = &qpnp_chg_reduce_power_stage_callback; INIT_WORK(&chip->reduce_power_stage_work, qpnp_chg_reduce_power_stage_work); mutex_init(&chip->batfet_vreg_lock); @@ -6357,7 +6360,7 @@ qpnp_charger_remove(struct spmi_device *spmi) #endif cancel_work_sync(&chip->insertion_ocv_work); cancel_work_sync(&chip->reduce_power_stage_work); - alarm_cancel(&chip->reduce_power_stage_alarm); + hrtimer_cancel(&chip->hrtimer_reduce_power_stage_alarm); mutex_destroy(&chip->batfet_vreg_lock); mutex_destroy(&chip->jeita_configure_lock);