[Sound-open-firmware] [PATCH 10/15] [RFC][v2]DMIC: Add min/max, ceil divide, find number, and normalize utils

Liam Girdwood liam.r.girdwood at linux.intel.com
Mon May 7 17:16:29 CEST 2018


On Mon, 2018-05-07 at 17:12 +0300, Seppo Ingalsuo wrote:
> 
> On 07.05.2018 14:19, Liam Girdwood wrote:
> > On Fri, 2018-05-04 at 18:01 +0300, Seppo Ingalsuo wrote:
> > > +
> > > +/* This is a divide function that returns ceil of the quotient.
> > > + * E.g. ceil_divide(9, 3) returns 3, ceil_divide(10, 3) returns 4.
> > > + */
> > > +int ceil_divide(int a, int b)
> > > +{
> > > +       int c;
> > > +
> > > +       c = a / b;
> > > +       if (c * b < a)
> > > +               c++;
> > > +
> > > +       return c;
> > > +}
> > 
> > This one should be static inline.
> 
> Please reconsider. Due to code size saving I'd not prefer inline code 
> when low benefit. Division should not be used in speed critical code 
> parts so not inlining this shouldn't be an issue in typical usage.
> 
> I didn't yet patch other similar division code parts but e.g. SRC would 
> also use this library function in initialization code.

I'm thinking about the use case when we optimise this with HiFi2/3 (or similar)
CEIL arithmetic. inline means we can optimise it to a few instructions. Btw,
what is the size delta ?

Liam


More information about the Sound-open-firmware mailing list