From: Rob Emanuele <rob@emanuele.us>
To: linux-kernel@vger.kernel.org
Cc: Rob Emanuele <rob@emanuele.us>
Subject: [PATCH] usb gadget, serial: Add a serial number field to the usb descriptor.
Date: Fri, 25 Jun 2010 15:45:14 -0700 [thread overview]
Message-ID: <1277505914-22719-1-git-send-email-rob@emanuele.us> (raw)
This way it can support the iSerialNumber parameter.
Signed-off-by: Rob Emanuele <rob@emanuele.us>
---
drivers/usb/gadget/serial.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index f46a609..7f64524 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -63,13 +63,16 @@
#define STRING_MANUFACTURER_IDX 0
#define STRING_PRODUCT_IDX 1
-#define STRING_DESCRIPTION_IDX 2
+#define STRING_SERIAL_IDX 2
+#define STRING_DESCRIPTION_IDX 3
static char manufacturer[50];
+static char serialnum[25];
static struct usb_string strings_dev[] = {
[STRING_MANUFACTURER_IDX].s = manufacturer,
[STRING_PRODUCT_IDX].s = GS_VERSION_NAME,
+ [STRING_SERIAL_IDX].s = serialnum,
[STRING_DESCRIPTION_IDX].s = NULL /* updated; f(use_acm) */,
{ } /* end of list */
};
@@ -175,7 +178,7 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
* contents can be overridden by the composite_dev glue.
*/
- /* device description: manufacturer, product */
+ /* device description: manufacturer, product, serialnum */
snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
init_utsname()->sysname, init_utsname()->release,
gadget->name);
@@ -193,6 +196,14 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
device_desc.iProduct = status;
+ snprintf(serialnum, sizeof serialnum, "non-unique");
+ status = usb_string_id(cdev);
+ if (status < 0)
+ goto fail;
+ strings_dev[STRING_SERIAL_IDX].id = status;
+
+ device_desc.iSerialNumber = status;
+
/* config description */
status = usb_string_id(cdev);
if (status < 0)
--
1.7.0.4
reply other threads:[~2010-06-25 22:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1277505914-22719-1-git-send-email-rob@emanuele.us \
--to=rob@emanuele.us \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®