public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: peiyong feng <peiyong.feng.kernel@gmail.com>
Cc: Felipe Balbi <balbi@ti.com>, Greg Kroah-Hartman <gregkh@suse.de>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Add name match for UDC and gadget driver. Only for g_ether Signed-off-by: peiyong feng <peiyong.feng.kernel@gmail.com>
Date: Fri, 11 Nov 2011 11:23:00 +0200	[thread overview]
Message-ID: <20111111092259.GC19090@legolas.emea.dhcp.ti.com> (raw)
In-Reply-To: <1320992229-13155-1-git-send-email-peiyong.feng.kernel@gmail.com>

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

Hi,

(a bit of top-posting before commenting on your patch)

this is truly badly formatted. Read Documentation/CodingStyle,
Documentation/SubmittingPatches, and Documentation/SubmitChecklist

On Fri, Nov 11, 2011 at 02:17:09PM +0800, peiyong feng wrote:
> ---
>  drivers/usb/gadget/composite.c |    1 +
>  drivers/usb/gadget/ether.c     |    1 +
>  drivers/usb/gadget/udc-core.c  |   15 +++++++++++++++
>  include/linux/usb/composite.h  |    2 ++
>  include/linux/usb/gadget.h     |    1 +
>  5 files changed, 20 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index f71b078..c1d2507 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -1583,6 +1583,7 @@ int usb_composite_probe(struct usb_composite_driver *driver,
>  	if (!driver->iProduct)
>  		driver->iProduct = driver->name;
>  	composite_driver.function =  (char *) driver->name;
> +	composite_driver.name    = driver->name_udc;
>  	composite_driver.driver.name = driver->name;
>  	composite_driver.speed = min((u8)composite_driver.speed,
>  				     (u8)driver->max_speed);
> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
> index 0cd764d..320b9e2 100644
> --- a/drivers/usb/gadget/ether.c
> +++ b/drivers/usb/gadget/ether.c
> @@ -390,6 +390,7 @@ static int __exit eth_unbind(struct usb_composite_dev *cdev)
>  
>  static struct usb_composite_driver eth_driver = {
>  	.name		= "g_ether",
> +	.name_udc	= CONFIG_UDC_NAME,
>  	.dev		= &device_desc,
>  	.strings	= dev_strings,
>  	.max_speed	= USB_SPEED_SUPER,
> diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
> index 022baec..9a23620 100644
> --- a/drivers/usb/gadget/udc-core.c
> +++ b/drivers/usb/gadget/udc-core.c
> @@ -37,6 +37,7 @@
>   * to hold information about udc driver and gadget together.
>   */
>  struct usb_udc {
> +	char *name;
>  	struct usb_gadget_driver	*driver;
>  	struct usb_gadget		*gadget;
>  	struct device			dev;
> @@ -144,6 +145,13 @@ static void usb_udc_release(struct device *dev)
>  }
>  
>  static const struct attribute_group *usb_udc_attr_groups[];
> +/*set the name of udc*/
> +static void usb_udc_set_name(struct usb_udc *udc,char *name)
> +{
> +	char *tmp = kzalloc(strlen(name)+1);
> +	strcpy(tmp,name);
> +	usb_udc->name = tmp;
> +}
>  /**
>   * usb_add_gadget_udc - adds a new gadget to the udc class driver list
>   * @parent: the parent device to this udc. Usually the controller
> @@ -162,6 +170,7 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
>  		goto err1;
>  
>  	device_initialize(&udc->dev);
> +	usb_udc_set_name(udc,gadget.name);
>  	udc->dev.release = usb_udc_release;
>  	udc->dev.class = udc_class;
>  	udc->dev.groups = usb_udc_attr_groups;
> @@ -269,6 +278,12 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
>  		return -EINVAL;
>  
>  	mutex_lock(&udc_lock);
> +	/*First we get the specific udc*/
> +	list_for_each_entry(udc, &udc_list, list) {
> +		if (strcmp(udc->name,driver->name)==0)
> +			goto found;
> +	}
> +	/*We take the first one that unused*/
>  	list_for_each_entry(udc, &udc_list, list) {
>  		/* For now we take the first one */
>  		if (!udc->driver)
> diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
> index a316fba..029c26d 100644
> --- a/include/linux/usb/composite.h
> +++ b/include/linux/usb/composite.h
> @@ -245,6 +245,7 @@ int usb_add_config(struct usb_composite_dev *,
>  /**
>   * struct usb_composite_driver - groups configurations into a gadget
>   * @name: For diagnostics, identifies the driver.
> + * @name_udc: which UDC this driver attach.
>   * @iProduct: Used as iProduct override if @dev->iProduct is not set.
>   *	If NULL value of @name is taken.
>   * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is
> @@ -278,6 +279,7 @@ int usb_add_config(struct usb_composite_dev *,
>   */
>  struct usb_composite_driver {
>  	const char				*name;
> +	const char 				*name_udc;
>  	const char				*iProduct;
>  	const char				*iManufacturer;
>  	const struct usb_device_descriptor	*dev;
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 1d3a675..e92083f 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -824,6 +824,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
>   */
>  struct usb_gadget_driver {
>  	char			*function;
> +	char 			*name;
>  	enum usb_device_speed	speed;
>  	void			(*unbind)(struct usb_gadget *);
>  	int			(*setup)(struct usb_gadget *,

I truly don't see the point of this patch. You cannot mandate to which
UDC the driver will attach to. In most situations, it will attach to the
only available UDC, if you have a board with more then one peripheral
port, then we need a better way of doing this. Something which won't
affect anybody else.

$SUBJECT can't be applied, sorry.

-- 
balbi

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

      reply	other threads:[~2011-11-11  9:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11  6:17 [PATCH] Add name match for UDC and gadget driver. Only for g_ether Signed-off-by: peiyong feng <peiyong.feng.kernel@gmail.com> peiyong feng
2011-11-11  9:23 ` Felipe Balbi [this message]

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=20111111092259.GC19090@legolas.emea.dhcp.ti.com \
    --to=balbi@ti.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peiyong.feng.kernel@gmail.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