static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem);
#define lock_policy_rwsem(mode, cpu) \
-static int lock_policy_rwsem_##mode(int cpu) \
+static void lock_policy_rwsem_##mode(int cpu) \
{ \
struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); \
BUG_ON(!policy); \
down_##mode(&per_cpu(cpu_policy_rwsem, policy->cpu)); \
- \
- return 0; \
}
lock_policy_rwsem(read, cpu);
{
struct cpufreq_policy *policy = to_policy(kobj);
struct freq_attr *fattr = to_attr(attr);
- ssize_t ret = -EINVAL;
+ ssize_t ret;
if (!down_read_trylock(&cpufreq_rwsem))
- goto exit;
+ return -EINVAL;
- if (lock_policy_rwsem_read(policy->cpu) < 0)
- goto up_read;
+ lock_policy_rwsem_read(policy->cpu);
if (fattr->show)
ret = fattr->show(policy, buf);
ret = -EIO;
unlock_policy_rwsem_read(policy->cpu);
-
-up_read:
up_read(&cpufreq_rwsem);
-exit:
+
return ret;
}
if (!down_read_trylock(&cpufreq_rwsem))
goto unlock;
- if (lock_policy_rwsem_write(policy->cpu) < 0)
- goto up_read;
+ lock_policy_rwsem_write(policy->cpu);
if (fattr->store)
ret = fattr->store(policy, buf, count);
unlock_policy_rwsem_write(policy->cpu);
-up_read:
up_read(&cpufreq_rwsem);
unlock:
put_online_cpus();
if (ret) {
pr_err("%s: Failed to move kobj: %d", __func__, ret);
- WARN_ON(lock_policy_rwsem_write(old_cpu));
+ lock_policy_rwsem_write(old_cpu);
cpumask_set_cpu(old_cpu, policy->cpus);
unlock_policy_rwsem_write(old_cpu);
return -EINVAL;
}
- WARN_ON(lock_policy_rwsem_write(cpu));
+ lock_policy_rwsem_write(cpu);
cpus = cpumask_weight(policy->cpus);
if (cpus > 1)
if (!down_read_trylock(&cpufreq_rwsem))
return 0;
- if (unlikely(lock_policy_rwsem_read(cpu)))
- goto out_policy;
+ lock_policy_rwsem_read(cpu);
ret_freq = __cpufreq_get(cpu);
unlock_policy_rwsem_read(cpu);
-
-out_policy:
up_read(&cpufreq_rwsem);
return ret_freq;
{
int ret = -EINVAL;
- if (unlikely(lock_policy_rwsem_write(policy->cpu)))
- goto fail;
+ lock_policy_rwsem_write(policy->cpu);
ret = __cpufreq_driver_target(policy, target_freq, relation);
unlock_policy_rwsem_write(policy->cpu);
-fail:
return ret;
}
EXPORT_SYMBOL_GPL(cpufreq_driver_target);
goto no_policy;
}
- if (unlikely(lock_policy_rwsem_write(cpu))) {
- ret = -EINVAL;
- goto fail;
- }
+ lock_policy_rwsem_write(cpu);
pr_debug("updating policy for CPU %u\n", cpu);
memcpy(&new_policy, policy, sizeof(*policy));
unlock_policy_rwsem_write(cpu);
-fail:
cpufreq_cpu_put(policy);
no_policy:
return ret;