|
|
|
Re: [PATCH 4/4] USB: Chipidea: use simple incremental integter as device id | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
|
On Wed, May 23, 2012 at 05:51:00PM +0800, Richard Zhao wrote:
> On Wed, May 23, 2012 at 05:35:22PM +0800, Richard Zhao wrote:
> > On Wed, May 23, 2012 at 12:24:08PM +0300, Felipe Balbi wrote:
> > > Hi,
> > >
> > > On Wed, May 23, 2012 at 11:13:40AM +0800, Richard Zhao wrote:
> > >
> > > needs commit log
> > ok
> > >
> > > > Signed-off-by: Richard Zhao <richard.zhao@xxxxxxxxxxxxx>
> > > > ---
> > > > drivers/usb/chipidea/core.c | 20 ++++++++++++++++++--
> > > > 1 files changed, 18 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > > > index d645396..767ccf7 100644
> > > > --- a/drivers/usb/chipidea/core.c
> > > > +++ b/drivers/usb/chipidea/core.c
> > > > @@ -332,6 +332,23 @@ static irqreturn_t ci_irq(int irq, void *data)
> > > > return ci->role == CI_ROLE_END ? ret : ci_role(ci)->irq(ci);
> > > > }
> > > >
> > > > +static DEFINE_SPINLOCK(dev_id_lock);
> > > > +static int dev_id;
> > > > +
> > > > +static int ci_get_id(void)
> > > > +{
> > > > + unsigned long flags;
> > > > + int id;
> > > > +
> > > > + spin_lock_irqsave(&dev_id_lock, flags);
> > > > + id = dev_id++;
> > > > + if (dev_id < 0)
> > > > + dev_id = 0;
> > > > + spin_unlock_irqrestore(&dev_id_lock, flags);
> > > > +
> > > > + return id;
> > > > +}
> > >
> > > if you used a bitmap you wouldn't need the lock.
> > but it needs a loop. hmm.. bitmap is better. I'll change
> > that way as dwc3_get_device_id.
> Note that we'll need a ci13xxx_remove_device to put id.
If it supports hotplug, the ids may be like 0 1 2 3 1 0 3 ...
It's bad comparing to incremental method.
>
> Thanks
> Richard
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html

[Linux Media] [Video for Linux] [Linux Input] [Linux Audio Users] [Photo] [Yosemite News] [Yosemite Photos] [Free Online Dating] [Linux Kernel] [Linux SCSI] [Old Linux USB Devel Archive] [More Archives]
![]() |
![]() |