diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 5e626b12b97e..5efd5550f4ca 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -828,11 +828,8 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
828 | memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); | 828 | memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); |
829 | 829 | ||
830 | /* prepare interface data */ | 830 | /* prepare interface data */ |
831 | policy->kobj.parent = &sys_dev->kobj; | 831 | ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj, |
832 | policy->kobj.ktype = &ktype_cpufreq; | 832 | "cpufreq"); |
833 | kobject_set_name(&policy->kobj, "cpufreq"); | ||
834 | |||
835 | ret = kobject_register(&policy->kobj); | ||
836 | if (ret) { | 833 | if (ret) { |
837 | unlock_policy_rwsem_write(cpu); | 834 | unlock_policy_rwsem_write(cpu); |
838 | goto err_out_driver_exit; | 835 | goto err_out_driver_exit; |
@@ -841,19 +838,25 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
841 | drv_attr = cpufreq_driver->attr; | 838 | drv_attr = cpufreq_driver->attr; |
842 | while ((drv_attr) && (*drv_attr)) { | 839 | while ((drv_attr) && (*drv_attr)) { |
843 | ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); | 840 | ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); |
844 | if (ret) | 841 | if (ret) { |
842 | unlock_policy_rwsem_write(cpu); | ||
845 | goto err_out_driver_exit; | 843 | goto err_out_driver_exit; |
844 | } | ||
846 | drv_attr++; | 845 | drv_attr++; |
847 | } | 846 | } |
848 | if (cpufreq_driver->get){ | 847 | if (cpufreq_driver->get){ |
849 | ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); | 848 | ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); |
850 | if (ret) | 849 | if (ret) { |
850 | unlock_policy_rwsem_write(cpu); | ||
851 | goto err_out_driver_exit; | 851 | goto err_out_driver_exit; |
852 | } | ||
852 | } | 853 | } |
853 | if (cpufreq_driver->target){ | 854 | if (cpufreq_driver->target){ |
854 | ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); | 855 | ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); |
855 | if (ret) | 856 | if (ret) { |
857 | unlock_policy_rwsem_write(cpu); | ||
856 | goto err_out_driver_exit; | 858 | goto err_out_driver_exit; |
859 | } | ||
857 | } | 860 | } |
858 | 861 | ||
859 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 862 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
@@ -896,6 +899,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
896 | goto err_out_unregister; | 899 | goto err_out_unregister; |
897 | } | 900 | } |
898 | 901 | ||
902 | kobject_uevent(&policy->kobj, KOBJ_ADD); | ||
899 | module_put(cpufreq_driver->owner); | 903 | module_put(cpufreq_driver->owner); |
900 | dprintk("initialization complete\n"); | 904 | dprintk("initialization complete\n"); |
901 | cpufreq_debug_enable_ratelimit(); | 905 | cpufreq_debug_enable_ratelimit(); |
@@ -909,7 +913,7 @@ err_out_unregister: | |||
909 | cpufreq_cpu_data[j] = NULL; | 913 | cpufreq_cpu_data[j] = NULL; |
910 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 914 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
911 | 915 | ||
912 | kobject_unregister(&policy->kobj); | 916 | kobject_put(&policy->kobj); |
913 | wait_for_completion(&policy->kobj_unregister); | 917 | wait_for_completion(&policy->kobj_unregister); |
914 | 918 | ||
915 | err_out_driver_exit: | 919 | err_out_driver_exit: |
@@ -1026,8 +1030,6 @@ static int __cpufreq_remove_dev (struct sys_device * sys_dev) | |||
1026 | 1030 | ||
1027 | unlock_policy_rwsem_write(cpu); | 1031 | unlock_policy_rwsem_write(cpu); |
1028 | 1032 | ||
1029 | kobject_unregister(&data->kobj); | ||
1030 | |||
1031 | kobject_put(&data->kobj); | 1033 | kobject_put(&data->kobj); |
1032 | 1034 | ||
1033 | /* we need to make sure that the underlying kobj is actually | 1035 | /* we need to make sure that the underlying kobj is actually |