cpufreq.c (f339f3541701d824a0256ad4bf14c26ceb6d79c3) | cpufreq.c (d4627a287e251efed59f2b4bda82c5950768c963) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/drivers/cpufreq/cpufreq.c 4 * 5 * Copyright (C) 2001 Russell King 6 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 7 * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org> 8 * --- 934 unchanged lines hidden (view full) --- 943 944#define to_policy(k) container_of(k, struct cpufreq_policy, kobj) 945#define to_attr(a) container_of(a, struct freq_attr, attr) 946 947static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf) 948{ 949 struct cpufreq_policy *policy = to_policy(kobj); 950 struct freq_attr *fattr = to_attr(attr); | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/drivers/cpufreq/cpufreq.c 4 * 5 * Copyright (C) 2001 Russell King 6 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 7 * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org> 8 * --- 934 unchanged lines hidden (view full) --- 943 944#define to_policy(k) container_of(k, struct cpufreq_policy, kobj) 945#define to_attr(a) container_of(a, struct freq_attr, attr) 946 947static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf) 948{ 949 struct cpufreq_policy *policy = to_policy(kobj); 950 struct freq_attr *fattr = to_attr(attr); |
951 ssize_t ret; | 951 ssize_t ret = -EBUSY; |
952 953 if (!fattr->show) 954 return -EIO; 955 956 down_read(&policy->rwsem); | 952 953 if (!fattr->show) 954 return -EIO; 955 956 down_read(&policy->rwsem); |
957 ret = fattr->show(policy, buf); | 957 if (likely(!policy_is_inactive(policy))) 958 ret = fattr->show(policy, buf); |
958 up_read(&policy->rwsem); 959 960 return ret; 961} 962 963static ssize_t store(struct kobject *kobj, struct attribute *attr, 964 const char *buf, size_t count) 965{ 966 struct cpufreq_policy *policy = to_policy(kobj); 967 struct freq_attr *fattr = to_attr(attr); | 959 up_read(&policy->rwsem); 960 961 return ret; 962} 963 964static ssize_t store(struct kobject *kobj, struct attribute *attr, 965 const char *buf, size_t count) 966{ 967 struct cpufreq_policy *policy = to_policy(kobj); 968 struct freq_attr *fattr = to_attr(attr); |
968 ssize_t ret = -EINVAL; | 969 ssize_t ret = -EBUSY; |
969 970 if (!fattr->store) 971 return -EIO; 972 973 /* 974 * cpus_read_trylock() is used here to work around a circular lock 975 * dependency problem with respect to the cpufreq_register_driver(). 976 */ 977 if (!cpus_read_trylock()) 978 return -EBUSY; 979 980 if (cpu_online(policy->cpu)) { 981 down_write(&policy->rwsem); | 970 971 if (!fattr->store) 972 return -EIO; 973 974 /* 975 * cpus_read_trylock() is used here to work around a circular lock 976 * dependency problem with respect to the cpufreq_register_driver(). 977 */ 978 if (!cpus_read_trylock()) 979 return -EBUSY; 980 981 if (cpu_online(policy->cpu)) { 982 down_write(&policy->rwsem); |
982 ret = fattr->store(policy, buf, count); | 983 if (likely(!policy_is_inactive(policy))) 984 ret = fattr->store(policy, buf, count); |
983 up_write(&policy->rwsem); 984 } 985 986 cpus_read_unlock(); 987 988 return ret; 989} 990 --- 539 unchanged lines hidden (view full) --- 1530 pr_debug("initialization complete\n"); 1531 1532 return 0; 1533 1534out_destroy_policy: 1535 for_each_cpu(j, policy->real_cpus) 1536 remove_cpu_dev_symlink(policy, j, get_cpu_device(j)); 1537 | 985 up_write(&policy->rwsem); 986 } 987 988 cpus_read_unlock(); 989 990 return ret; 991} 992 --- 539 unchanged lines hidden (view full) --- 1532 pr_debug("initialization complete\n"); 1533 1534 return 0; 1535 1536out_destroy_policy: 1537 for_each_cpu(j, policy->real_cpus) 1538 remove_cpu_dev_symlink(policy, j, get_cpu_device(j)); 1539 |
1540 cpumask_clear(policy->cpus); |
|
1538 up_write(&policy->rwsem); 1539 1540out_offline_policy: 1541 if (cpufreq_driver->offline) 1542 cpufreq_driver->offline(policy); 1543 1544out_exit_policy: 1545 if (cpufreq_driver->exit) --- 1406 unchanged lines hidden --- | 1541 up_write(&policy->rwsem); 1542 1543out_offline_policy: 1544 if (cpufreq_driver->offline) 1545 cpufreq_driver->offline(policy); 1546 1547out_exit_policy: 1548 if (cpufreq_driver->exit) --- 1406 unchanged lines hidden --- |