power: reset function pointers on unset environment
authorMarcin Hajkowski <marcinx.hajkowski@intel.com>
Fri, 5 Apr 2019 16:22:04 +0000 (18:22 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 22 Apr 2019 20:45:51 +0000 (22:45 +0200)
Set all power environment related function pointers to NULL
when unset is being made.

Signed-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_power/rte_power.c

index ed70108..6b77227 100644 (file)
@@ -27,6 +27,22 @@ rte_power_freq_change_t rte_power_freq_enable_turbo;
 rte_power_freq_change_t rte_power_freq_disable_turbo;
 rte_power_get_capabilities_t rte_power_get_capabilities;
 
+static void
+reset_power_function_ptrs(void)
+{
+       rte_power_freqs  = NULL;
+       rte_power_get_freq = NULL;
+       rte_power_set_freq = NULL;
+       rte_power_freq_up = NULL;
+       rte_power_freq_down = NULL;
+       rte_power_freq_max = NULL;
+       rte_power_freq_min = NULL;
+       rte_power_turbo_status = NULL;
+       rte_power_freq_enable_turbo = NULL;
+       rte_power_freq_disable_turbo = NULL;
+       rte_power_get_capabilities = NULL;
+}
+
 int
 rte_power_set_env(enum power_management_env env)
 {
@@ -85,8 +101,10 @@ rte_power_set_env(enum power_management_env env)
 
        if (ret == 0)
                global_default_env = env;
-       else
+       else {
                global_default_env = PM_ENV_NOT_SET;
+               reset_power_function_ptrs();
+       }
 
        rte_spinlock_unlock(&global_env_cfg_lock);
        return ret;
@@ -97,6 +115,7 @@ rte_power_unset_env(void)
 {
        rte_spinlock_lock(&global_env_cfg_lock);
        global_default_env = PM_ENV_NOT_SET;
+       reset_power_function_ptrs();
        rte_spinlock_unlock(&global_env_cfg_lock);
 }