Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: Drop unnecessary checks from show() and store()

The show() and store() routines in the cpufreq core don't need to
check if the struct freq_attr they want to use really provides the
callbacks they need as expected (if that's not the case, it means
a bug in the code anyway), so change them to avoid doing that.

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

+5 -16
+5 -16
drivers/cpufreq/cpufreq.c
··· 818 818 ssize_t ret; 819 819 820 820 down_read(&policy->rwsem); 821 - 822 - if (fattr->show) 823 - ret = fattr->show(policy, buf); 824 - else 825 - ret = -EIO; 826 - 821 + ret = fattr->show(policy, buf); 827 822 up_read(&policy->rwsem); 828 823 829 824 return ret; ··· 833 838 834 839 get_online_cpus(); 835 840 836 - if (!cpu_online(policy->cpu)) 837 - goto unlock; 838 - 839 - down_write(&policy->rwsem); 840 - 841 - if (fattr->store) 841 + if (cpu_online(policy->cpu)) { 842 + down_write(&policy->rwsem); 842 843 ret = fattr->store(policy, buf, count); 843 - else 844 - ret = -EIO; 844 + up_write(&policy->rwsem); 845 + } 845 846 846 - up_write(&policy->rwsem); 847 - unlock: 848 847 put_online_cpus(); 849 848 850 849 return ret;