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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:
> > > --- a/drivers/mmc/core/host.c
> > > +++ b/drivers/mmc/core/host.c
> > > @@ -387,6 +387,7 @@ struct mmc_host *mmc_alloc_host(int extra,
> > > struct device *dev)
> > >  {
> > >         int err;
> > >         struct mmc_host *host;
> > > +       int alias_id, min_idx, max_idx;
> > > 
> > >         host = kzalloc(sizeof(struct mmc_host) + extra,
> > > GFP_KERNEL);
> > >         if (!host)
> > > @@ -395,7 +396,18 @@ struct mmc_host *mmc_alloc_host(int extra,
> > > struct device *dev)
> > >         /* scanning will be enabled when we're ready */
> > >         host->rescan_disable = 1;
> > > 
> > > -       err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL);
> > > +       host->parent = dev;
> > > +
> > > +       alias_id = mmc_get_reserved_index(host);
> > > +       if (alias_id >= 0) {
> > > +               min_idx = alias_id;
> > > +               max_idx = alias_id + 1;
> > > +       } else {
> > > +               min_idx = mmc_first_nonreserved_index();
> > > +               max_idx = 0;
> > > +       }
> > > +
> > > +       err = ida_simple_get(&mmc_host_ida, min_idx, max_idx,
> > > GFP_KERNEL);


One more question I came across when reworking my patch: Do we need a
fallback here for the case where the reserved index is already taken?
To handle an SD card being replaced while still mounted?


> > >         if (err < 0) {
> > >                 kfree(host);
> > >                 return NULL;
> > > @@ -406,7 +418,6 @@ struct mmc_host *mmc_alloc_host(int extra,
> > > struct device *dev)
> > >         dev_set_name(&host->class_dev, "mmc%d", host->index);
> > >         host->ws = wakeup_source_register(NULL, dev_name(&host-
> > > > class_dev));
> > > 
> > > -       host->parent = dev;
> > >         host->class_dev.parent = dev;
> > >         host->class_dev.class = &mmc_host_class;
> > >         device_initialize(&host->class_dev);
> > > --
> > > 2.17.1
> > > 
> > 
> > Kind regards
> > Uffe




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux