Merge branch 'for-4.18/hid-redragon' into for-linus
[linux-block.git] / drivers / clk / clk.c
index 037035a46b33807503de8e0074362dbfb4203f33..ea67ac81c6f97db113cef4977936776d1673ae3f 100644 (file)
@@ -2311,8 +2311,11 @@ static int clk_core_set_phase_nolock(struct clk_core *core, int degrees)
 
        trace_clk_set_phase(core, degrees);
 
-       if (core->ops->set_phase)
+       if (core->ops->set_phase) {
                ret = core->ops->set_phase(core->hw, degrees);
+               if (!ret)
+                       core->phase = degrees;
+       }
 
        trace_clk_set_phase_complete(core, degrees);
 
@@ -2372,6 +2375,9 @@ static int clk_core_get_phase(struct clk_core *core)
        int ret;
 
        clk_prepare_lock();
+       /* Always try to update cached phase if possible */
+       if (core->ops->get_phase)
+               core->phase = core->ops->get_phase(core->hw);
        ret = core->phase;
        clk_prepare_unlock();