On Wed, Oct 11, 2017 at 04:14:37AM +0000, Zhi, Yong wrote:
> Hi, Andy,
>
> > -----Original Message-----
> > From: [email protected] [mailto:linux-media-
> > [email protected]] On Behalf Of Andy Shevchenko
> > Sent: Friday, June 16, 2017 3:53 PM
> > To: Zhi, Yong <[email protected]>
> > Cc: Linux Media Mailing List <[email protected]>;
> > [email protected]; Zheng, Jian Xu <[email protected]>;
> > [email protected]; Mani, Rajmohan <[email protected]>;
> > Toivonen, Tuukka <[email protected]>
> > Subject: Re: [PATCH v2 08/12] intel-ipu3: params: compute and program ccs
> >
> > On Thu, Jun 15, 2017 at 1:19 AM, Yong Zhi <[email protected]> wrote:
> > > A collection of routines that are mainly responsible to calculate the
> > > acc parameters.
> >
> > > +static unsigned int ipu3_css_scaler_get_exp(unsigned int counter,
> > > + unsigned int divider) {
> > > + unsigned int i = 0;
> > > +
> > > + while (counter <= divider / 2) {
> > > + divider /= 2;
> > > + i++;
> > > + }
> > > +
> > > + return i;
> >
> > We have a lot of different helpers including one you may use instead of this
> > function.
> >
> > It's *highly* recommended you learn what we have under lib/ (and not only
> > there) in kernel bewfore submitting a new version.
> >
>
> Tried to identify more places that could be re-implemented with lib
> helpers or more generic method, but we failed to spot any obvious
> candidate thus far.
How about:
return (!counter || divider < counter) ?
0 : fls(divider / counter) - 1;
--
Sakari Ailus
[email protected]