+
+ wanted_speed = t->bus_freq_hz;
+
+ /* For unsupported speeds, scale down the lowest speed which is faster. */
+ for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) {
+ /* supported speeds is in decreasing order */
+ if (wanted_speed == supported_speeds[i]) {
+ legal_speed = 0;
+ break;
+ }
+ if (wanted_speed > supported_speeds[i])
+ break;
+
+ legal_speed = supported_speeds[i];
+ }
+
+ if (legal_speed) {
+ /*
+ * Pretend this was the requested speed, but preserve the preferred
+ * speed so the clock counts can be scaled.
+ */
+ t->bus_freq_hz = legal_speed;
+ dev->wanted_bus_speed = wanted_speed;
+ }