Skip to content

Commit

Permalink
cpufreq: use memcpy() to copy policy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Viresh Kumar authored and Rafael J. Wysocki committed Sep 1, 2015
1 parent 6bfb7c7 commit 8fa5b63
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8fa5b63

Please sign in to comment.