Commit 914f7c31 authored by Jeff Garzik's avatar Jeff Garzik Committed by Dave Jones

[CPUFREQ] handle sysfs errors

Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 95dd7227
...@@ -453,6 +453,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -453,6 +453,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
unsigned int cpu = policy->cpu; unsigned int cpu = policy->cpu;
struct cpu_dbs_info_s *this_dbs_info; struct cpu_dbs_info_s *this_dbs_info;
unsigned int j; unsigned int j;
int rc;
this_dbs_info = &per_cpu(cpu_dbs_info, cpu); this_dbs_info = &per_cpu(cpu_dbs_info, cpu);
...@@ -469,6 +470,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -469,6 +470,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
break; break;
mutex_lock(&dbs_mutex); mutex_lock(&dbs_mutex);
rc = sysfs_create_group(&policy->kobj, &dbs_attr_group);
if (rc) {
mutex_unlock(&dbs_mutex);
return rc;
}
for_each_cpu_mask(j, policy->cpus) { for_each_cpu_mask(j, policy->cpus) {
struct cpu_dbs_info_s *j_dbs_info; struct cpu_dbs_info_s *j_dbs_info;
j_dbs_info = &per_cpu(cpu_dbs_info, j); j_dbs_info = &per_cpu(cpu_dbs_info, j);
...@@ -481,7 +489,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -481,7 +489,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
this_dbs_info->enable = 1; this_dbs_info->enable = 1;
this_dbs_info->down_skip = 0; this_dbs_info->down_skip = 0;
this_dbs_info->requested_freq = policy->cur; this_dbs_info->requested_freq = policy->cur;
sysfs_create_group(&policy->kobj, &dbs_attr_group);
dbs_enable++; dbs_enable++;
/* /*
* Start the timerschedule work, when this governor * Start the timerschedule work, when this governor
......
...@@ -473,6 +473,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -473,6 +473,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
unsigned int cpu = policy->cpu; unsigned int cpu = policy->cpu;
struct cpu_dbs_info_s *this_dbs_info; struct cpu_dbs_info_s *this_dbs_info;
unsigned int j; unsigned int j;
int rc;
this_dbs_info = &per_cpu(cpu_dbs_info, cpu); this_dbs_info = &per_cpu(cpu_dbs_info, cpu);
...@@ -501,6 +502,16 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -501,6 +502,16 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
return -ENOSPC; return -ENOSPC;
} }
} }
rc = sysfs_create_group(&policy->kobj, &dbs_attr_group);
if (rc) {
if (dbs_enable == 1)
destroy_workqueue(kondemand_wq);
dbs_enable--;
mutex_unlock(&dbs_mutex);
return rc;
}
for_each_cpu_mask(j, policy->cpus) { for_each_cpu_mask(j, policy->cpus) {
struct cpu_dbs_info_s *j_dbs_info; struct cpu_dbs_info_s *j_dbs_info;
j_dbs_info = &per_cpu(cpu_dbs_info, j); j_dbs_info = &per_cpu(cpu_dbs_info, j);
...@@ -510,7 +521,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -510,7 +521,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
j_dbs_info->prev_cpu_wall = get_jiffies_64(); j_dbs_info->prev_cpu_wall = get_jiffies_64();
} }
this_dbs_info->enable = 1; this_dbs_info->enable = 1;
sysfs_create_group(&policy->kobj, &dbs_attr_group);
/* /*
* Start the timerschedule work, when this governor * Start the timerschedule work, when this governor
* is used for first time * is used for first time
......
...@@ -131,19 +131,26 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, ...@@ -131,19 +131,26 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
unsigned int event) unsigned int event)
{ {
unsigned int cpu = policy->cpu; unsigned int cpu = policy->cpu;
int rc = 0;
switch (event) { switch (event) {
case CPUFREQ_GOV_START: case CPUFREQ_GOV_START:
if (!cpu_online(cpu)) if (!cpu_online(cpu))
return -EINVAL; return -EINVAL;
BUG_ON(!policy->cur); BUG_ON(!policy->cur);
mutex_lock(&userspace_mutex); mutex_lock(&userspace_mutex);
rc = sysfs_create_file (&policy->kobj,
&freq_attr_scaling_setspeed.attr);
if (rc)
goto start_out;
cpu_is_managed[cpu] = 1; cpu_is_managed[cpu] = 1;
cpu_min_freq[cpu] = policy->min; cpu_min_freq[cpu] = policy->min;
cpu_max_freq[cpu] = policy->max; cpu_max_freq[cpu] = policy->max;
cpu_cur_freq[cpu] = policy->cur; cpu_cur_freq[cpu] = policy->cur;
cpu_set_freq[cpu] = policy->cur; cpu_set_freq[cpu] = policy->cur;
sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]); dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]);
start_out:
mutex_unlock(&userspace_mutex); mutex_unlock(&userspace_mutex);
break; break;
case CPUFREQ_GOV_STOP: case CPUFREQ_GOV_STOP:
...@@ -180,7 +187,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, ...@@ -180,7 +187,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
mutex_unlock(&userspace_mutex); mutex_unlock(&userspace_mutex);
break; break;
} }
return 0; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment