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; +} + struct platform_device *ci13xxx_add_device(struct device *dev, struct resource *res, int nres, struct ci13xxx_platform_data *platdata) @@ -339,8 +356,7 @@ struct platform_device *ci13xxx_add_device(struct device *dev, struct platform_device *pdev; int ret; - /* FIXME: find a way to choose id */ - pdev = platform_device_alloc("ci_hdrc", -1); + pdev = platform_device_alloc("ci_hdrc", ci_get_id()); if (!pdev) return ERR_PTR(-ENOMEM); -- 1.7.5.4 -- 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