diff options
author | B, Ravi <ravibabu@ti.com> | 2012-08-31 11:09:49 +0000 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-09-11 17:34:41 +0300 |
commit | 65b3d52d02a558fbfe08e43688e15390c5ab3067 (patch) | |
tree | 0082a0e45c26ff015a7b0976e917c83d87db8e70 /drivers/usb/musb/musb_core.c | |
parent | 00a0b1d58af873d842580dcac55f3b156c3a4077 (diff) |
usb: musb: add musb_ida for multi instance support
Added musb_ida in musb_core.c to manage the multi core ids.
Signed-off-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Santhapuri, Damodar <damodar.santhapuri@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/musb_core.c')
-rw-r--r-- | drivers/usb/musb/musb_core.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 5cacccbc39b..61b64fced25 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -99,6 +99,7 @@ #include <linux/prefetch.h> #include <linux/platform_device.h> #include <linux/io.h> +#include <linux/idr.h> #include "musb_core.h" @@ -114,6 +115,7 @@ #define MUSB_DRIVER_NAME "musb-hdrc" const char musb_driver_name[] = MUSB_DRIVER_NAME; +static DEFINE_IDA(musb_ida); MODULE_DESCRIPTION(DRIVER_INFO); MODULE_AUTHOR(DRIVER_AUTHOR); @@ -130,6 +132,35 @@ static inline struct musb *dev_to_musb(struct device *dev) /*-------------------------------------------------------------------------*/ +int musb_get_id(struct device *dev, gfp_t gfp_mask) +{ + int ret; + int id; + + ret = ida_pre_get(&musb_ida, gfp_mask); + if (!ret) { + dev_err(dev, "failed to reserve resource for id\n"); + return -ENOMEM; + } + + ret = ida_get_new(&musb_ida, &id); + if (ret < 0) { + dev_err(dev, "failed to allocate a new id\n"); + return ret; + } + + return id; +} +EXPORT_SYMBOL_GPL(musb_get_id); + +void musb_put_id(struct device *dev, int id) +{ + + dev_dbg(dev, "removing id %d\n", id); + ida_remove(&musb_ida, id); +} +EXPORT_SYMBOL_GPL(musb_put_id); + #ifndef CONFIG_BLACKFIN static int musb_ulpi_read(struct usb_phy *phy, u32 offset) { |