aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2008-03-05 14:07:34 -0500
committerDave Jones <davej@redhat.com>2008-04-28 15:05:42 -0400
commit457091181176643787a547dc04eb3cf5dcd822ce (patch)
tree4e9e5434960137470cd39348cef4dbc73d7675d8 /drivers/cpufreq
parent905d77cd95e856b8e0b2d099fb70b9b8ccb7337e (diff)
[CPUFREQ] Refactor locking in cpufreq_add_dev
Simplify this by moving the unlocking out of the error paths into the exit path. Signed-off-by: Dave Jones <davej@codemonkey.org.uk>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/cpufreq.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0f10ce21d87..be78c07f72c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -799,7 +799,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
799 ret = cpufreq_driver->init(policy); 799 ret = cpufreq_driver->init(policy);
800 if (ret) { 800 if (ret) {
801 dprintk("initialization failed\n"); 801 dprintk("initialization failed\n");
802 unlock_policy_rwsem_write(cpu);
803 goto err_out; 802 goto err_out;
804 } 803 }
805 policy->user_policy.min = policy->cpuinfo.min_freq; 804 policy->user_policy.min = policy->cpuinfo.min_freq;
@@ -822,7 +821,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
822 /* check for existing affected CPUs. They may not be aware 821 /* check for existing affected CPUs. They may not be aware
823 * of it due to CPU Hotplug. 822 * of it due to CPU Hotplug.
824 */ 823 */
825 managed_policy = cpufreq_cpu_get(j); 824 managed_policy = cpufreq_cpu_get(j); // FIXME: Where is this released? What about error paths?
826 if (unlikely(managed_policy)) { 825 if (unlikely(managed_policy)) {
827 826
828 /* Set proper policy_cpu */ 827 /* Set proper policy_cpu */
@@ -841,14 +840,11 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
841 ret = sysfs_create_link(&sys_dev->kobj, 840 ret = sysfs_create_link(&sys_dev->kobj,
842 &managed_policy->kobj, 841 &managed_policy->kobj,
843 "cpufreq"); 842 "cpufreq");
844 if (ret) { 843 if (ret)
845 unlock_policy_rwsem_write(cpu);
846 goto err_out_driver_exit; 844 goto err_out_driver_exit;
847 }
848 845
849 cpufreq_debug_enable_ratelimit(); 846 cpufreq_debug_enable_ratelimit();
850 ret = 0; 847 ret = 0;
851 unlock_policy_rwsem_write(cpu);
852 goto err_out_driver_exit; /* call driver->exit() */ 848 goto err_out_driver_exit; /* call driver->exit() */
853 } 849 }
854 } 850 }
@@ -858,33 +854,26 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
858 /* prepare interface data */ 854 /* prepare interface data */
859 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj, 855 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj,
860 "cpufreq"); 856 "cpufreq");
861 if (ret) { 857 if (ret)
862 unlock_policy_rwsem_write(cpu);
863 goto err_out_driver_exit; 858 goto err_out_driver_exit;
864 } 859
865 /* set up files for this cpu device */ 860 /* set up files for this cpu device */
866 drv_attr = cpufreq_driver->attr; 861 drv_attr = cpufreq_driver->attr;
867 while ((drv_attr) && (*drv_attr)) { 862 while ((drv_attr) && (*drv_attr)) {
868 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); 863 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
869 if (ret) { 864 if (ret)
870 unlock_policy_rwsem_write(cpu);
871 goto err_out_driver_exit; 865 goto err_out_driver_exit;
872 }
873 drv_attr++; 866 drv_attr++;
874 } 867 }
875 if (cpufreq_driver->get){ 868 if (cpufreq_driver->get) {
876 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); 869 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr);
877 if (ret) { 870 if (ret)
878 unlock_policy_rwsem_write(cpu);
879 goto err_out_driver_exit; 871 goto err_out_driver_exit;
880 }
881 } 872 }
882 if (cpufreq_driver->target){ 873 if (cpufreq_driver->target) {
883 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); 874 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
884 if (ret) { 875 if (ret)
885 unlock_policy_rwsem_write(cpu);
886 goto err_out_driver_exit; 876 goto err_out_driver_exit;
887 }
888 } 877 }
889 878
890 spin_lock_irqsave(&cpufreq_driver_lock, flags); 879 spin_lock_irqsave(&cpufreq_driver_lock, flags);
@@ -906,10 +895,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
906 cpu_sys_dev = get_cpu_sysdev(j); 895 cpu_sys_dev = get_cpu_sysdev(j);
907 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, 896 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
908 "cpufreq"); 897 "cpufreq");
909 if (ret) { 898 if (ret)
910 unlock_policy_rwsem_write(cpu);
911 goto err_out_unregister; 899 goto err_out_unregister;
912 }
913 } 900 }
914 901
915 policy->governor = NULL; /* to assure that the starting sequence is 902 policy->governor = NULL; /* to assure that the starting sequence is
@@ -949,6 +936,7 @@ err_out_driver_exit:
949 cpufreq_driver->exit(policy); 936 cpufreq_driver->exit(policy);
950 937
951err_out: 938err_out:
939 unlock_policy_rwsem_write(cpu);
952 kfree(policy); 940 kfree(policy);
953 941
954nomem_out: 942nomem_out: