Fix a few edge cases with error handling in cpufreq(4)'s CPUFREQ_GET()

method:
- If the last of the child cpufreq drivers returns an error while trying to
  fetch its list of supported frequencies but an earlier driver found the
  requested frequency, don't return an error to the caller.
- If all of the child cpufreq drivers fail and the attempt to match the
  frequency based on 'cpu_est_clockrate()' fails, return ENXIO rather than
  returning success and returning a frequency of CPUFREQ_VAL_UNKNOWN.

MFC after:	3 days
PR:		kern/121433
Reported by:	Eugene Grosbein  eugen ! kuzbass dot ru
This commit is contained in:
jhb 2008-05-05 19:13:52 +00:00
parent 2ad219aa54
commit 4fb93663e6

View File

@ -452,8 +452,7 @@ cf_get_method(device_t dev, struct cf_level *level)
for (n = 0; n < numdevs && curr_set->freq == CPUFREQ_VAL_UNKNOWN; n++) {
if (!device_is_attached(devs[n]))
continue;
error = CPUFREQ_DRV_GET(devs[n], &set);
if (error)
if (CPUFREQ_DRV_GET(devs[n], &set) != 0)
continue;
for (i = 0; i < count; i++) {
if (CPUFREQ_CMP(set.freq, levels[i].total_set.freq)) {
@ -483,9 +482,10 @@ cf_get_method(device_t dev, struct cf_level *level)
if (CPUFREQ_CMP(rate, levels[i].total_set.freq)) {
sc->curr_level = levels[i];
CF_DEBUG("get estimated freq %d\n", curr_set->freq);
break;
goto out;
}
}
error = ENXIO;
out:
if (error == 0)