aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_sourcesink.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_sourcesink.c')
-rw-r--r--drivers/usb/gadget/f_sourcesink.c56
1 files changed, 3 insertions, 53 deletions
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index dc84d26d2835..bffe91d525f9 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -59,7 +59,6 @@ struct f_sourcesink {
59 59
60 struct usb_ep *in_ep; 60 struct usb_ep *in_ep;
61 struct usb_ep *out_ep; 61 struct usb_ep *out_ep;
62 struct timer_list resume;
63}; 62};
64 63
65static inline struct f_sourcesink *func_to_ss(struct usb_function *f) 64static inline struct f_sourcesink *func_to_ss(struct usb_function *f)
@@ -67,10 +66,6 @@ static inline struct f_sourcesink *func_to_ss(struct usb_function *f)
67 return container_of(f, struct f_sourcesink, function); 66 return container_of(f, struct f_sourcesink, function);
68} 67}
69 68
70static unsigned autoresume;
71module_param(autoresume, uint, 0);
72MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup");
73
74static unsigned pattern; 69static unsigned pattern;
75module_param(pattern, uint, 0); 70module_param(pattern, uint, 0);
76MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 = mod63 "); 71MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 = mod63 ");
@@ -118,7 +113,7 @@ static struct usb_endpoint_descriptor hs_source_desc = {
118 .bDescriptorType = USB_DT_ENDPOINT, 113 .bDescriptorType = USB_DT_ENDPOINT,
119 114
120 .bmAttributes = USB_ENDPOINT_XFER_BULK, 115 .bmAttributes = USB_ENDPOINT_XFER_BULK,
121 .wMaxPacketSize = __constant_cpu_to_le16(512), 116 .wMaxPacketSize = cpu_to_le16(512),
122}; 117};
123 118
124static struct usb_endpoint_descriptor hs_sink_desc = { 119static struct usb_endpoint_descriptor hs_sink_desc = {
@@ -126,7 +121,7 @@ static struct usb_endpoint_descriptor hs_sink_desc = {
126 .bDescriptorType = USB_DT_ENDPOINT, 121 .bDescriptorType = USB_DT_ENDPOINT,
127 122
128 .bmAttributes = USB_ENDPOINT_XFER_BULK, 123 .bmAttributes = USB_ENDPOINT_XFER_BULK,
129 .wMaxPacketSize = __constant_cpu_to_le16(512), 124 .wMaxPacketSize = cpu_to_le16(512),
130}; 125};
131 126
132static struct usb_descriptor_header *hs_source_sink_descs[] = { 127static struct usb_descriptor_header *hs_source_sink_descs[] = {
@@ -155,21 +150,6 @@ static struct usb_gadget_strings *sourcesink_strings[] = {
155 150
156/*-------------------------------------------------------------------------*/ 151/*-------------------------------------------------------------------------*/
157 152
158static void sourcesink_autoresume(unsigned long _c)
159{
160 struct usb_composite_dev *cdev = (void *)_c;
161 struct usb_gadget *g = cdev->gadget;
162
163 /* Normally the host would be woken up for something
164 * more significant than just a timer firing; likely
165 * because of some direct user request.
166 */
167 if (g->speed != USB_SPEED_UNKNOWN) {
168 int status = usb_gadget_wakeup(g);
169 DBG(cdev, "%s --> %d\n", __func__, status);
170 }
171}
172
173static int __init 153static int __init
174sourcesink_bind(struct usb_configuration *c, struct usb_function *f) 154sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
175{ 155{
@@ -198,9 +178,6 @@ autoconf_fail:
198 goto autoconf_fail; 178 goto autoconf_fail;
199 ss->out_ep->driver_data = cdev; /* claim */ 179 ss->out_ep->driver_data = cdev; /* claim */
200 180
201 setup_timer(&ss->resume, sourcesink_autoresume,
202 (unsigned long) c->cdev);
203
204 /* support high speed hardware */ 181 /* support high speed hardware */
205 if (gadget_is_dualspeed(c->cdev->gadget)) { 182 if (gadget_is_dualspeed(c->cdev->gadget)) {
206 hs_source_desc.bEndpointAddress = 183 hs_source_desc.bEndpointAddress =
@@ -359,7 +336,6 @@ static void disable_source_sink(struct f_sourcesink *ss)
359 336
360 cdev = ss->function.config->cdev; 337 cdev = ss->function.config->cdev;
361 disable_endpoints(cdev, ss->in_ep, ss->out_ep); 338 disable_endpoints(cdev, ss->in_ep, ss->out_ep);
362 del_timer(&ss->resume);
363 VDBG(cdev, "%s disabled\n", ss->function.name); 339 VDBG(cdev, "%s disabled\n", ss->function.name);
364} 340}
365 341
@@ -426,30 +402,6 @@ static void sourcesink_disable(struct usb_function *f)
426 disable_source_sink(ss); 402 disable_source_sink(ss);
427} 403}
428 404
429static void sourcesink_suspend(struct usb_function *f)
430{
431 struct f_sourcesink *ss = func_to_ss(f);
432 struct usb_composite_dev *cdev = f->config->cdev;
433
434 if (cdev->gadget->speed == USB_SPEED_UNKNOWN)
435 return;
436
437 if (autoresume) {
438 mod_timer(&ss->resume, jiffies + (HZ * autoresume));
439 DBG(cdev, "suspend, wakeup in %d seconds\n", autoresume);
440 } else
441 DBG(cdev, "%s\n", __func__);
442}
443
444static void sourcesink_resume(struct usb_function *f)
445{
446 struct f_sourcesink *ss = func_to_ss(f);
447 struct usb_composite_dev *cdev = f->config->cdev;
448
449 DBG(cdev, "%s\n", __func__);
450 del_timer(&ss->resume);
451}
452
453/*-------------------------------------------------------------------------*/ 405/*-------------------------------------------------------------------------*/
454 406
455static int __init sourcesink_bind_config(struct usb_configuration *c) 407static int __init sourcesink_bind_config(struct usb_configuration *c)
@@ -467,8 +419,6 @@ static int __init sourcesink_bind_config(struct usb_configuration *c)
467 ss->function.unbind = sourcesink_unbind; 419 ss->function.unbind = sourcesink_unbind;
468 ss->function.set_alt = sourcesink_set_alt; 420 ss->function.set_alt = sourcesink_set_alt;
469 ss->function.disable = sourcesink_disable; 421 ss->function.disable = sourcesink_disable;
470 ss->function.suspend = sourcesink_suspend;
471 ss->function.resume = sourcesink_resume;
472 422
473 status = usb_add_function(c, &ss->function); 423 status = usb_add_function(c, &ss->function);
474 if (status) 424 if (status)
@@ -559,7 +509,7 @@ static struct usb_configuration sourcesink_driver = {
559 * sourcesink_add - add a source/sink testing configuration to a device 509 * sourcesink_add - add a source/sink testing configuration to a device
560 * @cdev: the device to support the configuration 510 * @cdev: the device to support the configuration
561 */ 511 */
562int __init sourcesink_add(struct usb_composite_dev *cdev) 512int __init sourcesink_add(struct usb_composite_dev *cdev, bool autoresume)
563{ 513{
564 int id; 514 int id;
565 515