aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/zero.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-08-02 15:20:05 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:55:04 -0400
commitca2bdf4bcc91818f03e009b87c348609c2578d1d (patch)
tree0c19ffdbc34c6451bc8bcb97e093b1c075e60ac8 /drivers/usb/gadget/zero.c
parent2e806f67cc570d25395469a0ded0df8ffbd4d82f (diff)
USB: gadget: gadget zero cleanups
Clean up gadget zero, using newer APIs and conventions: - gadget_is_dualspeed() and gadget_is_otg() ... #ifdef removal - Remove many now-needless #includes - Use the VERBOSE_DEBUG convention - Some whitespace fixes. - A few comment updates - Plus a few other small cleanups: don't pass gfp_t around when it's always going to be GFP_ATOMIC, and do static init of serial number. Also go to straight GPL; there's no real point in dual licensing this stuff any more. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/zero.c')
-rw-r--r--drivers/usb/gadget/zero.c237
1 files changed, 96 insertions, 141 deletions
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index fcfe869acb94..ff540879ce3a 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1,38 +1,22 @@
1/* 1/*
2 * zero.c -- Gadget Zero, for USB development 2 * zero.c -- Gadget Zero, for USB development
3 * 3 *
4 * Copyright (C) 2003-2004 David Brownell 4 * Copyright (C) 2003-2007 David Brownell
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * This program is free software; you can redistribute it and/or modify
8 * modification, are permitted provided that the following conditions 8 * it under the terms of the GNU General Public License as published by
9 * are met: 9 * the Free Software Foundation; either version 2 of the License, or
10 * 1. Redistributions of source code must retain the above copyright 10 * (at your option) any later version.
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The names of the above-listed copyright holders may not be used
17 * to endorse or promote products derived from this software without
18 * specific prior written permission.
19 * 11 *
20 * ALTERNATIVELY, this software may be distributed under the terms of the 12 * This program is distributed in the hope that it will be useful,
21 * GNU General Public License ("GPL") as published by the Free Software 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * Foundation, either version 2 of that License or (at your option) any 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * later version. 15 * GNU General Public License for more details.
24 * 16 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 17 * You should have received a copy of the GNU General Public License
26 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 * along with this program; if not, write to the Free Software
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */ 20 */
37 21
38 22
@@ -57,30 +41,18 @@
57 * Many drivers will only have one configuration, letting them be much 41 * Many drivers will only have one configuration, letting them be much
58 * simpler if they also don't support high speed operation (like this 42 * simpler if they also don't support high speed operation (like this
59 * driver does). 43 * driver does).
44 *
45 * Why is *this* driver using two configurations, rather than setting up
46 * two interfaces with different functions? To help verify that multiple
47 * configuration infrastucture is working correctly; also, so that it can
48 * work with low capability USB controllers without four bulk endpoints.
60 */ 49 */
61 50
62#define DEBUG 1 51/* #define VERBOSE_DEBUG */
63// #define VERBOSE
64 52
65#include <linux/module.h>
66#include <linux/kernel.h> 53#include <linux/kernel.h>
67#include <linux/delay.h>
68#include <linux/ioport.h>
69#include <linux/slab.h>
70#include <linux/errno.h>
71#include <linux/init.h>
72#include <linux/timer.h>
73#include <linux/list.h>
74#include <linux/interrupt.h>
75#include <linux/utsname.h> 54#include <linux/utsname.h>
76#include <linux/device.h> 55#include <linux/device.h>
77#include <linux/moduleparam.h>
78
79#include <asm/byteorder.h>
80#include <asm/io.h>
81#include <asm/irq.h>
82#include <asm/system.h>
83#include <asm/unaligned.h>
84 56
85#include <linux/usb/ch9.h> 57#include <linux/usb/ch9.h>
86#include <linux/usb_gadget.h> 58#include <linux/usb_gadget.h>
@@ -90,7 +62,7 @@
90 62
91/*-------------------------------------------------------------------------*/ 63/*-------------------------------------------------------------------------*/
92 64
93#define DRIVER_VERSION "St Patrick's Day 2004" 65#define DRIVER_VERSION "Lughnasadh, 2007"
94 66
95static const char shortname [] = "zero"; 67static const char shortname [] = "zero";
96static const char longname [] = "Gadget Zero"; 68static const char longname [] = "Gadget Zero";
@@ -131,30 +103,16 @@ struct zero_dev {
131 struct timer_list resume; 103 struct timer_list resume;
132}; 104};
133 105
134#define xprintk(d,level,fmt,args...) \ 106#define DBG(d, fmt, args...) \
135 dev_printk(level , &(d)->gadget->dev , fmt , ## args) 107 dev_dbg(&(d)->gadget->dev , fmt , ## args)
136 108#define VDBG(d, fmt, args...) \
137#ifdef DEBUG 109 dev_vdbg(&(d)->gadget->dev , fmt , ## args)
138#define DBG(dev,fmt,args...) \ 110#define ERROR(d, fmt, args...) \
139 xprintk(dev , KERN_DEBUG , fmt , ## args) 111 dev_err(&(d)->gadget->dev , fmt , ## args)
140#else 112#define WARN(d, fmt, args...) \
141#define DBG(dev,fmt,args...) \ 113 dev_warn(&(d)->gadget->dev , fmt , ## args)
142 do { } while (0) 114#define INFO(d, fmt, args...) \
143#endif /* DEBUG */ 115 dev_info(&(d)->gadget->dev , fmt , ## args)
144
145#ifdef VERBOSE
146#define VDBG DBG
147#else
148#define VDBG(dev,fmt,args...) \
149 do { } while (0)
150#endif /* VERBOSE */
151
152#define ERROR(dev,fmt,args...) \
153 xprintk(dev , KERN_ERR , fmt , ## args)
154#define WARN(dev,fmt,args...) \
155 xprintk(dev , KERN_WARNING , fmt , ## args)
156#define INFO(dev,fmt,args...) \
157 xprintk(dev , KERN_INFO , fmt , ## args)
158 116
159/*-------------------------------------------------------------------------*/ 117/*-------------------------------------------------------------------------*/
160 118
@@ -326,8 +284,6 @@ static const struct usb_descriptor_header *fs_loopback_function [] = {
326 NULL, 284 NULL,
327}; 285};
328 286
329#ifdef CONFIG_USB_GADGET_DUALSPEED
330
331/* 287/*
332 * usb 2.0 devices need to expose both high speed and full speed 288 * usb 2.0 devices need to expose both high speed and full speed
333 * descriptors, unless they only run at full speed. 289 * descriptors, unless they only run at full speed.
@@ -383,17 +339,20 @@ static const struct usb_descriptor_header *hs_loopback_function [] = {
383}; 339};
384 340
385/* maxpacket and other transfer characteristics vary by speed. */ 341/* maxpacket and other transfer characteristics vary by speed. */
386#define ep_desc(g,hs,fs) (((g)->speed==USB_SPEED_HIGH)?(hs):(fs)) 342static inline struct usb_endpoint_descriptor *
387 343ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
388#else 344 struct usb_endpoint_descriptor *fs)
345{
346 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
347 return hs;
348 return fs;
349}
389 350
390/* if there's no high speed support, maxpacket doesn't change. */ 351static char manufacturer[50];
391#define ep_desc(g,hs,fs) fs
392 352
393#endif /* !CONFIG_USB_GADGET_DUALSPEED */ 353/* default serial number takes at least two packets */
354static char serial[] = "0123456789.0123456789.0123456789";
394 355
395static char manufacturer [50];
396static char serial [40];
397 356
398/* static strings, in UTF-8 */ 357/* static strings, in UTF-8 */
399static struct usb_string strings [] = { 358static struct usb_string strings [] = {
@@ -435,30 +394,29 @@ config_buf (struct usb_gadget *gadget,
435 int is_source_sink; 394 int is_source_sink;
436 int len; 395 int len;
437 const struct usb_descriptor_header **function; 396 const struct usb_descriptor_header **function;
438#ifdef CONFIG_USB_GADGET_DUALSPEED 397 int hs = 0;
439 int hs = (gadget->speed == USB_SPEED_HIGH);
440#endif
441 398
442 /* two configurations will always be index 0 and index 1 */ 399 /* two configurations will always be index 0 and index 1 */
443 if (index > 1) 400 if (index > 1)
444 return -EINVAL; 401 return -EINVAL;
445 is_source_sink = loopdefault ? (index == 1) : (index == 0); 402 is_source_sink = loopdefault ? (index == 1) : (index == 0);
446 403
447#ifdef CONFIG_USB_GADGET_DUALSPEED 404 if (gadget_is_dualspeed(gadget)) {
448 if (type == USB_DT_OTHER_SPEED_CONFIG) 405 hs = (gadget->speed == USB_SPEED_HIGH);
449 hs = !hs; 406 if (type == USB_DT_OTHER_SPEED_CONFIG)
407 hs = !hs;
408 }
450 if (hs) 409 if (hs)
451 function = is_source_sink 410 function = is_source_sink
452 ? hs_source_sink_function 411 ? hs_source_sink_function
453 : hs_loopback_function; 412 : hs_loopback_function;
454 else 413 else
455#endif
456 function = is_source_sink 414 function = is_source_sink
457 ? fs_source_sink_function 415 ? fs_source_sink_function
458 : fs_loopback_function; 416 : fs_loopback_function;
459 417
460 /* for now, don't advertise srp-only devices */ 418 /* for now, don't advertise srp-only devices */
461 if (!gadget->is_otg) 419 if (!gadget_is_otg(gadget))
462 function++; 420 function++;
463 421
464 len = usb_gadget_config_buf (is_source_sink 422 len = usb_gadget_config_buf (is_source_sink
@@ -498,6 +456,19 @@ static void free_ep_req (struct usb_ep *ep, struct usb_request *req)
498 456
499/*-------------------------------------------------------------------------*/ 457/*-------------------------------------------------------------------------*/
500 458
459/*
460 * SOURCE/SINK FUNCTION ... a primary testing vehicle for USB peripherals,
461 * this just sinks bulk packets OUT to the peripheral and sources them IN
462 * to the host, optionally with specific data patterns.
463 *
464 * In terms of control messaging, this supports all the standard requests
465 * plus two that support control-OUT tests.
466 *
467 * Note that because this doesn't queue more than one request at a time,
468 * some other function must be used to test queueing logic. The network
469 * link (g_ether) is probably the best option for that.
470 */
471
501/* optionally require specific source/sink data patterns */ 472/* optionally require specific source/sink data patterns */
502 473
503static int 474static int
@@ -534,12 +505,7 @@ check_read_data (
534 return 0; 505 return 0;
535} 506}
536 507
537static void 508static void reinit_write_data(struct usb_ep *ep, struct usb_request *req)
538reinit_write_data (
539 struct zero_dev *dev,
540 struct usb_ep *ep,
541 struct usb_request *req
542)
543{ 509{
544 unsigned i; 510 unsigned i;
545 u8 *buf = req->buf; 511 u8 *buf = req->buf;
@@ -566,16 +532,16 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req)
566 532
567 switch (status) { 533 switch (status) {
568 534
569 case 0: /* normal completion? */ 535 case 0: /* normal completion? */
570 if (ep == dev->out_ep) { 536 if (ep == dev->out_ep) {
571 check_read_data (dev, ep, req); 537 check_read_data (dev, ep, req);
572 memset (req->buf, 0x55, req->length); 538 memset (req->buf, 0x55, req->length);
573 } else 539 } else
574 reinit_write_data (dev, ep, req); 540 reinit_write_data(ep, req);
575 break; 541 break;
576 542
577 /* this endpoint is normally active while we're configured */ 543 /* this endpoint is normally active while we're configured */
578 case -ECONNABORTED: /* hardware forced ep reset */ 544 case -ECONNABORTED: /* hardware forced ep reset */
579 case -ECONNRESET: /* request dequeued */ 545 case -ECONNRESET: /* request dequeued */
580 case -ESHUTDOWN: /* disconnect from host */ 546 case -ESHUTDOWN: /* disconnect from host */
581 VDBG (dev, "%s gone (%d), %d/%d\n", ep->name, status, 547 VDBG (dev, "%s gone (%d), %d/%d\n", ep->name, status,
@@ -607,8 +573,7 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req)
607 } 573 }
608} 574}
609 575
610static struct usb_request * 576static struct usb_request *source_sink_start_ep(struct usb_ep *ep)
611source_sink_start_ep (struct usb_ep *ep, gfp_t gfp_flags)
612{ 577{
613 struct usb_request *req; 578 struct usb_request *req;
614 int status; 579 int status;
@@ -621,11 +586,11 @@ source_sink_start_ep (struct usb_ep *ep, gfp_t gfp_flags)
621 req->complete = source_sink_complete; 586 req->complete = source_sink_complete;
622 587
623 if (strcmp (ep->name, EP_IN_NAME) == 0) 588 if (strcmp (ep->name, EP_IN_NAME) == 0)
624 reinit_write_data (ep->driver_data, ep, req); 589 reinit_write_data(ep, req);
625 else 590 else
626 memset (req->buf, 0x55, req->length); 591 memset (req->buf, 0x55, req->length);
627 592
628 status = usb_ep_queue (ep, req, gfp_flags); 593 status = usb_ep_queue(ep, req, GFP_ATOMIC);
629 if (status) { 594 if (status) {
630 struct zero_dev *dev = ep->driver_data; 595 struct zero_dev *dev = ep->driver_data;
631 596
@@ -637,8 +602,7 @@ source_sink_start_ep (struct usb_ep *ep, gfp_t gfp_flags)
637 return req; 602 return req;
638} 603}
639 604
640static int 605static int set_source_sink_config(struct zero_dev *dev)
641set_source_sink_config (struct zero_dev *dev, gfp_t gfp_flags)
642{ 606{
643 int result = 0; 607 int result = 0;
644 struct usb_ep *ep; 608 struct usb_ep *ep;
@@ -653,8 +617,7 @@ set_source_sink_config (struct zero_dev *dev, gfp_t gfp_flags)
653 result = usb_ep_enable (ep, d); 617 result = usb_ep_enable (ep, d);
654 if (result == 0) { 618 if (result == 0) {
655 ep->driver_data = dev; 619 ep->driver_data = dev;
656 if (source_sink_start_ep(ep, gfp_flags) 620 if (source_sink_start_ep(ep) != NULL) {
657 != NULL) {
658 dev->in_ep = ep; 621 dev->in_ep = ep;
659 continue; 622 continue;
660 } 623 }
@@ -668,8 +631,7 @@ set_source_sink_config (struct zero_dev *dev, gfp_t gfp_flags)
668 result = usb_ep_enable (ep, d); 631 result = usb_ep_enable (ep, d);
669 if (result == 0) { 632 if (result == 0) {
670 ep->driver_data = dev; 633 ep->driver_data = dev;
671 if (source_sink_start_ep(ep, gfp_flags) 634 if (source_sink_start_ep(ep) != NULL) {
672 != NULL) {
673 dev->out_ep = ep; 635 dev->out_ep = ep;
674 continue; 636 continue;
675 } 637 }
@@ -701,7 +663,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req)
701 663
702 switch (status) { 664 switch (status) {
703 665
704 case 0: /* normal completion? */ 666 case 0: /* normal completion? */
705 if (ep == dev->out_ep) { 667 if (ep == dev->out_ep) {
706 /* loop this OUT packet back IN to the host */ 668 /* loop this OUT packet back IN to the host */
707 req->zero = (req->actual < req->length); 669 req->zero = (req->actual < req->length);
@@ -735,7 +697,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req)
735 * rely on the hardware driver to clean up on disconnect or 697 * rely on the hardware driver to clean up on disconnect or
736 * endpoint disable. 698 * endpoint disable.
737 */ 699 */
738 case -ECONNABORTED: /* hardware forced ep reset */ 700 case -ECONNABORTED: /* hardware forced ep reset */
739 case -ECONNRESET: /* request dequeued */ 701 case -ECONNRESET: /* request dequeued */
740 case -ESHUTDOWN: /* disconnect from host */ 702 case -ESHUTDOWN: /* disconnect from host */
741 free_ep_req (ep, req); 703 free_ep_req (ep, req);
@@ -743,8 +705,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req)
743 } 705 }
744} 706}
745 707
746static int 708static int set_loopback_config(struct zero_dev *dev)
747set_loopback_config (struct zero_dev *dev, gfp_t gfp_flags)
748{ 709{
749 int result = 0; 710 int result = 0;
750 struct usb_ep *ep; 711 struct usb_ep *ep;
@@ -844,8 +805,7 @@ static void zero_reset_config (struct zero_dev *dev)
844 * code can do, perhaps by disallowing more than one configuration or 805 * code can do, perhaps by disallowing more than one configuration or
845 * by limiting configuration choices (like the pxa2xx). 806 * by limiting configuration choices (like the pxa2xx).
846 */ 807 */
847static int 808static int zero_set_config(struct zero_dev *dev, unsigned number)
848zero_set_config (struct zero_dev *dev, unsigned number, gfp_t gfp_flags)
849{ 809{
850 int result = 0; 810 int result = 0;
851 struct usb_gadget *gadget = dev->gadget; 811 struct usb_gadget *gadget = dev->gadget;
@@ -855,17 +815,17 @@ zero_set_config (struct zero_dev *dev, unsigned number, gfp_t gfp_flags)
855 815
856 if (gadget_is_sa1100 (gadget) && dev->config) { 816 if (gadget_is_sa1100 (gadget) && dev->config) {
857 /* tx fifo is full, but we can't clear it...*/ 817 /* tx fifo is full, but we can't clear it...*/
858 INFO (dev, "can't change configurations\n"); 818 ERROR(dev, "can't change configurations\n");
859 return -ESPIPE; 819 return -ESPIPE;
860 } 820 }
861 zero_reset_config (dev); 821 zero_reset_config (dev);
862 822
863 switch (number) { 823 switch (number) {
864 case CONFIG_SOURCE_SINK: 824 case CONFIG_SOURCE_SINK:
865 result = set_source_sink_config (dev, gfp_flags); 825 result = set_source_sink_config(dev);
866 break; 826 break;
867 case CONFIG_LOOPBACK: 827 case CONFIG_LOOPBACK:
868 result = set_loopback_config (dev, gfp_flags); 828 result = set_loopback_config(dev);
869 break; 829 break;
870 default: 830 default:
871 result = -EINVAL; 831 result = -EINVAL;
@@ -885,7 +845,7 @@ zero_set_config (struct zero_dev *dev, unsigned number, gfp_t gfp_flags)
885 case USB_SPEED_LOW: speed = "low"; break; 845 case USB_SPEED_LOW: speed = "low"; break;
886 case USB_SPEED_FULL: speed = "full"; break; 846 case USB_SPEED_FULL: speed = "full"; break;
887 case USB_SPEED_HIGH: speed = "high"; break; 847 case USB_SPEED_HIGH: speed = "high"; break;
888 default: speed = "?"; break; 848 default: speed = "?"; break;
889 } 849 }
890 850
891 dev->config = number; 851 dev->config = number;
@@ -938,19 +898,17 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
938 value = min (w_length, (u16) sizeof device_desc); 898 value = min (w_length, (u16) sizeof device_desc);
939 memcpy (req->buf, &device_desc, value); 899 memcpy (req->buf, &device_desc, value);
940 break; 900 break;
941#ifdef CONFIG_USB_GADGET_DUALSPEED
942 case USB_DT_DEVICE_QUALIFIER: 901 case USB_DT_DEVICE_QUALIFIER:
943 if (!gadget->is_dualspeed) 902 if (!gadget_is_dualspeed(gadget))
944 break; 903 break;
945 value = min (w_length, (u16) sizeof dev_qualifier); 904 value = min (w_length, (u16) sizeof dev_qualifier);
946 memcpy (req->buf, &dev_qualifier, value); 905 memcpy (req->buf, &dev_qualifier, value);
947 break; 906 break;
948 907
949 case USB_DT_OTHER_SPEED_CONFIG: 908 case USB_DT_OTHER_SPEED_CONFIG:
950 if (!gadget->is_dualspeed) 909 if (!gadget_is_dualspeed(gadget))
951 break; 910 break;
952 // FALLTHROUGH 911 // FALLTHROUGH
953#endif /* CONFIG_USB_GADGET_DUALSPEED */
954 case USB_DT_CONFIG: 912 case USB_DT_CONFIG:
955 value = config_buf (gadget, req->buf, 913 value = config_buf (gadget, req->buf,
956 w_value >> 8, 914 w_value >> 8,
@@ -984,7 +942,7 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
984 else 942 else
985 VDBG (dev, "HNP inactive\n"); 943 VDBG (dev, "HNP inactive\n");
986 spin_lock (&dev->lock); 944 spin_lock (&dev->lock);
987 value = zero_set_config (dev, w_value, GFP_ATOMIC); 945 value = zero_set_config(dev, w_value);
988 spin_unlock (&dev->lock); 946 spin_unlock (&dev->lock);
989 break; 947 break;
990 case USB_REQ_GET_CONFIGURATION: 948 case USB_REQ_GET_CONFIGURATION:
@@ -1013,7 +971,7 @@ zero_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1013 * use this "reset the config" shortcut. 971 * use this "reset the config" shortcut.
1014 */ 972 */
1015 zero_reset_config (dev); 973 zero_reset_config (dev);
1016 zero_set_config (dev, config, GFP_ATOMIC); 974 zero_set_config(dev, config);
1017 value = 0; 975 value = 0;
1018 } 976 }
1019 spin_unlock (&dev->lock); 977 spin_unlock (&dev->lock);
@@ -1163,7 +1121,7 @@ autoconf_fail:
1163 } 1121 }
1164 EP_IN_NAME = ep->name; 1122 EP_IN_NAME = ep->name;
1165 ep->driver_data = ep; /* claim */ 1123 ep->driver_data = ep; /* claim */
1166 1124
1167 ep = usb_ep_autoconfig (gadget, &fs_sink_desc); 1125 ep = usb_ep_autoconfig (gadget, &fs_sink_desc);
1168 if (!ep) 1126 if (!ep)
1169 goto autoconf_fail; 1127 goto autoconf_fail;
@@ -1207,16 +1165,18 @@ autoconf_fail:
1207 1165
1208 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket; 1166 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1209 1167
1210#ifdef CONFIG_USB_GADGET_DUALSPEED 1168 if (gadget_is_dualspeed(gadget)) {
1211 /* assume ep0 uses the same value for both speeds ... */ 1169 /* assume ep0 uses the same value for both speeds ... */
1212 dev_qualifier.bMaxPacketSize0 = device_desc.bMaxPacketSize0; 1170 dev_qualifier.bMaxPacketSize0 = device_desc.bMaxPacketSize0;
1213 1171
1214 /* and that all endpoints are dual-speed */ 1172 /* and that all endpoints are dual-speed */
1215 hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; 1173 hs_source_desc.bEndpointAddress =
1216 hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; 1174 fs_source_desc.bEndpointAddress;
1217#endif 1175 hs_sink_desc.bEndpointAddress =
1176 fs_sink_desc.bEndpointAddress;
1177 }
1218 1178
1219 if (gadget->is_otg) { 1179 if (gadget_is_otg(gadget)) {
1220 otg_descriptor.bmAttributes |= USB_OTG_HNP, 1180 otg_descriptor.bmAttributes |= USB_OTG_HNP,
1221 source_sink_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1181 source_sink_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
1222 loopback_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1182 loopback_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
@@ -1294,23 +1254,18 @@ static struct usb_gadget_driver zero_driver = {
1294 .suspend = zero_suspend, 1254 .suspend = zero_suspend,
1295 .resume = zero_resume, 1255 .resume = zero_resume,
1296 1256
1297 .driver = { 1257 .driver = {
1298 .name = (char *) shortname, 1258 .name = (char *) shortname,
1299 .owner = THIS_MODULE, 1259 .owner = THIS_MODULE,
1300 }, 1260 },
1301}; 1261};
1302 1262
1303MODULE_AUTHOR ("David Brownell"); 1263MODULE_AUTHOR("David Brownell");
1304MODULE_LICENSE ("Dual BSD/GPL"); 1264MODULE_LICENSE("GPL");
1305 1265
1306 1266
1307static int __init init (void) 1267static int __init init (void)
1308{ 1268{
1309 /* a real value would likely come through some id prom
1310 * or module option. this one takes at least two packets.
1311 */
1312 strlcpy (serial, "0123456789.0123456789.0123456789", sizeof serial);
1313
1314 return usb_gadget_register_driver (&zero_driver); 1269 return usb_gadget_register_driver (&zero_driver);
1315} 1270}
1316module_init (init); 1271module_init (init);