cpufreq: use memcpy() to copy policy
authorViresh Kumar <viresh.kumar@linaro.org>
Mon, 3 Aug 2015 03:06:15 +0000 (08:36 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 1 Sep 2015 13:50:38 +0000 (15:50 +0200)
cpufreq_get_policy() is useful if the pointer to policy isn't available
in advance. But if it is available, then there is no need to call
cpufreq_get_policy(). Directly use memcpy() to copy the policy.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c

index 293f47b814bf0111661d2529689267511857d486..86d69416821b3791fa52a15b73f390b063c685ce 100644 (file)
@@ -606,9 +606,7 @@ static ssize_t store_##file_name                                    \
        int ret, temp;                                                  \
        struct cpufreq_policy new_policy;                               \
                                                                        \
-       ret = cpufreq_get_policy(&new_policy, policy->cpu);             \
-       if (ret)                                                        \
-               return -EINVAL;                                         \
+       memcpy(&new_policy, policy, sizeof(*policy));                   \
                                                                        \
        ret = sscanf(buf, "%u", &new_policy.object);                    \
        if (ret != 1)                                                   \
@@ -662,9 +660,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
        char    str_governor[16];
        struct cpufreq_policy new_policy;
 
-       ret = cpufreq_get_policy(&new_policy, policy->cpu);
-       if (ret)
-               return ret;
+       memcpy(&new_policy, policy, sizeof(*policy));
 
        ret = sscanf(buf, "%15s", str_governor);
        if (ret != 1)