Re: (EXT) Re: [PATCH mmc-next v2] mmc: allow setting slot index via device tree alias

From: Matthias Schiffer
Date: Tue Aug 25 2020 - 07:24:17 EST


On Tue, 2020-08-25 at 11:39 +0200, Matthias Schiffer wrote:
> On Tue, 2020-08-25 at 11:14 +0200, Ulf Hansson wrote:
> > On Thu, 20 Aug 2020 at 09:59, Matthias Schiffer
> > <matthias.schiffer@xxxxxxxxxxxxxxx> wrote:
> > > +
> > > +static void __init mmc_of_reserve_idx(void)
> > > +{
> > > + int max;
> > > +
> > > + max = of_alias_get_highest_id("mmc");
> >
> > Is calling of_alias_get_highest_id("mmc") costly from an execution
> > point of view?
> >
> > If not, we might as well call it directly from mmc_alloc_host()
> > each
> > time a host is allocated instead, to simplify the code a bit.
>
> It's not particularly costly (it just walks the list of aliases once
> and does a string comparison for each entry), but it does so while
> holding the of_mutex.
>
> Both variants exist in the current kernel: The I2C core stores the
> hightest index in a global variable, while of_alias_get_highest_id()
> is
> called once for each registered SPI controller. I have a slight
> preference for the global variable solution.

Looking at this again, it's pretty much the same as of_alias_get_id().
I'll remove the extra functions and global variable.

Kind regards,
Matthias