public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Felipe Balbi <balbi@ti.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Arnd Bergmann <arnd@arndb.de>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Subject: Re: [PATCH 12/12] usb: gadget: at91_udc: Allocate udc instance
Date: Wed, 14 Jan 2015 11:39:06 -0600	[thread overview]
Message-ID: <20150114173906.GL16533@saruman> (raw)
In-Reply-To: <1421252524-24452-13-git-send-email-alexandre.belloni@free-electrons.com>

[-- Attachment #1: Type: text/plain, Size: 3801 bytes --]

On Wed, Jan 14, 2015 at 05:22:04PM +0100, Alexandre Belloni wrote:
> From: Boris Brezillon <boris.brezillon@free-electrons.com>
> 
> Allocate udc structure instead of relying on the statically declared
> object.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Acked-by: Felipe Balbi <balbi@ti.com>

> ---
>  drivers/usb/gadget/udc/at91_udc.c | 96 +++++++++++----------------------------
>  1 file changed, 26 insertions(+), 70 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
> index c0abb9bc76a9..6d285226ab94 100644
> --- a/drivers/usb/gadget/udc/at91_udc.c
> +++ b/drivers/usb/gadget/udc/at91_udc.c
> @@ -59,7 +59,15 @@
>  #define	DRIVER_VERSION	"3 May 2006"
>  
>  static const char driver_name [] = "at91_udc";
> -static const char ep0name[] = "ep0";
> +static const char * const ep_names[] = {
> +	"ep0",
> +	"ep1",
> +	"ep2",
> +	"ep3-int",
> +	"ep4",
> +	"ep5",
> +};
> +#define ep0name		ep_names[0]
>  
>  #define VBUS_POLL_TIMEOUT	msecs_to_jiffies(1000)
>  
> @@ -1497,74 +1505,6 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
>  
>  /*-------------------------------------------------------------------------*/
>  
> -static struct at91_udc controller = {
> -	.gadget = {
> -		.ops	= &at91_udc_ops,
> -		.ep0	= &controller.ep[0].ep,
> -		.name	= driver_name,
> -	},
> -	.ep[0] = {
> -		.ep = {
> -			.name	= ep0name,
> -			.ops	= &at91_ep_ops,
> -		},
> -		.udc		= &controller,
> -		.maxpacket	= 8,
> -		.int_mask	= 1 << 0,
> -	},
> -	.ep[1] = {
> -		.ep = {
> -			.name	= "ep1",
> -			.ops	= &at91_ep_ops,
> -		},
> -		.udc		= &controller,
> -		.is_pingpong	= 1,
> -		.maxpacket	= 64,
> -		.int_mask	= 1 << 1,
> -	},
> -	.ep[2] = {
> -		.ep = {
> -			.name	= "ep2",
> -			.ops	= &at91_ep_ops,
> -		},
> -		.udc		= &controller,
> -		.is_pingpong	= 1,
> -		.maxpacket	= 64,
> -		.int_mask	= 1 << 2,
> -	},
> -	.ep[3] = {
> -		.ep = {
> -			/* could actually do bulk too */
> -			.name	= "ep3-int",
> -			.ops	= &at91_ep_ops,
> -		},
> -		.udc		= &controller,
> -		.maxpacket	= 8,
> -		.int_mask	= 1 << 3,
> -	},
> -	.ep[4] = {
> -		.ep = {
> -			.name	= "ep4",
> -			.ops	= &at91_ep_ops,
> -		},
> -		.udc		= &controller,
> -		.is_pingpong	= 1,
> -		.maxpacket	= 256,
> -		.int_mask	= 1 << 4,
> -	},
> -	.ep[5] = {
> -		.ep = {
> -			.name	= "ep5",
> -			.ops	= &at91_ep_ops,
> -		},
> -		.udc		= &controller,
> -		.is_pingpong	= 1,
> -		.maxpacket	= 256,
> -		.int_mask	= 1 << 5,
> -	},
> -	/* ep6 and ep7 are also reserved (custom silicon might use them) */
> -};
> -
>  static void at91_vbus_update(struct at91_udc *udc, unsigned value)
>  {
>  	value ^= udc->board.vbus_active_low;
> @@ -1872,15 +1812,31 @@ static int at91udc_probe(struct platform_device *pdev)
>  	struct at91_ep	*ep;
>  	int		i;
>  
> +	udc = devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL);
> +	if (!udc)
> +		return -ENOMEM;
> +
>  	/* init software state */
> -	udc = &controller;
>  	udc->gadget.dev.parent = dev;
>  	at91udc_of_init(udc, pdev->dev.of_node);
>  	udc->pdev = pdev;
>  	udc->enabled = 0;
>  	spin_lock_init(&udc->lock);
>  
> +	udc->gadget.ops = &at91_udc_ops;
> +	udc->gadget.ep0 = &udc->ep[0].ep;
> +	udc->gadget.name = driver_name;
> +	udc->gadget.dev.init_name = "gadget";
>  
> +	for (i = 0; i < NUM_ENDPOINTS; i++) {
> +		ep = &udc->ep[i];
> +		ep->ep.name = ep_names[i];
> +		ep->ep.ops = &at91_ep_ops;
> +		ep->udc = udc;
> +		ep->int_mask = BIT(i);
> +		if (i != 0 && i != 3)
> +			ep->is_pingpong = 1;
> +	}
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	udc->udp_baseaddr = devm_ioremap_resource(dev, res);
> -- 
> 2.1.0
> 

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-01-14 17:40 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14 16:21 [PATCH 00/12] Atmel matrix, SMC and UDC rework Alexandre Belloni
2015-01-14 16:21 ` [PATCH 01/12] mfd: syscon: Add atmel-matrix registers definition Alexandre Belloni
2015-01-18 12:52   ` Lee Jones
2015-01-18 13:11     ` Boris Brezillon
2015-01-19  8:16       ` Lee Jones
2015-01-14 16:21 ` [PATCH 02/12] mfd: syscon: Add Atmel Matrix bus DT binding documentation Alexandre Belloni
2015-01-18 12:53   ` Lee Jones
2015-01-14 16:21 ` [PATCH 03/12] mfd: syscon: Add atmel-smc registers definition Alexandre Belloni
2015-01-18 12:53   ` Lee Jones
2015-01-14 16:21 ` [PATCH 04/12] mfd: syscon: Add Atmel SMC binding doc Alexandre Belloni
2015-01-18 12:54   ` Lee Jones
2015-01-14 16:21 ` [PATCH 05/12] usb: gadget: at91_udc: Fix clock names Alexandre Belloni
2015-01-14 17:37   ` Felipe Balbi
2015-01-14 16:21 ` [PATCH 06/12] usb: gadget: at91_udc: Drop uclk clock Alexandre Belloni
2015-01-14 17:37   ` Felipe Balbi
2015-01-14 16:21 ` [PATCH 07/12] usb: gadget: at91_udc: Document DT clocks and clock-names property Alexandre Belloni
2015-01-14 16:22 ` [PATCH 08/12] usb: gadget: at91_udc: Remove non-DT handling code Alexandre Belloni
2015-01-14 17:38   ` Felipe Balbi
2015-01-14 18:35     ` Alexandre Belloni
2015-01-14 18:39       ` Felipe Balbi
2015-01-14 16:22 ` [PATCH 09/12] usb: gadget: at91_udc: Simplify probe and remove functions Alexandre Belloni
2015-01-14 17:38   ` Felipe Balbi
2015-01-14 16:22 ` [PATCH 10/12] usb: gadget: at91_udc: Rework for multi-platform kernel support Alexandre Belloni
2015-01-14 17:38   ` Felipe Balbi
2015-01-14 16:22 ` [PATCH 11/12] usb: gadget: at91_udc: Update DT binding documentation Alexandre Belloni
2015-01-14 16:22 ` [PATCH 12/12] usb: gadget: at91_udc: Allocate udc instance Alexandre Belloni
2015-01-14 17:39   ` Felipe Balbi [this message]
2015-01-15 13:30 ` [PATCH 00/12] Atmel matrix, SMC and UDC rework Nicolas Ferre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150114173906.GL16533@saruman \
    --to=balbi@ti.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=arnd@arndb.de \
    --cc=boris.brezillon@free-electrons.com \
    --cc=jjhiblot@traphandler.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox