From: Marcin Hajkowski Date: Fri, 5 Apr 2019 16:22:03 +0000 (+0200) Subject: power: return error when environment already set X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5a5f3178d4a83338e518343ea4037f56b6065f1e;p=dpdk.git power: return error when environment already set On attempt to set_env in already initialized state notify user by returning error that operation cannot be performed. Signed-off-by: Marcin Hajkowski Acked-by: Anatoly Burakov --- diff --git a/lib/librte_power/rte_power.c b/lib/librte_power/rte_power.c index 540d69be7b..ed701087dc 100644 --- a/lib/librte_power/rte_power.c +++ b/lib/librte_power/rte_power.c @@ -33,8 +33,9 @@ rte_power_set_env(enum power_management_env env) rte_spinlock_lock(&global_env_cfg_lock); if (global_default_env != PM_ENV_NOT_SET) { + RTE_LOG(ERR, POWER, "Power Management Environment already set.\n"); rte_spinlock_unlock(&global_env_cfg_lock); - return 0; + return -1; } int ret = 0; diff --git a/lib/librte_power/rte_power.h b/lib/librte_power/rte_power.h index 47db69f336..0650112ade 100644 --- a/lib/librte_power/rte_power.h +++ b/lib/librte_power/rte_power.h @@ -26,7 +26,8 @@ enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM, /** * Set the default power management implementation. If this is not called prior * to rte_power_init(), then auto-detect of the environment will take place. - * It is thread safe. + * It is thread safe. New env can be set only in unitialized state + * (thus rte_power_unset_env must be called if different env was already set). * * @param env * env. The environment in which to initialise Power Management for.