Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102168994
D41762.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
985 B
Referenced Files
None
Subscribers
None
D41762.diff
View Options
diff --git a/sys/dev/cpufreq/cpufreq_dt.c b/sys/dev/cpufreq/cpufreq_dt.c
--- a/sys/dev/cpufreq/cpufreq_dt.c
+++ b/sys/dev/cpufreq/cpufreq_dt.c
@@ -104,17 +104,26 @@
cpufreq_dt_find_opp(device_t dev, uint64_t freq)
{
struct cpufreq_dt_softc *sc;
- ssize_t n;
+ uint64_t diff, best_diff;
+ ssize_t n, best_n;
sc = device_get_softc(dev);
+ diff = 0;
+ best_diff = ~0;
DPRINTF(dev, "Looking for freq %ju\n", freq);
- for (n = 0; n < sc->nopp; n++)
- if (CPUFREQ_CMP(sc->opp[n].freq, freq))
- return (&sc->opp[n]);
+ for (n = 0; n < sc->nopp; n++) {
+ diff = abs64((int64_t)sc->opp[n].freq - (int64_t)freq);
+ DPRINTF(dev, "Testing %ju, diff is %ju\n", sc->opp[n].freq, diff);
+ if (diff < best_diff) {
+ best_diff = diff;
+ best_n = n;
+ DPRINTF(dev, "%ju is best for now\n", sc->opp[n].freq);
+ }
+ }
- DPRINTF(dev, "Couldn't find one\n");
- return (NULL);
+ DPRINTF(dev, "Will use %ju\n", sc->opp[best_n].freq);
+ return (&sc->opp[best_n]);
}
static void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 11:23 AM (17 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14558087
Default Alt Text
D41762.diff (985 B)
Attached To
Mode
D41762: cpufreq_dt: Find the closest frequency
Attached
Detach File
Event Timeline
Log In to Comment