diff options
Diffstat (limited to 'drivers/usb/gadget/ether.c')
-rw-r--r-- | drivers/usb/gadget/ether.c | 353 |
1 files changed, 137 insertions, 216 deletions
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 3f783cbdc7c3..5bb53ae88969 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -84,18 +84,19 @@ | |||
84 | */ | 84 | */ |
85 | 85 | ||
86 | #define DRIVER_DESC "Ethernet Gadget" | 86 | #define DRIVER_DESC "Ethernet Gadget" |
87 | #define DRIVER_VERSION "Equinox 2004" | 87 | #define DRIVER_VERSION "May Day 2005" |
88 | 88 | ||
89 | static const char shortname [] = "ether"; | 89 | static const char shortname [] = "ether"; |
90 | static const char driver_desc [] = DRIVER_DESC; | 90 | static const char driver_desc [] = DRIVER_DESC; |
91 | 91 | ||
92 | #define RX_EXTRA 20 /* guard against rx overflows */ | 92 | #define RX_EXTRA 20 /* guard against rx overflows */ |
93 | 93 | ||
94 | #ifdef CONFIG_USB_ETH_RNDIS | ||
95 | #include "rndis.h" | 94 | #include "rndis.h" |
96 | #else | 95 | |
97 | #define rndis_init() 0 | 96 | #ifndef CONFIG_USB_ETH_RNDIS |
98 | #define rndis_exit() do{}while(0) | 97 | #define rndis_uninit(x) do{}while(0) |
98 | #define rndis_deregister(c) do{}while(0) | ||
99 | #define rndis_exit() do{}while(0) | ||
99 | #endif | 100 | #endif |
100 | 101 | ||
101 | /* CDC and RNDIS support the same host-chosen outgoing packet filters. */ | 102 | /* CDC and RNDIS support the same host-chosen outgoing packet filters. */ |
@@ -140,9 +141,6 @@ struct eth_dev { | |||
140 | * It also ASSUMES a self-powered device, without remote wakeup, | 141 | * It also ASSUMES a self-powered device, without remote wakeup, |
141 | * although remote wakeup support would make sense. | 142 | * although remote wakeup support would make sense. |
142 | */ | 143 | */ |
143 | static const char *EP_IN_NAME; | ||
144 | static const char *EP_OUT_NAME; | ||
145 | static const char *EP_STATUS_NAME; | ||
146 | 144 | ||
147 | /*-------------------------------------------------------------------------*/ | 145 | /*-------------------------------------------------------------------------*/ |
148 | 146 | ||
@@ -312,6 +310,7 @@ static inline int rndis_active(struct eth_dev *dev) | |||
312 | #define FS_BPS (19 * 64 * 1 * 1000 * 8) | 310 | #define FS_BPS (19 * 64 * 1 * 1000 * 8) |
313 | 311 | ||
314 | #ifdef CONFIG_USB_GADGET_DUALSPEED | 312 | #ifdef CONFIG_USB_GADGET_DUALSPEED |
313 | #define DEVSPEED USB_SPEED_HIGH | ||
315 | 314 | ||
316 | static unsigned qmult = 5; | 315 | static unsigned qmult = 5; |
317 | module_param (qmult, uint, S_IRUGO|S_IWUSR); | 316 | module_param (qmult, uint, S_IRUGO|S_IWUSR); |
@@ -330,6 +329,8 @@ static inline int BITRATE(struct usb_gadget *g) | |||
330 | } | 329 | } |
331 | 330 | ||
332 | #else /* full speed (low speed doesn't do bulk) */ | 331 | #else /* full speed (low speed doesn't do bulk) */ |
332 | #define DEVSPEED USB_SPEED_FULL | ||
333 | |||
333 | #define qlen(gadget) DEFAULT_QLEN | 334 | #define qlen(gadget) DEFAULT_QLEN |
334 | 335 | ||
335 | static inline int BITRATE(struct usb_gadget *g) | 336 | static inline int BITRATE(struct usb_gadget *g) |
@@ -395,7 +396,8 @@ static inline int BITRATE(struct usb_gadget *g) | |||
395 | #define STRING_SUBSET 8 | 396 | #define STRING_SUBSET 8 |
396 | #define STRING_RNDIS 9 | 397 | #define STRING_RNDIS 9 |
397 | 398 | ||
398 | #define USB_BUFSIZ 256 /* holds our biggest descriptor */ | 399 | /* holds our biggest descriptor (or RNDIS response) */ |
400 | #define USB_BUFSIZ 256 | ||
399 | 401 | ||
400 | /* | 402 | /* |
401 | * This device advertises one configuration, eth_config, unless RNDIS | 403 | * This device advertises one configuration, eth_config, unless RNDIS |
@@ -538,7 +540,7 @@ static const struct usb_cdc_call_mgmt_descriptor call_mgmt_descriptor = { | |||
538 | .bDataInterface = 0x01, | 540 | .bDataInterface = 0x01, |
539 | }; | 541 | }; |
540 | 542 | ||
541 | static struct usb_cdc_acm_descriptor acm_descriptor = { | 543 | static const struct usb_cdc_acm_descriptor acm_descriptor = { |
542 | .bLength = sizeof acm_descriptor, | 544 | .bLength = sizeof acm_descriptor, |
543 | .bDescriptorType = USB_DT_CS_INTERFACE, | 545 | .bDescriptorType = USB_DT_CS_INTERFACE, |
544 | .bDescriptorSubType = USB_CDC_ACM_TYPE, | 546 | .bDescriptorSubType = USB_CDC_ACM_TYPE, |
@@ -846,7 +848,7 @@ static const struct usb_descriptor_header *hs_rndis_function [] = { | |||
846 | #else | 848 | #else |
847 | 849 | ||
848 | /* if there's no high speed support, maxpacket doesn't change. */ | 850 | /* if there's no high speed support, maxpacket doesn't change. */ |
849 | #define ep_desc(g,hs,fs) fs | 851 | #define ep_desc(g,hs,fs) (((void)(g)), (fs)) |
850 | 852 | ||
851 | static inline void __init hs_subset_descriptors(void) | 853 | static inline void __init hs_subset_descriptors(void) |
852 | { | 854 | { |
@@ -946,10 +948,31 @@ config_buf (enum usb_device_speed speed, | |||
946 | static void eth_start (struct eth_dev *dev, int gfp_flags); | 948 | static void eth_start (struct eth_dev *dev, int gfp_flags); |
947 | static int alloc_requests (struct eth_dev *dev, unsigned n, int gfp_flags); | 949 | static int alloc_requests (struct eth_dev *dev, unsigned n, int gfp_flags); |
948 | 950 | ||
949 | #ifdef DEV_CONFIG_CDC | 951 | static int |
950 | static inline int ether_alt_ep_setup (struct eth_dev *dev, struct usb_ep *ep) | 952 | set_ether_config (struct eth_dev *dev, int gfp_flags) |
951 | { | 953 | { |
952 | const struct usb_endpoint_descriptor *d; | 954 | int result = 0; |
955 | struct usb_gadget *gadget = dev->gadget; | ||
956 | |||
957 | /* status endpoint used for RNDIS and (optionally) CDC */ | ||
958 | if (!subset_active(dev) && dev->status_ep) { | ||
959 | dev->status = ep_desc (gadget, &hs_status_desc, | ||
960 | &fs_status_desc); | ||
961 | dev->status_ep->driver_data = dev; | ||
962 | |||
963 | result = usb_ep_enable (dev->status_ep, dev->status); | ||
964 | if (result != 0) { | ||
965 | DEBUG (dev, "enable %s --> %d\n", | ||
966 | dev->status_ep->name, result); | ||
967 | goto done; | ||
968 | } | ||
969 | } | ||
970 | |||
971 | dev->in = ep_desc (dev->gadget, &hs_source_desc, &fs_source_desc); | ||
972 | dev->in_ep->driver_data = dev; | ||
973 | |||
974 | dev->out = ep_desc (dev->gadget, &hs_sink_desc, &fs_sink_desc); | ||
975 | dev->out_ep->driver_data = dev; | ||
953 | 976 | ||
954 | /* With CDC, the host isn't allowed to use these two data | 977 | /* With CDC, the host isn't allowed to use these two data |
955 | * endpoints in the default altsetting for the interface. | 978 | * endpoints in the default altsetting for the interface. |
@@ -959,135 +982,33 @@ static inline int ether_alt_ep_setup (struct eth_dev *dev, struct usb_ep *ep) | |||
959 | * a side effect of setting a packet filter. Deactivation is | 982 | * a side effect of setting a packet filter. Deactivation is |
960 | * from REMOTE_NDIS_HALT_MSG, reset from REMOTE_NDIS_RESET_MSG. | 983 | * from REMOTE_NDIS_HALT_MSG, reset from REMOTE_NDIS_RESET_MSG. |
961 | */ | 984 | */ |
962 | 985 | if (!cdc_active(dev)) { | |
963 | /* one endpoint writes data back IN to the host */ | 986 | result = usb_ep_enable (dev->in_ep, dev->in); |
964 | if (strcmp (ep->name, EP_IN_NAME) == 0) { | 987 | if (result != 0) { |
965 | d = ep_desc (dev->gadget, &hs_source_desc, &fs_source_desc); | 988 | DEBUG(dev, "enable %s --> %d\n", |
966 | ep->driver_data = dev; | 989 | dev->in_ep->name, result); |
967 | dev->in = d; | 990 | goto done; |
968 | |||
969 | /* one endpoint just reads OUT packets */ | ||
970 | } else if (strcmp (ep->name, EP_OUT_NAME) == 0) { | ||
971 | d = ep_desc (dev->gadget, &hs_sink_desc, &fs_sink_desc); | ||
972 | ep->driver_data = dev; | ||
973 | dev->out = d; | ||
974 | |||
975 | /* optional status/notification endpoint */ | ||
976 | } else if (EP_STATUS_NAME && | ||
977 | strcmp (ep->name, EP_STATUS_NAME) == 0) { | ||
978 | int result; | ||
979 | |||
980 | d = ep_desc (dev->gadget, &hs_status_desc, &fs_status_desc); | ||
981 | result = usb_ep_enable (ep, d); | ||
982 | if (result < 0) | ||
983 | return result; | ||
984 | |||
985 | ep->driver_data = dev; | ||
986 | dev->status = d; | ||
987 | } | ||
988 | return 0; | ||
989 | } | ||
990 | #endif | ||
991 | |||
992 | #if defined(DEV_CONFIG_SUBSET) || defined(CONFIG_USB_ETH_RNDIS) | ||
993 | static inline int ether_ep_setup (struct eth_dev *dev, struct usb_ep *ep) | ||
994 | { | ||
995 | int result; | ||
996 | const struct usb_endpoint_descriptor *d; | ||
997 | |||
998 | /* CDC subset is simpler: if the device is there, | ||
999 | * it's live with rx and tx endpoints. | ||
1000 | * | ||
1001 | * Do this as a shortcut for RNDIS too. | ||
1002 | */ | ||
1003 | |||
1004 | /* one endpoint writes data back IN to the host */ | ||
1005 | if (strcmp (ep->name, EP_IN_NAME) == 0) { | ||
1006 | d = ep_desc (dev->gadget, &hs_source_desc, &fs_source_desc); | ||
1007 | result = usb_ep_enable (ep, d); | ||
1008 | if (result < 0) | ||
1009 | return result; | ||
1010 | |||
1011 | ep->driver_data = dev; | ||
1012 | dev->in = d; | ||
1013 | |||
1014 | /* one endpoint just reads OUT packets */ | ||
1015 | } else if (strcmp (ep->name, EP_OUT_NAME) == 0) { | ||
1016 | d = ep_desc (dev->gadget, &hs_sink_desc, &fs_sink_desc); | ||
1017 | result = usb_ep_enable (ep, d); | ||
1018 | if (result < 0) | ||
1019 | return result; | ||
1020 | |||
1021 | ep->driver_data = dev; | ||
1022 | dev->out = d; | ||
1023 | } | ||
1024 | |||
1025 | return 0; | ||
1026 | } | ||
1027 | #endif | ||
1028 | |||
1029 | static int | ||
1030 | set_ether_config (struct eth_dev *dev, int gfp_flags) | ||
1031 | { | ||
1032 | int result = 0; | ||
1033 | struct usb_ep *ep; | ||
1034 | struct usb_gadget *gadget = dev->gadget; | ||
1035 | |||
1036 | gadget_for_each_ep (ep, gadget) { | ||
1037 | #ifdef DEV_CONFIG_CDC | ||
1038 | if (!dev->rndis && dev->cdc) { | ||
1039 | result = ether_alt_ep_setup (dev, ep); | ||
1040 | if (result == 0) | ||
1041 | continue; | ||
1042 | } | 991 | } |
1043 | #endif | ||
1044 | |||
1045 | #ifdef CONFIG_USB_ETH_RNDIS | ||
1046 | if (dev->rndis && strcmp (ep->name, EP_STATUS_NAME) == 0) { | ||
1047 | const struct usb_endpoint_descriptor *d; | ||
1048 | d = ep_desc (gadget, &hs_status_desc, &fs_status_desc); | ||
1049 | result = usb_ep_enable (ep, d); | ||
1050 | if (result == 0) { | ||
1051 | ep->driver_data = dev; | ||
1052 | dev->status = d; | ||
1053 | continue; | ||
1054 | } | ||
1055 | } else | ||
1056 | #endif | ||
1057 | 992 | ||
1058 | { | 993 | result = usb_ep_enable (dev->out_ep, dev->out); |
1059 | #if defined(DEV_CONFIG_SUBSET) || defined(CONFIG_USB_ETH_RNDIS) | 994 | if (result != 0) { |
1060 | result = ether_ep_setup (dev, ep); | 995 | DEBUG (dev, "enable %s --> %d\n", |
1061 | if (result == 0) | 996 | dev->in_ep->name, result); |
1062 | continue; | 997 | goto done; |
1063 | #endif | ||
1064 | } | 998 | } |
1065 | |||
1066 | /* stop on error */ | ||
1067 | ERROR (dev, "can't enable %s, result %d\n", ep->name, result); | ||
1068 | break; | ||
1069 | } | 999 | } |
1070 | if (!result && (!dev->in_ep || !dev->out_ep)) | ||
1071 | result = -ENODEV; | ||
1072 | 1000 | ||
1001 | done: | ||
1073 | if (result == 0) | 1002 | if (result == 0) |
1074 | result = alloc_requests (dev, qlen (gadget), gfp_flags); | 1003 | result = alloc_requests (dev, qlen (gadget), gfp_flags); |
1075 | 1004 | ||
1076 | /* on error, disable any endpoints */ | 1005 | /* on error, disable any endpoints */ |
1077 | if (result < 0) { | 1006 | if (result < 0) { |
1078 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) | 1007 | if (!subset_active(dev)) |
1079 | if (dev->status) | ||
1080 | (void) usb_ep_disable (dev->status_ep); | 1008 | (void) usb_ep_disable (dev->status_ep); |
1081 | #endif | ||
1082 | dev->status = NULL; | 1009 | dev->status = NULL; |
1083 | #if defined(DEV_CONFIG_SUBSET) || defined(CONFIG_USB_ETH_RNDIS) | 1010 | (void) usb_ep_disable (dev->in_ep); |
1084 | if (dev->rndis || !dev->cdc) { | 1011 | (void) usb_ep_disable (dev->out_ep); |
1085 | if (dev->in) | ||
1086 | (void) usb_ep_disable (dev->in_ep); | ||
1087 | if (dev->out) | ||
1088 | (void) usb_ep_disable (dev->out_ep); | ||
1089 | } | ||
1090 | #endif | ||
1091 | dev->in = NULL; | 1012 | dev->in = NULL; |
1092 | dev->out = NULL; | 1013 | dev->out = NULL; |
1093 | } else | 1014 | } else |
@@ -1095,8 +1016,7 @@ set_ether_config (struct eth_dev *dev, int gfp_flags) | |||
1095 | /* activate non-CDC configs right away | 1016 | /* activate non-CDC configs right away |
1096 | * this isn't strictly according to the RNDIS spec | 1017 | * this isn't strictly according to the RNDIS spec |
1097 | */ | 1018 | */ |
1098 | #if defined(DEV_CONFIG_SUBSET) || defined(CONFIG_USB_ETH_RNDIS) | 1019 | if (!cdc_active (dev)) { |
1099 | if (dev->rndis || !dev->cdc) { | ||
1100 | netif_carrier_on (dev->net); | 1020 | netif_carrier_on (dev->net); |
1101 | if (netif_running (dev->net)) { | 1021 | if (netif_running (dev->net)) { |
1102 | spin_unlock (&dev->lock); | 1022 | spin_unlock (&dev->lock); |
@@ -1104,7 +1024,6 @@ set_ether_config (struct eth_dev *dev, int gfp_flags) | |||
1104 | spin_lock (&dev->lock); | 1024 | spin_lock (&dev->lock); |
1105 | } | 1025 | } |
1106 | } | 1026 | } |
1107 | #endif | ||
1108 | 1027 | ||
1109 | if (result == 0) | 1028 | if (result == 0) |
1110 | DEBUG (dev, "qlen %d\n", qlen (gadget)); | 1029 | DEBUG (dev, "qlen %d\n", qlen (gadget)); |
@@ -1124,6 +1043,7 @@ static void eth_reset_config (struct eth_dev *dev) | |||
1124 | 1043 | ||
1125 | netif_stop_queue (dev->net); | 1044 | netif_stop_queue (dev->net); |
1126 | netif_carrier_off (dev->net); | 1045 | netif_carrier_off (dev->net); |
1046 | rndis_uninit(dev->rndis_config); | ||
1127 | 1047 | ||
1128 | /* disable endpoints, forcing (synchronous) completion of | 1048 | /* disable endpoints, forcing (synchronous) completion of |
1129 | * pending i/o. then free the requests. | 1049 | * pending i/o. then free the requests. |
@@ -1150,6 +1070,8 @@ static void eth_reset_config (struct eth_dev *dev) | |||
1150 | if (dev->status) { | 1070 | if (dev->status) { |
1151 | usb_ep_disable (dev->status_ep); | 1071 | usb_ep_disable (dev->status_ep); |
1152 | } | 1072 | } |
1073 | dev->rndis = 0; | ||
1074 | dev->cdc_filter = 0; | ||
1153 | dev->config = 0; | 1075 | dev->config = 0; |
1154 | } | 1076 | } |
1155 | 1077 | ||
@@ -1162,9 +1084,6 @@ eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags) | |||
1162 | int result = 0; | 1084 | int result = 0; |
1163 | struct usb_gadget *gadget = dev->gadget; | 1085 | struct usb_gadget *gadget = dev->gadget; |
1164 | 1086 | ||
1165 | if (number == dev->config) | ||
1166 | return 0; | ||
1167 | |||
1168 | if (gadget_is_sa1100 (gadget) | 1087 | if (gadget_is_sa1100 (gadget) |
1169 | && dev->config | 1088 | && dev->config |
1170 | && atomic_read (&dev->tx_qlen) != 0) { | 1089 | && atomic_read (&dev->tx_qlen) != 0) { |
@@ -1174,12 +1093,8 @@ eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags) | |||
1174 | } | 1093 | } |
1175 | eth_reset_config (dev); | 1094 | eth_reset_config (dev); |
1176 | 1095 | ||
1177 | /* default: pass all packets, no multicast filtering */ | ||
1178 | dev->cdc_filter = DEFAULT_FILTER; | ||
1179 | |||
1180 | switch (number) { | 1096 | switch (number) { |
1181 | case DEV_CONFIG_VALUE: | 1097 | case DEV_CONFIG_VALUE: |
1182 | dev->rndis = 0; | ||
1183 | result = set_ether_config (dev, gfp_flags); | 1098 | result = set_ether_config (dev, gfp_flags); |
1184 | break; | 1099 | break; |
1185 | #ifdef CONFIG_USB_ETH_RNDIS | 1100 | #ifdef CONFIG_USB_ETH_RNDIS |
@@ -1218,9 +1133,9 @@ eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags) | |||
1218 | dev->config = number; | 1133 | dev->config = number; |
1219 | INFO (dev, "%s speed config #%d: %d mA, %s, using %s\n", | 1134 | INFO (dev, "%s speed config #%d: %d mA, %s, using %s\n", |
1220 | speed, number, power, driver_desc, | 1135 | speed, number, power, driver_desc, |
1221 | dev->rndis | 1136 | rndis_active(dev) |
1222 | ? "RNDIS" | 1137 | ? "RNDIS" |
1223 | : (dev->cdc | 1138 | : (cdc_active(dev) |
1224 | ? "CDC Ethernet" | 1139 | ? "CDC Ethernet" |
1225 | : "CDC Ethernet Subset")); | 1140 | : "CDC Ethernet Subset")); |
1226 | } | 1141 | } |
@@ -1231,6 +1146,13 @@ eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags) | |||
1231 | 1146 | ||
1232 | #ifdef DEV_CONFIG_CDC | 1147 | #ifdef DEV_CONFIG_CDC |
1233 | 1148 | ||
1149 | /* The interrupt endpoint is used in CDC networking models (Ethernet, ATM) | ||
1150 | * only to notify the host about link status changes (which we support) or | ||
1151 | * report completion of some encapsulated command (as used in RNDIS). Since | ||
1152 | * we want this CDC Ethernet code to be vendor-neutral, we don't use that | ||
1153 | * command mechanism; and only one status request is ever queued. | ||
1154 | */ | ||
1155 | |||
1234 | static void eth_status_complete (struct usb_ep *ep, struct usb_request *req) | 1156 | static void eth_status_complete (struct usb_ep *ep, struct usb_request *req) |
1235 | { | 1157 | { |
1236 | struct usb_cdc_notification *event = req->buf; | 1158 | struct usb_cdc_notification *event = req->buf; |
@@ -1259,7 +1181,7 @@ static void eth_status_complete (struct usb_ep *ep, struct usb_request *req) | |||
1259 | } else if (value != -ECONNRESET) | 1181 | } else if (value != -ECONNRESET) |
1260 | DEBUG (dev, "event %02x --> %d\n", | 1182 | DEBUG (dev, "event %02x --> %d\n", |
1261 | event->bNotificationType, value); | 1183 | event->bNotificationType, value); |
1262 | event->bmRequestType = 0xff; | 1184 | req->context = NULL; |
1263 | } | 1185 | } |
1264 | 1186 | ||
1265 | static void issue_start_status (struct eth_dev *dev) | 1187 | static void issue_start_status (struct eth_dev *dev) |
@@ -1276,6 +1198,8 @@ static void issue_start_status (struct eth_dev *dev) | |||
1276 | * a "cancel the whole queue" primitive since any | 1198 | * a "cancel the whole queue" primitive since any |
1277 | * unlink-one primitive has way too many error modes. | 1199 | * unlink-one primitive has way too many error modes. |
1278 | * here, we "know" toggle is already clear... | 1200 | * here, we "know" toggle is already clear... |
1201 | * | ||
1202 | * FIXME iff req->context != null just dequeue it | ||
1279 | */ | 1203 | */ |
1280 | usb_ep_disable (dev->status_ep); | 1204 | usb_ep_disable (dev->status_ep); |
1281 | usb_ep_enable (dev->status_ep, dev->status); | 1205 | usb_ep_enable (dev->status_ep, dev->status); |
@@ -1292,6 +1216,8 @@ static void issue_start_status (struct eth_dev *dev) | |||
1292 | 1216 | ||
1293 | req->length = sizeof *event; | 1217 | req->length = sizeof *event; |
1294 | req->complete = eth_status_complete; | 1218 | req->complete = eth_status_complete; |
1219 | req->context = dev; | ||
1220 | |||
1295 | value = usb_ep_queue (dev->status_ep, req, GFP_ATOMIC); | 1221 | value = usb_ep_queue (dev->status_ep, req, GFP_ATOMIC); |
1296 | if (value < 0) | 1222 | if (value < 0) |
1297 | DEBUG (dev, "status buf queue --> %d\n", value); | 1223 | DEBUG (dev, "status buf queue --> %d\n", value); |
@@ -1351,9 +1277,9 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1351 | struct eth_dev *dev = get_gadget_data (gadget); | 1277 | struct eth_dev *dev = get_gadget_data (gadget); |
1352 | struct usb_request *req = dev->req; | 1278 | struct usb_request *req = dev->req; |
1353 | int value = -EOPNOTSUPP; | 1279 | int value = -EOPNOTSUPP; |
1354 | u16 wIndex = (__force u16) ctrl->wIndex; | 1280 | u16 wIndex = le16_to_cpu(ctrl->wIndex); |
1355 | u16 wValue = (__force u16) ctrl->wValue; | 1281 | u16 wValue = le16_to_cpu(ctrl->wValue); |
1356 | u16 wLength = (__force u16) ctrl->wLength; | 1282 | u16 wLength = le16_to_cpu(ctrl->wLength); |
1357 | 1283 | ||
1358 | /* descriptors just go into the pre-allocated ep0 buffer, | 1284 | /* descriptors just go into the pre-allocated ep0 buffer, |
1359 | * while config change events may enable network traffic. | 1285 | * while config change events may enable network traffic. |
@@ -1424,7 +1350,7 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1424 | || !dev->config | 1350 | || !dev->config |
1425 | || wIndex > 1) | 1351 | || wIndex > 1) |
1426 | break; | 1352 | break; |
1427 | if (!dev->cdc && wIndex != 0) | 1353 | if (!cdc_active(dev) && wIndex != 0) |
1428 | break; | 1354 | break; |
1429 | spin_lock (&dev->lock); | 1355 | spin_lock (&dev->lock); |
1430 | 1356 | ||
@@ -1456,9 +1382,11 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1456 | 1382 | ||
1457 | /* CDC requires the data transfers not be done from | 1383 | /* CDC requires the data transfers not be done from |
1458 | * the default interface setting ... also, setting | 1384 | * the default interface setting ... also, setting |
1459 | * the non-default interface clears filters etc. | 1385 | * the non-default interface resets filters etc. |
1460 | */ | 1386 | */ |
1461 | if (wValue == 1) { | 1387 | if (wValue == 1) { |
1388 | if (!cdc_active (dev)) | ||
1389 | break; | ||
1462 | usb_ep_enable (dev->in_ep, dev->in); | 1390 | usb_ep_enable (dev->in_ep, dev->in); |
1463 | usb_ep_enable (dev->out_ep, dev->out); | 1391 | usb_ep_enable (dev->out_ep, dev->out); |
1464 | dev->cdc_filter = DEFAULT_FILTER; | 1392 | dev->cdc_filter = DEFAULT_FILTER; |
@@ -1492,11 +1420,11 @@ done_set_intf: | |||
1492 | || !dev->config | 1420 | || !dev->config |
1493 | || wIndex > 1) | 1421 | || wIndex > 1) |
1494 | break; | 1422 | break; |
1495 | if (!(dev->cdc || dev->rndis) && wIndex != 0) | 1423 | if (!(cdc_active(dev) || rndis_active(dev)) && wIndex != 0) |
1496 | break; | 1424 | break; |
1497 | 1425 | ||
1498 | /* for CDC, iff carrier is on, data interface is active. */ | 1426 | /* for CDC, iff carrier is on, data interface is active. */ |
1499 | if (dev->rndis || wIndex != 1) | 1427 | if (rndis_active(dev) || wIndex != 1) |
1500 | *(u8 *)req->buf = 0; | 1428 | *(u8 *)req->buf = 0; |
1501 | else | 1429 | else |
1502 | *(u8 *)req->buf = netif_carrier_ok (dev->net) ? 1 : 0; | 1430 | *(u8 *)req->buf = netif_carrier_ok (dev->net) ? 1 : 0; |
@@ -1509,8 +1437,7 @@ done_set_intf: | |||
1509 | * wValue = packet filter bitmap | 1437 | * wValue = packet filter bitmap |
1510 | */ | 1438 | */ |
1511 | if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE) | 1439 | if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE) |
1512 | || !dev->cdc | 1440 | || !cdc_active(dev) |
1513 | || dev->rndis | ||
1514 | || wLength != 0 | 1441 | || wLength != 0 |
1515 | || wIndex > 1) | 1442 | || wIndex > 1) |
1516 | break; | 1443 | break; |
@@ -1534,7 +1461,7 @@ done_set_intf: | |||
1534 | */ | 1461 | */ |
1535 | case USB_CDC_SEND_ENCAPSULATED_COMMAND: | 1462 | case USB_CDC_SEND_ENCAPSULATED_COMMAND: |
1536 | if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE) | 1463 | if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE) |
1537 | || !dev->rndis | 1464 | || !rndis_active(dev) |
1538 | || wLength > USB_BUFSIZ | 1465 | || wLength > USB_BUFSIZ |
1539 | || wValue | 1466 | || wValue |
1540 | || rndis_control_intf.bInterfaceNumber | 1467 | || rndis_control_intf.bInterfaceNumber |
@@ -1549,7 +1476,7 @@ done_set_intf: | |||
1549 | case USB_CDC_GET_ENCAPSULATED_RESPONSE: | 1476 | case USB_CDC_GET_ENCAPSULATED_RESPONSE: |
1550 | if ((USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE) | 1477 | if ((USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE) |
1551 | == ctrl->bRequestType | 1478 | == ctrl->bRequestType |
1552 | && dev->rndis | 1479 | && rndis_active(dev) |
1553 | // && wLength >= 0x0400 | 1480 | // && wLength >= 0x0400 |
1554 | && !wValue | 1481 | && !wValue |
1555 | && rndis_control_intf.bInterfaceNumber | 1482 | && rndis_control_intf.bInterfaceNumber |
@@ -1688,10 +1615,8 @@ rx_submit (struct eth_dev *dev, struct usb_request *req, int gfp_flags) | |||
1688 | */ | 1615 | */ |
1689 | size = (sizeof (struct ethhdr) + dev->net->mtu + RX_EXTRA); | 1616 | size = (sizeof (struct ethhdr) + dev->net->mtu + RX_EXTRA); |
1690 | size += dev->out_ep->maxpacket - 1; | 1617 | size += dev->out_ep->maxpacket - 1; |
1691 | #ifdef CONFIG_USB_ETH_RNDIS | 1618 | if (rndis_active(dev)) |
1692 | if (dev->rndis) | ||
1693 | size += sizeof (struct rndis_packet_msg_type); | 1619 | size += sizeof (struct rndis_packet_msg_type); |
1694 | #endif | ||
1695 | size -= size % dev->out_ep->maxpacket; | 1620 | size -= size % dev->out_ep->maxpacket; |
1696 | 1621 | ||
1697 | if ((skb = alloc_skb (size + NET_IP_ALIGN, gfp_flags)) == 0) { | 1622 | if ((skb = alloc_skb (size + NET_IP_ALIGN, gfp_flags)) == 0) { |
@@ -1735,11 +1660,9 @@ static void rx_complete (struct usb_ep *ep, struct usb_request *req) | |||
1735 | /* normal completion */ | 1660 | /* normal completion */ |
1736 | case 0: | 1661 | case 0: |
1737 | skb_put (skb, req->actual); | 1662 | skb_put (skb, req->actual); |
1738 | #ifdef CONFIG_USB_ETH_RNDIS | ||
1739 | /* we know MaxPacketsPerTransfer == 1 here */ | 1663 | /* we know MaxPacketsPerTransfer == 1 here */ |
1740 | if (dev->rndis) | 1664 | if (rndis_active(dev)) |
1741 | status = rndis_rm_hdr (skb); | 1665 | status = rndis_rm_hdr (skb); |
1742 | #endif | ||
1743 | if (status < 0 | 1666 | if (status < 0 |
1744 | || ETH_HLEN > skb->len | 1667 | || ETH_HLEN > skb->len |
1745 | || skb->len > ETH_FRAME_LEN) { | 1668 | || skb->len > ETH_FRAME_LEN) { |
@@ -1859,8 +1782,6 @@ static void rx_fill (struct eth_dev *dev, int gfp_flags) | |||
1859 | struct usb_request *req; | 1782 | struct usb_request *req; |
1860 | unsigned long flags; | 1783 | unsigned long flags; |
1861 | 1784 | ||
1862 | clear_bit (WORK_RX_MEMORY, &dev->todo); | ||
1863 | |||
1864 | /* fill unused rxq slots with some skb */ | 1785 | /* fill unused rxq slots with some skb */ |
1865 | spin_lock_irqsave (&dev->lock, flags); | 1786 | spin_lock_irqsave (&dev->lock, flags); |
1866 | while (!list_empty (&dev->rx_reqs)) { | 1787 | while (!list_empty (&dev->rx_reqs)) { |
@@ -1883,11 +1804,9 @@ static void eth_work (void *_dev) | |||
1883 | { | 1804 | { |
1884 | struct eth_dev *dev = _dev; | 1805 | struct eth_dev *dev = _dev; |
1885 | 1806 | ||
1886 | if (test_bit (WORK_RX_MEMORY, &dev->todo)) { | 1807 | if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) { |
1887 | if (netif_running (dev->net)) | 1808 | if (netif_running (dev->net)) |
1888 | rx_fill (dev, GFP_KERNEL); | 1809 | rx_fill (dev, GFP_KERNEL); |
1889 | else | ||
1890 | clear_bit (WORK_RX_MEMORY, &dev->todo); | ||
1891 | } | 1810 | } |
1892 | 1811 | ||
1893 | if (dev->todo) | 1812 | if (dev->todo) |
@@ -1971,8 +1890,7 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net) | |||
1971 | * or the hardware can't use skb buffers. | 1890 | * or the hardware can't use skb buffers. |
1972 | * or there's not enough space for any RNDIS headers we need | 1891 | * or there's not enough space for any RNDIS headers we need |
1973 | */ | 1892 | */ |
1974 | #ifdef CONFIG_USB_ETH_RNDIS | 1893 | if (rndis_active(dev)) { |
1975 | if (dev->rndis) { | ||
1976 | struct sk_buff *skb_rndis; | 1894 | struct sk_buff *skb_rndis; |
1977 | 1895 | ||
1978 | skb_rndis = skb_realloc_headroom (skb, | 1896 | skb_rndis = skb_realloc_headroom (skb, |
@@ -1985,7 +1903,6 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net) | |||
1985 | rndis_add_hdr (skb); | 1903 | rndis_add_hdr (skb); |
1986 | length = skb->len; | 1904 | length = skb->len; |
1987 | } | 1905 | } |
1988 | #endif | ||
1989 | req->buf = skb->data; | 1906 | req->buf = skb->data; |
1990 | req->context = skb; | 1907 | req->context = skb; |
1991 | req->complete = tx_complete; | 1908 | req->complete = tx_complete; |
@@ -2018,9 +1935,7 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net) | |||
2018 | } | 1935 | } |
2019 | 1936 | ||
2020 | if (retval) { | 1937 | if (retval) { |
2021 | #ifdef CONFIG_USB_ETH_RNDIS | ||
2022 | drop: | 1938 | drop: |
2023 | #endif | ||
2024 | dev->stats.tx_dropped++; | 1939 | dev->stats.tx_dropped++; |
2025 | dev_kfree_skb_any (skb); | 1940 | dev_kfree_skb_any (skb); |
2026 | spin_lock_irqsave (&dev->lock, flags); | 1941 | spin_lock_irqsave (&dev->lock, flags); |
@@ -2036,27 +1951,31 @@ drop: | |||
2036 | 1951 | ||
2037 | #ifdef CONFIG_USB_ETH_RNDIS | 1952 | #ifdef CONFIG_USB_ETH_RNDIS |
2038 | 1953 | ||
2039 | static void rndis_send_media_state (struct eth_dev *dev, int connect) | 1954 | /* The interrupt endpoint is used in RNDIS to notify the host when messages |
2040 | { | 1955 | * other than data packets are available ... notably the REMOTE_NDIS_*_CMPLT |
2041 | if (!dev) | 1956 | * messages, but also REMOTE_NDIS_INDICATE_STATUS_MSG and potentially even |
2042 | return; | 1957 | * REMOTE_NDIS_KEEPALIVE_MSG. |
2043 | 1958 | * | |
2044 | if (connect) { | 1959 | * The RNDIS control queue is processed by GET_ENCAPSULATED_RESPONSE, and |
2045 | if (rndis_signal_connect (dev->rndis_config)) | 1960 | * normally just one notification will be queued. |
2046 | return; | 1961 | */ |
2047 | } else { | 1962 | |
2048 | if (rndis_signal_disconnect (dev->rndis_config)) | 1963 | static struct usb_request *eth_req_alloc (struct usb_ep *, unsigned, unsigned); |
2049 | return; | 1964 | static void eth_req_free (struct usb_ep *ep, struct usb_request *req); |
2050 | } | ||
2051 | } | ||
2052 | 1965 | ||
2053 | static void | 1966 | static void |
2054 | rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req) | 1967 | rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req) |
2055 | { | 1968 | { |
1969 | struct eth_dev *dev = ep->driver_data; | ||
1970 | |||
2056 | if (req->status || req->actual != req->length) | 1971 | if (req->status || req->actual != req->length) |
2057 | DEBUG ((struct eth_dev *) ep->driver_data, | 1972 | DEBUG (dev, |
2058 | "rndis control ack complete --> %d, %d/%d\n", | 1973 | "rndis control ack complete --> %d, %d/%d\n", |
2059 | req->status, req->actual, req->length); | 1974 | req->status, req->actual, req->length); |
1975 | req->context = NULL; | ||
1976 | |||
1977 | if (req != dev->stat_req) | ||
1978 | eth_req_free(ep, req); | ||
2060 | } | 1979 | } |
2061 | 1980 | ||
2062 | static int rndis_control_ack (struct net_device *net) | 1981 | static int rndis_control_ack (struct net_device *net) |
@@ -2071,11 +1990,19 @@ static int rndis_control_ack (struct net_device *net) | |||
2071 | return -ENODEV; | 1990 | return -ENODEV; |
2072 | } | 1991 | } |
2073 | 1992 | ||
1993 | /* in case queue length > 1 */ | ||
1994 | if (resp->context) { | ||
1995 | resp = eth_req_alloc (dev->status_ep, 8, GFP_ATOMIC); | ||
1996 | if (!resp) | ||
1997 | return -ENOMEM; | ||
1998 | } | ||
1999 | |||
2074 | /* Send RNDIS RESPONSE_AVAILABLE notification; | 2000 | /* Send RNDIS RESPONSE_AVAILABLE notification; |
2075 | * USB_CDC_NOTIFY_RESPONSE_AVAILABLE should work too | 2001 | * USB_CDC_NOTIFY_RESPONSE_AVAILABLE should work too |
2076 | */ | 2002 | */ |
2077 | resp->length = 8; | 2003 | resp->length = 8; |
2078 | resp->complete = rndis_control_ack_complete; | 2004 | resp->complete = rndis_control_ack_complete; |
2005 | resp->context = dev; | ||
2079 | 2006 | ||
2080 | *((__le32 *) resp->buf) = __constant_cpu_to_le32 (1); | 2007 | *((__le32 *) resp->buf) = __constant_cpu_to_le32 (1); |
2081 | *((__le32 *) resp->buf + 1) = __constant_cpu_to_le32 (0); | 2008 | *((__le32 *) resp->buf + 1) = __constant_cpu_to_le32 (0); |
@@ -2089,6 +2016,10 @@ static int rndis_control_ack (struct net_device *net) | |||
2089 | return 0; | 2016 | return 0; |
2090 | } | 2017 | } |
2091 | 2018 | ||
2019 | #else | ||
2020 | |||
2021 | #define rndis_control_ack NULL | ||
2022 | |||
2092 | #endif /* RNDIS */ | 2023 | #endif /* RNDIS */ |
2093 | 2024 | ||
2094 | static void eth_start (struct eth_dev *dev, int gfp_flags) | 2025 | static void eth_start (struct eth_dev *dev, int gfp_flags) |
@@ -2101,14 +2032,12 @@ static void eth_start (struct eth_dev *dev, int gfp_flags) | |||
2101 | /* and open the tx floodgates */ | 2032 | /* and open the tx floodgates */ |
2102 | atomic_set (&dev->tx_qlen, 0); | 2033 | atomic_set (&dev->tx_qlen, 0); |
2103 | netif_wake_queue (dev->net); | 2034 | netif_wake_queue (dev->net); |
2104 | #ifdef CONFIG_USB_ETH_RNDIS | 2035 | if (rndis_active(dev)) { |
2105 | if (dev->rndis) { | ||
2106 | rndis_set_param_medium (dev->rndis_config, | 2036 | rndis_set_param_medium (dev->rndis_config, |
2107 | NDIS_MEDIUM_802_3, | 2037 | NDIS_MEDIUM_802_3, |
2108 | BITRATE(dev->gadget)/100); | 2038 | BITRATE(dev->gadget)/100); |
2109 | rndis_send_media_state (dev, 1); | 2039 | (void) rndis_signal_connect (dev->rndis_config); |
2110 | } | 2040 | } |
2111 | #endif | ||
2112 | } | 2041 | } |
2113 | 2042 | ||
2114 | static int eth_open (struct net_device *net) | 2043 | static int eth_open (struct net_device *net) |
@@ -2149,28 +2078,27 @@ static int eth_stop (struct net_device *net) | |||
2149 | } | 2078 | } |
2150 | } | 2079 | } |
2151 | 2080 | ||
2152 | #ifdef CONFIG_USB_ETH_RNDIS | 2081 | if (rndis_active(dev)) { |
2153 | if (dev->rndis) { | ||
2154 | rndis_set_param_medium (dev->rndis_config, | 2082 | rndis_set_param_medium (dev->rndis_config, |
2155 | NDIS_MEDIUM_802_3, 0); | 2083 | NDIS_MEDIUM_802_3, 0); |
2156 | rndis_send_media_state (dev, 0); | 2084 | (void) rndis_signal_disconnect (dev->rndis_config); |
2157 | } | 2085 | } |
2158 | #endif | ||
2159 | 2086 | ||
2160 | return 0; | 2087 | return 0; |
2161 | } | 2088 | } |
2162 | 2089 | ||
2163 | /*-------------------------------------------------------------------------*/ | 2090 | /*-------------------------------------------------------------------------*/ |
2164 | 2091 | ||
2165 | static struct usb_request *eth_req_alloc (struct usb_ep *ep, unsigned size) | 2092 | static struct usb_request * |
2093 | eth_req_alloc (struct usb_ep *ep, unsigned size, unsigned gfp_flags) | ||
2166 | { | 2094 | { |
2167 | struct usb_request *req; | 2095 | struct usb_request *req; |
2168 | 2096 | ||
2169 | req = usb_ep_alloc_request (ep, GFP_KERNEL); | 2097 | req = usb_ep_alloc_request (ep, gfp_flags); |
2170 | if (!req) | 2098 | if (!req) |
2171 | return NULL; | 2099 | return NULL; |
2172 | 2100 | ||
2173 | req->buf = kmalloc (size, GFP_KERNEL); | 2101 | req->buf = kmalloc (size, gfp_flags); |
2174 | if (!req->buf) { | 2102 | if (!req->buf) { |
2175 | usb_ep_free_request (ep, req); | 2103 | usb_ep_free_request (ep, req); |
2176 | req = NULL; | 2104 | req = NULL; |
@@ -2192,10 +2120,8 @@ eth_unbind (struct usb_gadget *gadget) | |||
2192 | struct eth_dev *dev = get_gadget_data (gadget); | 2120 | struct eth_dev *dev = get_gadget_data (gadget); |
2193 | 2121 | ||
2194 | DEBUG (dev, "unbind\n"); | 2122 | DEBUG (dev, "unbind\n"); |
2195 | #ifdef CONFIG_USB_ETH_RNDIS | ||
2196 | rndis_deregister (dev->rndis_config); | 2123 | rndis_deregister (dev->rndis_config); |
2197 | rndis_exit (); | 2124 | rndis_exit (); |
2198 | #endif | ||
2199 | 2125 | ||
2200 | /* we've already been disconnected ... no i/o is active */ | 2126 | /* we've already been disconnected ... no i/o is active */ |
2201 | if (dev->req) { | 2127 | if (dev->req) { |
@@ -2368,13 +2294,11 @@ autoconf_fail: | |||
2368 | gadget->name); | 2294 | gadget->name); |
2369 | return -ENODEV; | 2295 | return -ENODEV; |
2370 | } | 2296 | } |
2371 | EP_IN_NAME = in_ep->name; | ||
2372 | in_ep->driver_data = in_ep; /* claim */ | 2297 | in_ep->driver_data = in_ep; /* claim */ |
2373 | 2298 | ||
2374 | out_ep = usb_ep_autoconfig (gadget, &fs_sink_desc); | 2299 | out_ep = usb_ep_autoconfig (gadget, &fs_sink_desc); |
2375 | if (!out_ep) | 2300 | if (!out_ep) |
2376 | goto autoconf_fail; | 2301 | goto autoconf_fail; |
2377 | EP_OUT_NAME = out_ep->name; | ||
2378 | out_ep->driver_data = out_ep; /* claim */ | 2302 | out_ep->driver_data = out_ep; /* claim */ |
2379 | 2303 | ||
2380 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) | 2304 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) |
@@ -2384,7 +2308,6 @@ autoconf_fail: | |||
2384 | if (cdc || rndis) { | 2308 | if (cdc || rndis) { |
2385 | status_ep = usb_ep_autoconfig (gadget, &fs_status_desc); | 2309 | status_ep = usb_ep_autoconfig (gadget, &fs_status_desc); |
2386 | if (status_ep) { | 2310 | if (status_ep) { |
2387 | EP_STATUS_NAME = status_ep->name; | ||
2388 | status_ep->driver_data = status_ep; /* claim */ | 2311 | status_ep->driver_data = status_ep; /* claim */ |
2389 | } else if (rndis) { | 2312 | } else if (rndis) { |
2390 | dev_err (&gadget->dev, | 2313 | dev_err (&gadget->dev, |
@@ -2426,7 +2349,7 @@ autoconf_fail: | |||
2426 | hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; | 2349 | hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; |
2427 | hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; | 2350 | hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; |
2428 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) | 2351 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) |
2429 | if (EP_STATUS_NAME) | 2352 | if (status_ep) |
2430 | hs_status_desc.bEndpointAddress = | 2353 | hs_status_desc.bEndpointAddress = |
2431 | fs_status_desc.bEndpointAddress; | 2354 | fs_status_desc.bEndpointAddress; |
2432 | #endif | 2355 | #endif |
@@ -2499,20 +2422,23 @@ autoconf_fail: | |||
2499 | SET_ETHTOOL_OPS(net, &ops); | 2422 | SET_ETHTOOL_OPS(net, &ops); |
2500 | 2423 | ||
2501 | /* preallocate control message data and buffer */ | 2424 | /* preallocate control message data and buffer */ |
2502 | dev->req = eth_req_alloc (gadget->ep0, USB_BUFSIZ); | 2425 | dev->req = eth_req_alloc (gadget->ep0, USB_BUFSIZ, GFP_KERNEL); |
2503 | if (!dev->req) | 2426 | if (!dev->req) |
2504 | goto fail; | 2427 | goto fail; |
2505 | dev->req->complete = eth_setup_complete; | 2428 | dev->req->complete = eth_setup_complete; |
2506 | 2429 | ||
2507 | /* ... and maybe likewise for status transfer */ | 2430 | /* ... and maybe likewise for status transfer */ |
2431 | #ifdef DEV_CONFIG_CDC | ||
2508 | if (dev->status_ep) { | 2432 | if (dev->status_ep) { |
2509 | dev->stat_req = eth_req_alloc (dev->status_ep, | 2433 | dev->stat_req = eth_req_alloc (dev->status_ep, |
2510 | STATUS_BYTECOUNT); | 2434 | STATUS_BYTECOUNT, GFP_KERNEL); |
2511 | if (!dev->stat_req) { | 2435 | if (!dev->stat_req) { |
2512 | eth_req_free (gadget->ep0, dev->req); | 2436 | eth_req_free (gadget->ep0, dev->req); |
2513 | goto fail; | 2437 | goto fail; |
2514 | } | 2438 | } |
2439 | dev->stat_req->context = NULL; | ||
2515 | } | 2440 | } |
2441 | #endif | ||
2516 | 2442 | ||
2517 | /* finish hookup to lower layer ... */ | 2443 | /* finish hookup to lower layer ... */ |
2518 | dev->gadget = gadget; | 2444 | dev->gadget = gadget; |
@@ -2526,16 +2452,16 @@ autoconf_fail: | |||
2526 | netif_stop_queue (dev->net); | 2452 | netif_stop_queue (dev->net); |
2527 | netif_carrier_off (dev->net); | 2453 | netif_carrier_off (dev->net); |
2528 | 2454 | ||
2529 | // SET_NETDEV_DEV (dev->net, &gadget->dev); | 2455 | SET_NETDEV_DEV (dev->net, &gadget->dev); |
2530 | status = register_netdev (dev->net); | 2456 | status = register_netdev (dev->net); |
2531 | if (status < 0) | 2457 | if (status < 0) |
2532 | goto fail1; | 2458 | goto fail1; |
2533 | 2459 | ||
2534 | INFO (dev, "%s, version: " DRIVER_VERSION "\n", driver_desc); | 2460 | INFO (dev, "%s, version: " DRIVER_VERSION "\n", driver_desc); |
2535 | INFO (dev, "using %s, OUT %s IN %s%s%s\n", gadget->name, | 2461 | INFO (dev, "using %s, OUT %s IN %s%s%s\n", gadget->name, |
2536 | EP_OUT_NAME, EP_IN_NAME, | 2462 | out_ep->name, in_ep->name, |
2537 | EP_STATUS_NAME ? " STATUS " : "", | 2463 | status_ep ? " STATUS " : "", |
2538 | EP_STATUS_NAME ? EP_STATUS_NAME : "" | 2464 | status_ep ? status_ep->name : "" |
2539 | ); | 2465 | ); |
2540 | INFO (dev, "MAC %02x:%02x:%02x:%02x:%02x:%02x\n", | 2466 | INFO (dev, "MAC %02x:%02x:%02x:%02x:%02x:%02x\n", |
2541 | net->dev_addr [0], net->dev_addr [1], | 2467 | net->dev_addr [0], net->dev_addr [1], |
@@ -2548,7 +2474,6 @@ autoconf_fail: | |||
2548 | dev->host_mac [2], dev->host_mac [3], | 2474 | dev->host_mac [2], dev->host_mac [3], |
2549 | dev->host_mac [4], dev->host_mac [5]); | 2475 | dev->host_mac [4], dev->host_mac [5]); |
2550 | 2476 | ||
2551 | #ifdef CONFIG_USB_ETH_RNDIS | ||
2552 | if (rndis) { | 2477 | if (rndis) { |
2553 | u32 vendorID = 0; | 2478 | u32 vendorID = 0; |
2554 | 2479 | ||
@@ -2565,7 +2490,7 @@ fail0: | |||
2565 | /* these set up a lot of the OIDs that RNDIS needs */ | 2490 | /* these set up a lot of the OIDs that RNDIS needs */ |
2566 | rndis_set_host_mac (dev->rndis_config, dev->host_mac); | 2491 | rndis_set_host_mac (dev->rndis_config, dev->host_mac); |
2567 | if (rndis_set_param_dev (dev->rndis_config, dev->net, | 2492 | if (rndis_set_param_dev (dev->rndis_config, dev->net, |
2568 | &dev->stats)) | 2493 | &dev->stats, &dev->cdc_filter)) |
2569 | goto fail0; | 2494 | goto fail0; |
2570 | if (rndis_set_param_vendor (dev->rndis_config, vendorID, | 2495 | if (rndis_set_param_vendor (dev->rndis_config, vendorID, |
2571 | manufacturer)) | 2496 | manufacturer)) |
@@ -2576,7 +2501,6 @@ fail0: | |||
2576 | goto fail0; | 2501 | goto fail0; |
2577 | INFO (dev, "RNDIS ready\n"); | 2502 | INFO (dev, "RNDIS ready\n"); |
2578 | } | 2503 | } |
2579 | #endif | ||
2580 | 2504 | ||
2581 | return status; | 2505 | return status; |
2582 | 2506 | ||
@@ -2610,11 +2534,8 @@ eth_resume (struct usb_gadget *gadget) | |||
2610 | /*-------------------------------------------------------------------------*/ | 2534 | /*-------------------------------------------------------------------------*/ |
2611 | 2535 | ||
2612 | static struct usb_gadget_driver eth_driver = { | 2536 | static struct usb_gadget_driver eth_driver = { |
2613 | #ifdef CONFIG_USB_GADGET_DUALSPEED | 2537 | .speed = DEVSPEED, |
2614 | .speed = USB_SPEED_HIGH, | 2538 | |
2615 | #else | ||
2616 | .speed = USB_SPEED_FULL, | ||
2617 | #endif | ||
2618 | .function = (char *) driver_desc, | 2539 | .function = (char *) driver_desc, |
2619 | .bind = eth_bind, | 2540 | .bind = eth_bind, |
2620 | .unbind = eth_unbind, | 2541 | .unbind = eth_unbind, |