public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: gadget: mass storage: use proper device class in device desc
@ 2010-07-01  9:17 Michal Nazarewicz
  2010-07-01 10:09 ` David Brownell
  2010-07-01 14:09 ` Alan Stern
  0 siblings, 2 replies; 5+ messages in thread
From: Michal Nazarewicz @ 2010-07-01  9:17 UTC (permalink / raw)
  To: linux-usb; +Cc: Alan Stern, Kyungmin Park, Marek Szyprowski, linux-kernel

This patch changes the bDeviceClass, bDeviceSubClass, bDeviceProtocol
to match the real class and protocol instead of leaving it as per
interface.

Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
---
Hello Alan,

Each time I see the device descriptor of the File Storage Gadget
I wonder if it shouldn't be set to the real value rather then leaving
it as per interface.

Is there a reason to leave it as per interface?  Will chenging it to
the real value change anything?

I checked my pendrive and an IDE<->USB adapter they as well use a per
interface class but maybe it'll be better to use proper call any way?

 drivers/usb/gadget/file_storage.c |    6 +++++-
 drivers/usb/gadget/mass_storage.c |    4 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index d57c09f..1f76ea0 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -544,7 +544,9 @@ device_desc = {
 	.bDescriptorType =	USB_DT_DEVICE,
 
 	.bcdUSB =		cpu_to_le16(0x0200),
-	.bDeviceClass =		USB_CLASS_PER_INTERFACE,
+	.bDeviceClass =		USB_CLASS_MASS_STORAGE,
+	.bDeviceSubClass =	USB_SC_SCSI, /* Adjusted during fsg_bind() */
+	.bDeviceProtocol =	USB_PR_BULK, /* Adjusted during fsg_bind() */
 
 	/* The next three values can be overridden by module parameters */
 	.idVendor =		cpu_to_le16(FSG_VENDOR_ID),
@@ -3450,7 +3452,9 @@ static int __ref fsg_bind(struct usb_gadget *gadget)
 	i = (transport_is_cbi() ? 3 : 2);	// Number of endpoints
 	fsg_intf_desc.bNumEndpoints = i;
 	fsg_intf_desc.bInterfaceSubClass = mod_data.protocol_type;
+	device_desc.bDeviceSubClass = mod_data.protocol_type;
 	fsg_intf_desc.bInterfaceProtocol = mod_data.transport_type;
+	device_desc.bDeviceProtocol = mod_data.transport_type;
 	fsg_fs_function[i + FSG_FS_FUNCTION_PRE_EP_ENTRIES] = NULL;
 
 	if (gadget_is_dualspeed(gadget)) {
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c
index 585f255..59054a4 100644
--- a/drivers/usb/gadget/mass_storage.c
+++ b/drivers/usb/gadget/mass_storage.c
@@ -70,7 +70,9 @@ static struct usb_device_descriptor msg_device_desc = {
 	.bDescriptorType =	USB_DT_DEVICE,
 
 	.bcdUSB =		cpu_to_le16(0x0200),
-	.bDeviceClass =		USB_CLASS_PER_INTERFACE,
+	.bDeviceClass =		USB_CLASS_MASS_STORAGE,
+	.bDeviceSubClass =	USB_SC_SCSI,
+	.bDeviceProtocol =	USB_PR_BULK,
 
 	/* Vendor and product id can be overridden by module parameters.  */
 	.idVendor =		cpu_to_le16(FSG_VENDOR_ID),
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: gadget: mass storage: use proper device class in device desc
  2010-07-01  9:17 [PATCH] USB: gadget: mass storage: use proper device class in device desc Michal Nazarewicz
@ 2010-07-01 10:09 ` David Brownell
  2010-07-01 10:15   ` Michał Nazarewicz
  2010-07-01 14:09 ` Alan Stern
  1 sibling, 1 reply; 5+ messages in thread
From: David Brownell @ 2010-07-01 10:09 UTC (permalink / raw)
  To: linux-usb, Michal Nazarewicz
  Cc: Alan Stern, Kyungmin Park, Marek Szyprowski, linux-kernel



--- On Thu, 7/1/10, Michal Nazarewicz <m.nazarewicz@samsung.com> wrote:

> to match the real class and protocol instead of leaving it
> as per
> interface.

It works now though ... why change it,
and risk causing breakage??
 
>
> 
> Each time I see the device descriptor of the File Storage
> Gadget
> I wonder if it shouldn't be set to the real value rather
> then leaving
> it as per interface.
> 
> Is there a reason to leave it as per interface?  Will
> chenging it to
> the real value change anything?
> 
> I checked my pendrive and an IDE<->USB adapter they
> as well use a per
> interface class ...



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: gadget: mass storage: use proper device class in device desc
  2010-07-01 10:09 ` David Brownell
@ 2010-07-01 10:15   ` Michał Nazarewicz
  0 siblings, 0 replies; 5+ messages in thread
From: Michał Nazarewicz @ 2010-07-01 10:15 UTC (permalink / raw)
  To: linux-usb, David Brownell
  Cc: Alan Stern, Kyungmin Park, Marek Szyprowski, linux-kernel

On Thu, 01 Jul 2010 12:09:48 +0200, David Brownell <david-b@pacbell.net> wrote:
> It works now though ... why change it,
> and risk causing breakage??

OK.

-- 
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: gadget: mass storage: use proper device class in device desc
  2010-07-01  9:17 [PATCH] USB: gadget: mass storage: use proper device class in device desc Michal Nazarewicz
  2010-07-01 10:09 ` David Brownell
@ 2010-07-01 14:09 ` Alan Stern
  2010-07-01 14:26   ` Michał Nazarewicz
  1 sibling, 1 reply; 5+ messages in thread
From: Alan Stern @ 2010-07-01 14:09 UTC (permalink / raw)
  To: Michal Nazarewicz
  Cc: linux-usb, Kyungmin Park, Marek Szyprowski, linux-kernel

On Thu, 1 Jul 2010, Michal Nazarewicz wrote:

> Hello Alan,
> 
> Each time I see the device descriptor of the File Storage Gadget
> I wonder if it shouldn't be set to the real value rather then leaving
> it as per interface.

It should not be changed.

> Is there a reason to leave it as per interface?

See Table 4.1 in the USB Mass Storage Bulk-Only Transport 
specification and Table 3.1 in the CBI Transport specification.

>  Will chenging it to
> the real value change anything?

You mean will it hurt anything?  I don't know; I have never tried it.

> I checked my pendrive and an IDE<->USB adapter they as well use a per
> interface class but maybe it'll be better to use proper call any way?

No.  And it's not a proper call -- it's not even the proper descriptor
valu.  So NAK on this patch.

Alan Stern


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: gadget: mass storage: use proper device class in device desc
  2010-07-01 14:09 ` Alan Stern
@ 2010-07-01 14:26   ` Michał Nazarewicz
  0 siblings, 0 replies; 5+ messages in thread
From: Michał Nazarewicz @ 2010-07-01 14:26 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-usb, Kyungmin Park, Marek Szyprowski, linux-kernel

> On Thu, 1 Jul 2010, Michal Nazarewicz wrote:
>> Each time I see the device descriptor of the File Storage Gadget
>> I wonder if it shouldn't be set to the real value rather then leaving
>> it as per interface.

On Thu, 01 Jul 2010 16:09:39 +0200, Alan Stern <stern@rowland.harvard.edu> wrote:
> It should not be changed.

>> Is there a reason to leave it as per interface?

> See Table 4.1 in the USB Mass Storage Bulk-Only Transport
> specification and Table 3.1 in the CBI Transport specification.

Ha! Thanks for clarification.  Will have to look more careful through
the specs next time.

-- 
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-07-01 14:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-01  9:17 [PATCH] USB: gadget: mass storage: use proper device class in device desc Michal Nazarewicz
2010-07-01 10:09 ` David Brownell
2010-07-01 10:15   ` Michał Nazarewicz
2010-07-01 14:09 ` Alan Stern
2010-07-01 14:26   ` Michał Nazarewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox