@@ -126,36 +126,32 @@ struct omap_opp *opp_find_freq_ceil(struct omap_opp *oppl, unsigned long *freq)
struct omap_opp *opp_find_freq_floor(struct omap_opp *oppl, unsigned long *freq)
{
+ struct omap_opp *prev_opp = oppl;
+
if (unlikely(!oppl || IS_ERR(oppl) || !freq || IS_ERR(freq))) {
pr_err("%s: Invalid parameters being passed\n", __func__);
return ERR_PTR(-EINVAL);
}
/* skip initial terminator */
- if (OPP_TERM(oppl)) {
+ if (OPP_TERM(oppl))
oppl++;
- /* If searching init list for a high val, skip to very top */
- /*
- * XXX What is the point of this? If one is going to traverse
- * the list, might as well do what we need to do during the
- * traversal.
- */
- while (!OPP_TERM(oppl)) /* XXX above */
- oppl++;
- }
- while (!OPP_TERM(--oppl)) {
- if (!oppl->enabled)
- continue;
+ while (!OPP_TERM(oppl)) {
+ if (oppl->enabled) {
+ if (oppl->rate > *freq)
+ break;
- if (oppl->rate <= *freq)
- break;
+ prev_opp = oppl;
+ }
+
+ oppl++;
}
- if (OPP_TERM(oppl))
+ if (prev_opp->rate > *freq)
return ERR_PTR(-ENOENT);
- *freq = oppl->rate;
+ *freq = prev_opp->rate;
return oppl;
}