aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/inode.c')
-rw-r--r--drivers/usb/gadget/inode.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 173004f60fea..47ef8bd58a00 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -20,8 +20,7 @@
20 */ 20 */
21 21
22 22
23// #define DEBUG /* data to help fault diagnosis */ 23/* #define VERBOSE_DEBUG */
24// #define VERBOSE /* extra debug messages (success too) */
25 24
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/module.h> 26#include <linux/module.h>
@@ -38,7 +37,7 @@
38#include <linux/moduleparam.h> 37#include <linux/moduleparam.h>
39 38
40#include <linux/usb/gadgetfs.h> 39#include <linux/usb/gadgetfs.h>
41#include <linux/usb_gadget.h> 40#include <linux/usb/gadget.h>
42 41
43 42
44/* 43/*
@@ -253,7 +252,7 @@ static const char *CHIP;
253 do { } while (0) 252 do { } while (0)
254#endif /* DEBUG */ 253#endif /* DEBUG */
255 254
256#ifdef VERBOSE 255#ifdef VERBOSE_DEBUG
257#define VDEBUG DBG 256#define VDEBUG DBG
258#else 257#else
259#define VDEBUG(dev,fmt,args...) \ 258#define VDEBUG(dev,fmt,args...) \
@@ -1010,11 +1009,12 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
1010 /* assume that was SET_CONFIGURATION */ 1009 /* assume that was SET_CONFIGURATION */
1011 if (dev->current_config) { 1010 if (dev->current_config) {
1012 unsigned power; 1011 unsigned power;
1013#ifdef CONFIG_USB_GADGET_DUALSPEED 1012
1014 if (dev->gadget->speed == USB_SPEED_HIGH) 1013 if (gadget_is_dualspeed(dev->gadget)
1014 && (dev->gadget->speed
1015 == USB_SPEED_HIGH))
1015 power = dev->hs_config->bMaxPower; 1016 power = dev->hs_config->bMaxPower;
1016 else 1017 else
1017#endif
1018 power = dev->config->bMaxPower; 1018 power = dev->config->bMaxPower;
1019 usb_gadget_vbus_draw(dev->gadget, 2 * power); 1019 usb_gadget_vbus_draw(dev->gadget, 2 * power);
1020 } 1020 }
@@ -1355,24 +1355,21 @@ static int
1355config_buf (struct dev_data *dev, u8 type, unsigned index) 1355config_buf (struct dev_data *dev, u8 type, unsigned index)
1356{ 1356{
1357 int len; 1357 int len;
1358#ifdef CONFIG_USB_GADGET_DUALSPEED 1358 int hs = 0;
1359 int hs;
1360#endif
1361 1359
1362 /* only one configuration */ 1360 /* only one configuration */
1363 if (index > 0) 1361 if (index > 0)
1364 return -EINVAL; 1362 return -EINVAL;
1365 1363
1366#ifdef CONFIG_USB_GADGET_DUALSPEED 1364 if (gadget_is_dualspeed(dev->gadget)) {
1367 hs = (dev->gadget->speed == USB_SPEED_HIGH); 1365 hs = (dev->gadget->speed == USB_SPEED_HIGH);
1368 if (type == USB_DT_OTHER_SPEED_CONFIG) 1366 if (type == USB_DT_OTHER_SPEED_CONFIG)
1369 hs = !hs; 1367 hs = !hs;
1368 }
1370 if (hs) { 1369 if (hs) {
1371 dev->req->buf = dev->hs_config; 1370 dev->req->buf = dev->hs_config;
1372 len = le16_to_cpu(dev->hs_config->wTotalLength); 1371 len = le16_to_cpu(dev->hs_config->wTotalLength);
1373 } else 1372 } else {
1374#endif
1375 {
1376 dev->req->buf = dev->config; 1373 dev->req->buf = dev->config;
1377 len = le16_to_cpu(dev->config->wTotalLength); 1374 len = le16_to_cpu(dev->config->wTotalLength);
1378 } 1375 }
@@ -1393,13 +1390,13 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1393 spin_lock (&dev->lock); 1390 spin_lock (&dev->lock);
1394 dev->setup_abort = 0; 1391 dev->setup_abort = 0;
1395 if (dev->state == STATE_DEV_UNCONNECTED) { 1392 if (dev->state == STATE_DEV_UNCONNECTED) {
1396#ifdef CONFIG_USB_GADGET_DUALSPEED 1393 if (gadget_is_dualspeed(gadget)
1397 if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == NULL) { 1394 && gadget->speed == USB_SPEED_HIGH
1395 && dev->hs_config == NULL) {
1398 spin_unlock(&dev->lock); 1396 spin_unlock(&dev->lock);
1399 ERROR (dev, "no high speed config??\n"); 1397 ERROR (dev, "no high speed config??\n");
1400 return -EINVAL; 1398 return -EINVAL;
1401 } 1399 }
1402#endif /* CONFIG_USB_GADGET_DUALSPEED */
1403 1400
1404 dev->state = STATE_DEV_CONNECTED; 1401 dev->state = STATE_DEV_CONNECTED;
1405 dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket; 1402 dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket;
@@ -1469,13 +1466,12 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1469 // user mode expected to disable endpoints 1466 // user mode expected to disable endpoints
1470 } else { 1467 } else {
1471 u8 config, power; 1468 u8 config, power;
1472#ifdef CONFIG_USB_GADGET_DUALSPEED 1469
1473 if (gadget->speed == USB_SPEED_HIGH) { 1470 if (gadget_is_dualspeed(gadget)
1471 && gadget->speed == USB_SPEED_HIGH) {
1474 config = dev->hs_config->bConfigurationValue; 1472 config = dev->hs_config->bConfigurationValue;
1475 power = dev->hs_config->bMaxPower; 1473 power = dev->hs_config->bMaxPower;
1476 } else 1474 } else {
1477#endif
1478 {
1479 config = dev->config->bConfigurationValue; 1475 config = dev->config->bConfigurationValue;
1480 power = dev->config->bMaxPower; 1476 power = dev->config->bMaxPower;
1481 } 1477 }