Re: [PATCH v3] media: intel/ipu6: Improve DWC PHY HSFREQRANGE band selection for overlapping ranges
From: Marco Nenciarini
Date: Thu Apr 02 2026 - 05:46:12 EST
On 02-Apr-26 11:54, Andy Shevchenko wrote:
> Below just a couple of remarks, no need to be addressed, JFYI.
Thanks for the review.
> > + if (mbps > freqranges[i].max)
> > + continue;
> > +
> > + if (mbps < freqranges[i].min)
> > + break;
>
> Wondering if this can use bsearch() algo or any linear ranges.
The overlapping ranges and the multi-criteria selection (osc_freq_target
first, then closest default_mbps) make it hard to fit into a single
comparator. The forward scan with early break seemed like the most
straightforward approach.
> > + abs((int)mbps - (int)freqranges[i].default_mbps) <
> > + abs((int)mbps - (int)freqranges[best].default_mbps)))
>
> Note, abs(INT_MIN) is UB, I hope this won't be the case IRL in this code.
Good point. The values here are well within range, but an unsigned
abs_diff() helper would be cleaner. I will address it if a v4 is needed
for other reasons.
Marco