All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Robert Lukassen <Robert.Lukassen@tomtom.com>
Cc: Jef Driesen <jefdriesen@telenet.be>,
	David Brownell <dbrownell@users.sourceforge.net>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: g_serial: Allow to override the default VID/PID
Date: Tue, 30 Nov 2010 09:46:05 -0800	[thread overview]
Message-ID: <20101130174605.GC19977@kroah.com> (raw)
In-Reply-To: <D6DB9C7EDECDA944B870F62B587008622C8A42@NL-EXC-06.intra.local>

On Mon, Nov 22, 2010 at 11:20:55AM +0100, Robert Lukassen wrote:
> Hi,
> 
> I just revisited the patch I submitted and I can see that it needs 
> fixing. The intention of the patch was to provide the idVendor & 
> idProduct kernel module parameter overrides to the individual 
> functions at 'bind()' time. Prior to the patch, the overrides were 
> done after the bind, making it hard for individual functions to 
> determine the correct value for idVendor (some functions may need 
> to use that value, e.g. USB audio when it registers itself
> as an ALSA device; it would want to use the same Vendor id).
> 
> The patch makes sure that that happens, however, right after the bind()
> the patched values are lost due to the copying of the gadget specific
> device descriptor. Here's the snippet from 2.6.34:
> 
>  999        usb_gadget_set_selfpowered(gadget);
> 1000
> 
> 1001        /* interface and string IDs start at zero via kzalloc.
> 1002         * we force endpoints to start unassigned; few controller
> 1003         * drivers will zero ep->driver_data.
> 1004         */
> 1005        usb_ep_autoconfig_reset(cdev->gadget);
> 1006
> 1007        /* composite gadget needs to assign strings for whole device (like
> 1008         * serial number), register function drivers, potentially update
> 1009         * power state and consumption, etc
> 1010         */
> 1011        status = composite->bind(cdev);
> 1012        if (status < 0)
> 1013                goto fail;
> 1014
> 1015        cdev->desc = *composite->dev;
> 1016        cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
> 1017
> 1018        /* standardized runtime overrides for device ID data */
> 1019        if (idVendor)
> 1020                cdev->desc.idVendor = cpu_to_le16(idVendor);
> 1021        if (idProduct)
> 1022                cdev->desc.idProduct = cpu_to_le16(idProduct);
> 1023        if (bcdDevice)
> 1024                cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);
> 1025
> 
> In line 1015, the composite device descriptor is copied to the cdev->desc
> field. Then the values get patched.
> 
> My patch just moved lines 1018-1024, so that the functions could access
> the patched values. The ill side effect is that these patched values
> are lost when the *composite->dev (== device descriptor) is copied 
> in line 1015.
> 
> It would seem that the patch should also have moved lines 1015-1016 in front 
> of the composite->bind(cdev) call.
> 
> It would require all composite gadgets (such as serial.c) and all functions
> (such as f_acm.c) to do any modifications to the device descriptor as passed 
> to them in the 'bind' call. For functions that is natural, as they should be
> unaware of the gadget that uses them. 
> 
> The composite gadgets such as 'serial' seem to deal with it differently.
> The serial.c gadget refers to the device descriptor as 'device_desc', and it
> is a static struct. It references it in its 'init' function (which is ok, it is
> prior to the registration point) and in the gs_bind() call. At that point it should
> probably not be using 'device_desc', but cdev->desc.
> 
> I think we can go one of two ways. I'd be happy to go over the composite gadgets and 
> change their use of their device descriptors, such that they use cdev->desc at
> bind() time. Combining that with the moving the copying of the *composite->dev
> to before calling 'composite->bind()' would make things consistent.
> 
> The other way is reverting my original patch. For those functions that need access
> to the overridden idVendor/idProduct code, we'll need to work out another
> (generic) solution.

So, do you want me to revert your original patch and wait for you to
come up with a "better" solution?

That seems like the correct thing to do at the moment.

thanks,

greg k-h

  reply	other threads:[~2010-11-30 17:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4CE6F807.1090607@telenet.be>
2010-11-19 23:32 ` [PATCH] USB: g_serial: Allow to override the default VID/PID Jef Driesen
2010-11-20  0:12   ` Greg KH
2010-11-20 23:03     ` Jef Driesen
2010-11-22 10:20       ` Robert Lukassen
2010-11-30 17:46         ` Greg KH [this message]
2010-12-03 22:09           ` Jef Driesen
2010-12-06  8:09             ` Robert Lukassen
2010-12-15  7:57               ` Jef Driesen
2010-12-17  0:02                 ` Greg KH

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=20101130174605.GC19977@kroah.com \
    --to=greg@kroah.com \
    --cc=Robert.Lukassen@tomtom.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=gregkh@suse.de \
    --cc=jefdriesen@telenet.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.