cpumask: alloc zeroed cpumask for static cpumask_var_ts
[safe/jmp/linux-2.6] / drivers / cpufreq / cpufreq.c
index 1867dac..6e2ec0b 100644 (file)
@@ -452,6 +452,7 @@ static ssize_t show_##file_name                             \
 
 show_one(cpuinfo_min_freq, cpuinfo.min_freq);
 show_one(cpuinfo_max_freq, cpuinfo.max_freq);
+show_one(cpuinfo_transition_latency, cpuinfo.transition_latency);
 show_one(scaling_min_freq, min);
 show_one(scaling_max_freq, max);
 show_one(scaling_cur_freq, cur);
@@ -659,6 +660,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
 define_one_ro0400(cpuinfo_cur_freq);
 define_one_ro(cpuinfo_min_freq);
 define_one_ro(cpuinfo_max_freq);
+define_one_ro(cpuinfo_transition_latency);
 define_one_ro(scaling_available_governors);
 define_one_ro(scaling_driver);
 define_one_ro(scaling_cur_freq);
@@ -672,6 +674,7 @@ define_one_rw(scaling_setspeed);
 static struct attribute *default_attrs[] = {
        &cpuinfo_min_freq.attr,
        &cpuinfo_max_freq.attr,
+       &cpuinfo_transition_latency.attr,
        &scaling_min_freq.attr,
        &scaling_max_freq.attr,
        &affected_cpus.attr,
@@ -753,11 +756,6 @@ static struct kobj_type ktype_cpufreq = {
        .release        = cpufreq_sysfs_release,
 };
 
-static struct kobj_type ktype_empty_cpufreq = {
-       .sysfs_ops      = &sysfs_ops,
-       .release        = cpufreq_sysfs_release,
-};
-
 
 /**
  * cpufreq_add_dev - add a CPU device
@@ -810,7 +808,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
                ret = -ENOMEM;
                goto nomem_out;
        }
-       if (!alloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) {
+       if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) {
                free_cpumask_var(policy->cpus);
                kfree(policy);
                ret = -ENOMEM;
@@ -891,36 +889,26 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
        memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
 
        /* prepare interface data */
-       if (!cpufreq_driver->hide_interface) {
-               ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
-                                          &sys_dev->kobj, "cpufreq");
+       ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj,
+                                  "cpufreq");
+       if (ret)
+               goto err_out_driver_exit;
+
+       /* set up files for this cpu device */
+       drv_attr = cpufreq_driver->attr;
+       while ((drv_attr) && (*drv_attr)) {
+               ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
                if (ret)
                        goto err_out_driver_exit;
-
-               /* set up files for this cpu device */
-               drv_attr = cpufreq_driver->attr;
-               while ((drv_attr) && (*drv_attr)) {
-                       ret = sysfs_create_file(&policy->kobj,
-                                               &((*drv_attr)->attr));
-                       if (ret)
-                               goto err_out_driver_exit;
-                       drv_attr++;
-               }
-               if (cpufreq_driver->get) {
-                       ret = sysfs_create_file(&policy->kobj,
-                                               &cpuinfo_cur_freq.attr);
-                       if (ret)
-                               goto err_out_driver_exit;
-               }
-               if (cpufreq_driver->target) {
-                       ret = sysfs_create_file(&policy->kobj,
-                                               &scaling_cur_freq.attr);
-                       if (ret)
-                               goto err_out_driver_exit;
-               }
-       } else {
-               ret = kobject_init_and_add(&policy->kobj, &ktype_empty_cpufreq,
-                                          &sys_dev->kobj, "cpufreq");
+               drv_attr++;
+       }
+       if (cpufreq_driver->get) {
+               ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr);
+               if (ret)
+                       goto err_out_driver_exit;
+       }
+       if (cpufreq_driver->target) {
+               ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
                if (ret)
                        goto err_out_driver_exit;
        }
@@ -1082,11 +1070,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
        spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
 #endif
 
+       unlock_policy_rwsem_write(cpu);
+
        if (cpufreq_driver->target)
                __cpufreq_governor(data, CPUFREQ_GOV_STOP);
 
-       unlock_policy_rwsem_write(cpu);
-
        kobject_put(&data->kobj);
 
        /* we need to make sure that the underlying kobj is actually