Hi, On Wed, May 23, 2012 at 11:13:40AM +0800, Richard Zhao wrote: needs commit log > 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. -- balbi
Attachment:
signature.asc
Description: Digital signature