[PATCH v4 01/11] usb: musb: add musb->id to identify core instance

Felipe Balbi balbi at ti.com
Wed Jul 25 17:45:35 EST 2012


Hi,

On Thu, Jul 19, 2012 at 05:15:57PM +0530, Ajay Kumar Gupta wrote:
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 89d1871..3e09984 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,33 @@ 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;
> +}
> +
> +void musb_put_id(struct device *dev, int id)
> +{
> +
> +	dev_dbg(dev, "removing id %d\n", id);
> +	ida_remove(&musb_ida, id);
> +}

both of these should be EXPORT_SYMBOL_GPL() for cases when musb and glue
are compiled as modules.

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/devicetree-discuss/attachments/20120725/92a8126b/attachment.sig>


More information about the devicetree-discuss mailing list