PM: domains: Return early if perf state is already set for the device
authorUlf Hansson <ulf.hansson@linaro.org>
Thu, 3 Jun 2021 09:34:36 +0000 (11:34 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 11 Jun 2021 16:39:24 +0000 (18:39 +0200)
When dev_pm_genpd_set_performance_state() gets called to set a new
performance state for the device, let's take a quicker path by doing an
early return, if it turns out that the new state is already set for the
device.

Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/domain.c

index ede0f57..90a9828 100644 (file)
@@ -387,6 +387,9 @@ static int genpd_set_performance_state(struct device *dev, unsigned int state)
        int ret;
 
        prev_state = gpd_data->performance_state;
+       if (prev_state == state)
+               return 0;
+
        gpd_data->performance_state = state;
        state = _genpd_reeval_performance_state(genpd, state);