diff options
| -rw-r--r-- | drivers/block/ub.c | 20 | ||||
| -rw-r--r-- | drivers/isdn/hisax/st5481_usb.c | 9 | ||||
| -rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.c | 1 | ||||
| -rw-r--r-- | drivers/usb/core/devio.c | 2 | ||||
| -rw-r--r-- | drivers/usb/core/hcd.c | 26 | ||||
| -rw-r--r-- | drivers/usb/core/hcd.h | 14 | ||||
| -rw-r--r-- | drivers/usb/core/message.c | 58 | ||||
| -rw-r--r-- | drivers/usb/core/usb.c | 2 | ||||
| -rw-r--r-- | drivers/usb/storage/transport.c | 4 | ||||
| -rw-r--r-- | include/linux/usb.h | 9 |
10 files changed, 91 insertions, 54 deletions
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 69b7f8e77596..689cd27ac890 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
| @@ -1025,6 +1025,7 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1025 | { | 1025 | { |
| 1026 | struct urb *urb = &sc->work_urb; | 1026 | struct urb *urb = &sc->work_urb; |
| 1027 | struct bulk_cs_wrap *bcs; | 1027 | struct bulk_cs_wrap *bcs; |
| 1028 | int endp; | ||
| 1028 | int len; | 1029 | int len; |
| 1029 | int rc; | 1030 | int rc; |
| 1030 | 1031 | ||
| @@ -1033,6 +1034,10 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1033 | return; | 1034 | return; |
| 1034 | } | 1035 | } |
| 1035 | 1036 | ||
| 1037 | endp = usb_pipeendpoint(sc->last_pipe); | ||
| 1038 | if (usb_pipein(sc->last_pipe)) | ||
| 1039 | endp |= USB_DIR_IN; | ||
| 1040 | |||
| 1036 | if (cmd->state == UB_CMDST_CLEAR) { | 1041 | if (cmd->state == UB_CMDST_CLEAR) { |
| 1037 | if (urb->status == -EPIPE) { | 1042 | if (urb->status == -EPIPE) { |
| 1038 | /* | 1043 | /* |
| @@ -1048,9 +1053,7 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1048 | * We ignore the result for the halt clear. | 1053 | * We ignore the result for the halt clear. |
| 1049 | */ | 1054 | */ |
| 1050 | 1055 | ||
| 1051 | /* reset the endpoint toggle */ | 1056 | usb_reset_endpoint(sc->dev, endp); |
| 1052 | usb_settoggle(sc->dev, usb_pipeendpoint(sc->last_pipe), | ||
| 1053 | usb_pipeout(sc->last_pipe), 0); | ||
| 1054 | 1057 | ||
| 1055 | ub_state_sense(sc, cmd); | 1058 | ub_state_sense(sc, cmd); |
| 1056 | 1059 | ||
| @@ -1065,9 +1068,7 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1065 | * We ignore the result for the halt clear. | 1068 | * We ignore the result for the halt clear. |
| 1066 | */ | 1069 | */ |
| 1067 | 1070 | ||
| 1068 | /* reset the endpoint toggle */ | 1071 | usb_reset_endpoint(sc->dev, endp); |
| 1069 | usb_settoggle(sc->dev, usb_pipeendpoint(sc->last_pipe), | ||
| 1070 | usb_pipeout(sc->last_pipe), 0); | ||
| 1071 | 1072 | ||
| 1072 | ub_state_stat(sc, cmd); | 1073 | ub_state_stat(sc, cmd); |
| 1073 | 1074 | ||
| @@ -1082,9 +1083,7 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1082 | * We ignore the result for the halt clear. | 1083 | * We ignore the result for the halt clear. |
| 1083 | */ | 1084 | */ |
| 1084 | 1085 | ||
| 1085 | /* reset the endpoint toggle */ | 1086 | usb_reset_endpoint(sc->dev, endp); |
| 1086 | usb_settoggle(sc->dev, usb_pipeendpoint(sc->last_pipe), | ||
| 1087 | usb_pipeout(sc->last_pipe), 0); | ||
| 1088 | 1087 | ||
| 1089 | ub_state_stat_counted(sc, cmd); | 1088 | ub_state_stat_counted(sc, cmd); |
| 1090 | 1089 | ||
| @@ -2119,8 +2118,7 @@ static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe) | |||
| 2119 | del_timer_sync(&timer); | 2118 | del_timer_sync(&timer); |
| 2120 | usb_kill_urb(&sc->work_urb); | 2119 | usb_kill_urb(&sc->work_urb); |
| 2121 | 2120 | ||
| 2122 | /* reset the endpoint toggle */ | 2121 | usb_reset_endpoint(sc->dev, endp); |
| 2123 | usb_settoggle(sc->dev, endp, usb_pipeout(sc->last_pipe), 0); | ||
| 2124 | 2122 | ||
| 2125 | return 0; | 2123 | return 0; |
| 2126 | } | 2124 | } |
diff --git a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c index ec3c0e507669..2b3a055059ea 100644 --- a/drivers/isdn/hisax/st5481_usb.c +++ b/drivers/isdn/hisax/st5481_usb.c | |||
| @@ -149,14 +149,7 @@ static void usb_ctrl_complete(struct urb *urb) | |||
| 149 | if (ctrl_msg->dr.bRequest == USB_REQ_CLEAR_FEATURE) { | 149 | if (ctrl_msg->dr.bRequest == USB_REQ_CLEAR_FEATURE) { |
| 150 | /* Special case handling for pipe reset */ | 150 | /* Special case handling for pipe reset */ |
| 151 | le16_to_cpus(&ctrl_msg->dr.wIndex); | 151 | le16_to_cpus(&ctrl_msg->dr.wIndex); |
| 152 | 152 | usb_reset_endpoint(adapter->usb_dev, ctrl_msg->dr.wIndex); | |
| 153 | /* toggle is reset on clear */ | ||
| 154 | usb_settoggle(adapter->usb_dev, | ||
| 155 | ctrl_msg->dr.wIndex & ~USB_DIR_IN, | ||
| 156 | (ctrl_msg->dr.wIndex & USB_DIR_IN) == 0, | ||
| 157 | 0); | ||
| 158 | |||
| 159 | |||
| 160 | } | 153 | } |
| 161 | 154 | ||
| 162 | if (ctrl_msg->complete) | 155 | if (ctrl_msg->complete) |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index d9d974a8f52a..add3395d3248 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
| @@ -1461,7 +1461,6 @@ static int pvr2_upload_firmware1(struct pvr2_hdw *hdw) | |||
| 1461 | return ret; | 1461 | return ret; |
| 1462 | } | 1462 | } |
| 1463 | 1463 | ||
| 1464 | usb_settoggle(hdw->usb_dev, 0 & 0xf, !(0 & USB_DIR_IN), 0); | ||
| 1465 | usb_clear_halt(hdw->usb_dev, usb_sndbulkpipe(hdw->usb_dev, 0 & 0x7f)); | 1464 | usb_clear_halt(hdw->usb_dev, usb_sndbulkpipe(hdw->usb_dev, 0 & 0x7f)); |
| 1466 | 1465 | ||
| 1467 | pipe = usb_sndctrlpipe(hdw->usb_dev, 0); | 1466 | pipe = usb_sndctrlpipe(hdw->usb_dev, 0); |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index df3c539f652a..308609039c73 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
| @@ -841,7 +841,7 @@ static int proc_resetep(struct dev_state *ps, void __user *arg) | |||
| 841 | ret = checkintf(ps, ret); | 841 | ret = checkintf(ps, ret); |
| 842 | if (ret) | 842 | if (ret) |
| 843 | return ret; | 843 | return ret; |
| 844 | usb_settoggle(ps->dev, ep & 0xf, !(ep & USB_DIR_IN), 0); | 844 | usb_reset_endpoint(ps->dev, ep); |
| 845 | return 0; | 845 | return 0; |
| 846 | } | 846 | } |
| 847 | 847 | ||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 81fa8506825d..42b93da1085d 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
| @@ -1539,6 +1539,32 @@ void usb_hcd_disable_endpoint(struct usb_device *udev, | |||
| 1539 | hcd->driver->endpoint_disable(hcd, ep); | 1539 | hcd->driver->endpoint_disable(hcd, ep); |
| 1540 | } | 1540 | } |
| 1541 | 1541 | ||
| 1542 | /** | ||
| 1543 | * usb_hcd_reset_endpoint - reset host endpoint state | ||
| 1544 | * @udev: USB device. | ||
| 1545 | * @ep: the endpoint to reset. | ||
| 1546 | * | ||
| 1547 | * Resets any host endpoint state such as the toggle bit, sequence | ||
| 1548 | * number and current window. | ||
| 1549 | */ | ||
| 1550 | void usb_hcd_reset_endpoint(struct usb_device *udev, | ||
| 1551 | struct usb_host_endpoint *ep) | ||
| 1552 | { | ||
| 1553 | struct usb_hcd *hcd = bus_to_hcd(udev->bus); | ||
| 1554 | |||
| 1555 | if (hcd->driver->endpoint_reset) | ||
| 1556 | hcd->driver->endpoint_reset(hcd, ep); | ||
| 1557 | else { | ||
| 1558 | int epnum = usb_endpoint_num(&ep->desc); | ||
| 1559 | int is_out = usb_endpoint_dir_out(&ep->desc); | ||
| 1560 | int is_control = usb_endpoint_xfer_control(&ep->desc); | ||
| 1561 | |||
| 1562 | usb_settoggle(udev, epnum, is_out, 0); | ||
| 1563 | if (is_control) | ||
| 1564 | usb_settoggle(udev, epnum, !is_out, 0); | ||
| 1565 | } | ||
| 1566 | } | ||
| 1567 | |||
| 1542 | /* Protect against drivers that try to unlink URBs after the device | 1568 | /* Protect against drivers that try to unlink URBs after the device |
| 1543 | * is gone, by waiting until all unlinks for @udev are finished. | 1569 | * is gone, by waiting until all unlinks for @udev are finished. |
| 1544 | * Since we don't currently track URBs by device, simply wait until | 1570 | * Since we don't currently track URBs by device, simply wait until |
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index f750eb1ab595..e7d4479de41c 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
| @@ -206,6 +206,11 @@ struct hc_driver { | |||
| 206 | void (*endpoint_disable)(struct usb_hcd *hcd, | 206 | void (*endpoint_disable)(struct usb_hcd *hcd, |
| 207 | struct usb_host_endpoint *ep); | 207 | struct usb_host_endpoint *ep); |
| 208 | 208 | ||
| 209 | /* (optional) reset any endpoint state such as sequence number | ||
| 210 | and current window */ | ||
| 211 | void (*endpoint_reset)(struct usb_hcd *hcd, | ||
| 212 | struct usb_host_endpoint *ep); | ||
| 213 | |||
| 209 | /* root hub support */ | 214 | /* root hub support */ |
| 210 | int (*hub_status_data) (struct usb_hcd *hcd, char *buf); | 215 | int (*hub_status_data) (struct usb_hcd *hcd, char *buf); |
| 211 | int (*hub_control) (struct usb_hcd *hcd, | 216 | int (*hub_control) (struct usb_hcd *hcd, |
| @@ -234,6 +239,8 @@ extern void usb_hcd_flush_endpoint(struct usb_device *udev, | |||
| 234 | struct usb_host_endpoint *ep); | 239 | struct usb_host_endpoint *ep); |
| 235 | extern void usb_hcd_disable_endpoint(struct usb_device *udev, | 240 | extern void usb_hcd_disable_endpoint(struct usb_device *udev, |
| 236 | struct usb_host_endpoint *ep); | 241 | struct usb_host_endpoint *ep); |
| 242 | extern void usb_hcd_reset_endpoint(struct usb_device *udev, | ||
| 243 | struct usb_host_endpoint *ep); | ||
| 237 | extern void usb_hcd_synchronize_unlinks(struct usb_device *udev); | 244 | extern void usb_hcd_synchronize_unlinks(struct usb_device *udev); |
| 238 | extern int usb_hcd_get_frame_number(struct usb_device *udev); | 245 | extern int usb_hcd_get_frame_number(struct usb_device *udev); |
| 239 | 246 | ||
| @@ -279,6 +286,13 @@ extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); | |||
| 279 | extern void usb_hc_died(struct usb_hcd *hcd); | 286 | extern void usb_hc_died(struct usb_hcd *hcd); |
| 280 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); | 287 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); |
| 281 | 288 | ||
| 289 | /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ | ||
| 290 | #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) | ||
| 291 | #define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep))) | ||
| 292 | #define usb_settoggle(dev, ep, out, bit) \ | ||
| 293 | ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | \ | ||
| 294 | ((bit) << (ep))) | ||
| 295 | |||
| 282 | /* -------------------------------------------------------------------------- */ | 296 | /* -------------------------------------------------------------------------- */ |
| 283 | 297 | ||
| 284 | /* Enumeration is only for the hub driver, or HCD virtual root hubs */ | 298 | /* Enumeration is only for the hub driver, or HCD virtual root hubs */ |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 30a0690f3683..b62628377654 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
| @@ -1002,8 +1002,7 @@ int usb_clear_halt(struct usb_device *dev, int pipe) | |||
| 1002 | * the copy in usb-storage, for as long as we need two copies. | 1002 | * the copy in usb-storage, for as long as we need two copies. |
| 1003 | */ | 1003 | */ |
| 1004 | 1004 | ||
| 1005 | /* toggle was reset by the clear */ | 1005 | usb_reset_endpoint(dev, endp); |
| 1006 | usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0); | ||
| 1007 | 1006 | ||
| 1008 | return 0; | 1007 | return 0; |
| 1009 | } | 1008 | } |
| @@ -1076,6 +1075,30 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr, | |||
| 1076 | } | 1075 | } |
| 1077 | 1076 | ||
| 1078 | /** | 1077 | /** |
| 1078 | * usb_reset_endpoint - Reset an endpoint's state. | ||
| 1079 | * @dev: the device whose endpoint is to be reset | ||
| 1080 | * @epaddr: the endpoint's address. Endpoint number for output, | ||
| 1081 | * endpoint number + USB_DIR_IN for input | ||
| 1082 | * | ||
| 1083 | * Resets any host-side endpoint state such as the toggle bit, | ||
| 1084 | * sequence number or current window. | ||
| 1085 | */ | ||
| 1086 | void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr) | ||
| 1087 | { | ||
| 1088 | unsigned int epnum = epaddr & USB_ENDPOINT_NUMBER_MASK; | ||
| 1089 | struct usb_host_endpoint *ep; | ||
| 1090 | |||
| 1091 | if (usb_endpoint_out(epaddr)) | ||
| 1092 | ep = dev->ep_out[epnum]; | ||
| 1093 | else | ||
| 1094 | ep = dev->ep_in[epnum]; | ||
| 1095 | if (ep) | ||
| 1096 | usb_hcd_reset_endpoint(dev, ep); | ||
| 1097 | } | ||
| 1098 | EXPORT_SYMBOL_GPL(usb_reset_endpoint); | ||
| 1099 | |||
| 1100 | |||
| 1101 | /** | ||
| 1079 | * usb_disable_interface -- Disable all endpoints for an interface | 1102 | * usb_disable_interface -- Disable all endpoints for an interface |
| 1080 | * @dev: the device whose interface is being disabled | 1103 | * @dev: the device whose interface is being disabled |
| 1081 | * @intf: pointer to the interface descriptor | 1104 | * @intf: pointer to the interface descriptor |
| @@ -1117,7 +1140,6 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
| 1117 | usb_disable_endpoint(dev, i, true); | 1140 | usb_disable_endpoint(dev, i, true); |
| 1118 | usb_disable_endpoint(dev, i + USB_DIR_IN, true); | 1141 | usb_disable_endpoint(dev, i + USB_DIR_IN, true); |
| 1119 | } | 1142 | } |
| 1120 | dev->toggle[0] = dev->toggle[1] = 0; | ||
| 1121 | 1143 | ||
| 1122 | /* getting rid of interfaces will disconnect | 1144 | /* getting rid of interfaces will disconnect |
| 1123 | * any drivers bound to them (a key side effect) | 1145 | * any drivers bound to them (a key side effect) |
| @@ -1154,28 +1176,24 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
| 1154 | * usb_enable_endpoint - Enable an endpoint for USB communications | 1176 | * usb_enable_endpoint - Enable an endpoint for USB communications |
| 1155 | * @dev: the device whose interface is being enabled | 1177 | * @dev: the device whose interface is being enabled |
| 1156 | * @ep: the endpoint | 1178 | * @ep: the endpoint |
| 1157 | * @reset_toggle: flag to set the endpoint's toggle back to 0 | 1179 | * @reset_ep: flag to reset the endpoint state |
| 1158 | * | 1180 | * |
| 1159 | * Resets the endpoint toggle if asked, and sets dev->ep_{in,out} pointers. | 1181 | * Resets the endpoint state if asked, and sets dev->ep_{in,out} pointers. |
| 1160 | * For control endpoints, both the input and output sides are handled. | 1182 | * For control endpoints, both the input and output sides are handled. |
| 1161 | */ | 1183 | */ |
| 1162 | void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep, | 1184 | void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep, |
| 1163 | bool reset_toggle) | 1185 | bool reset_ep) |
| 1164 | { | 1186 | { |
| 1165 | int epnum = usb_endpoint_num(&ep->desc); | 1187 | int epnum = usb_endpoint_num(&ep->desc); |
| 1166 | int is_out = usb_endpoint_dir_out(&ep->desc); | 1188 | int is_out = usb_endpoint_dir_out(&ep->desc); |
| 1167 | int is_control = usb_endpoint_xfer_control(&ep->desc); | 1189 | int is_control = usb_endpoint_xfer_control(&ep->desc); |
| 1168 | 1190 | ||
| 1169 | if (is_out || is_control) { | 1191 | if (reset_ep) |
| 1170 | if (reset_toggle) | 1192 | usb_hcd_reset_endpoint(dev, ep); |
| 1171 | usb_settoggle(dev, epnum, 1, 0); | 1193 | if (is_out || is_control) |
| 1172 | dev->ep_out[epnum] = ep; | 1194 | dev->ep_out[epnum] = ep; |
| 1173 | } | 1195 | if (!is_out || is_control) |
| 1174 | if (!is_out || is_control) { | ||
| 1175 | if (reset_toggle) | ||
| 1176 | usb_settoggle(dev, epnum, 0, 0); | ||
| 1177 | dev->ep_in[epnum] = ep; | 1196 | dev->ep_in[epnum] = ep; |
| 1178 | } | ||
| 1179 | ep->enabled = 1; | 1197 | ep->enabled = 1; |
| 1180 | } | 1198 | } |
| 1181 | 1199 | ||
| @@ -1183,18 +1201,18 @@ void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep, | |||
| 1183 | * usb_enable_interface - Enable all the endpoints for an interface | 1201 | * usb_enable_interface - Enable all the endpoints for an interface |
| 1184 | * @dev: the device whose interface is being enabled | 1202 | * @dev: the device whose interface is being enabled |
| 1185 | * @intf: pointer to the interface descriptor | 1203 | * @intf: pointer to the interface descriptor |
| 1186 | * @reset_toggles: flag to set the endpoints' toggles back to 0 | 1204 | * @reset_eps: flag to reset the endpoints' state |
| 1187 | * | 1205 | * |
| 1188 | * Enables all the endpoints for the interface's current altsetting. | 1206 | * Enables all the endpoints for the interface's current altsetting. |
| 1189 | */ | 1207 | */ |
| 1190 | void usb_enable_interface(struct usb_device *dev, | 1208 | void usb_enable_interface(struct usb_device *dev, |
| 1191 | struct usb_interface *intf, bool reset_toggles) | 1209 | struct usb_interface *intf, bool reset_eps) |
| 1192 | { | 1210 | { |
| 1193 | struct usb_host_interface *alt = intf->cur_altsetting; | 1211 | struct usb_host_interface *alt = intf->cur_altsetting; |
| 1194 | int i; | 1212 | int i; |
| 1195 | 1213 | ||
| 1196 | for (i = 0; i < alt->desc.bNumEndpoints; ++i) | 1214 | for (i = 0; i < alt->desc.bNumEndpoints; ++i) |
| 1197 | usb_enable_endpoint(dev, &alt->endpoint[i], reset_toggles); | 1215 | usb_enable_endpoint(dev, &alt->endpoint[i], reset_eps); |
| 1198 | } | 1216 | } |
| 1199 | 1217 | ||
| 1200 | /** | 1218 | /** |
| @@ -1335,7 +1353,7 @@ EXPORT_SYMBOL_GPL(usb_set_interface); | |||
| 1335 | * This issues a standard SET_CONFIGURATION request to the device using | 1353 | * This issues a standard SET_CONFIGURATION request to the device using |
| 1336 | * the current configuration. The effect is to reset most USB-related | 1354 | * the current configuration. The effect is to reset most USB-related |
| 1337 | * state in the device, including interface altsettings (reset to zero), | 1355 | * state in the device, including interface altsettings (reset to zero), |
| 1338 | * endpoint halts (cleared), and data toggle (only for bulk and interrupt | 1356 | * endpoint halts (cleared), and endpoint state (only for bulk and interrupt |
| 1339 | * endpoints). Other usbcore state is unchanged, including bindings of | 1357 | * endpoints). Other usbcore state is unchanged, including bindings of |
| 1340 | * usb device drivers to interfaces. | 1358 | * usb device drivers to interfaces. |
| 1341 | * | 1359 | * |
| @@ -1343,7 +1361,7 @@ EXPORT_SYMBOL_GPL(usb_set_interface); | |||
| 1343 | * (multi-interface) devices. Instead, the driver for each interface may | 1361 | * (multi-interface) devices. Instead, the driver for each interface may |
| 1344 | * use usb_set_interface() on the interfaces it claims. Be careful though; | 1362 | * use usb_set_interface() on the interfaces it claims. Be careful though; |
| 1345 | * some devices don't support the SET_INTERFACE request, and others won't | 1363 | * some devices don't support the SET_INTERFACE request, and others won't |
| 1346 | * reset all the interface state (notably data toggles). Resetting the whole | 1364 | * reset all the interface state (notably endpoint state). Resetting the whole |
| 1347 | * configuration would affect other drivers' interfaces. | 1365 | * configuration would affect other drivers' interfaces. |
| 1348 | * | 1366 | * |
| 1349 | * The caller must own the device lock. | 1367 | * The caller must own the device lock. |
| @@ -1376,8 +1394,6 @@ int usb_reset_configuration(struct usb_device *dev) | |||
| 1376 | if (retval < 0) | 1394 | if (retval < 0) |
| 1377 | return retval; | 1395 | return retval; |
| 1378 | 1396 | ||
| 1379 | dev->toggle[0] = dev->toggle[1] = 0; | ||
| 1380 | |||
| 1381 | /* re-init hc/hcd interface/endpoint state */ | 1397 | /* re-init hc/hcd interface/endpoint state */ |
| 1382 | for (i = 0; i < config->desc.bNumInterfaces; i++) { | 1398 | for (i = 0; i < config->desc.bNumInterfaces; i++) { |
| 1383 | struct usb_interface *intf = config->interface[i]; | 1399 | struct usb_interface *intf = config->interface[i]; |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index dcfc072630c1..7eee400d3e32 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
| @@ -362,7 +362,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, | |||
| 362 | dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE; | 362 | dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE; |
| 363 | dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT; | 363 | dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT; |
| 364 | /* ep0 maxpacket comes later, from device descriptor */ | 364 | /* ep0 maxpacket comes later, from device descriptor */ |
| 365 | usb_enable_endpoint(dev, &dev->ep0, true); | 365 | usb_enable_endpoint(dev, &dev->ep0, false); |
| 366 | dev->can_submit = 1; | 366 | dev->can_submit = 1; |
| 367 | 367 | ||
| 368 | /* Save readable and stable topology id, distinguishing devices | 368 | /* Save readable and stable topology id, distinguishing devices |
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 49aedb36dc19..fcb320217218 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
| @@ -247,10 +247,8 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe) | |||
| 247 | USB_ENDPOINT_HALT, endp, | 247 | USB_ENDPOINT_HALT, endp, |
| 248 | NULL, 0, 3*HZ); | 248 | NULL, 0, 3*HZ); |
| 249 | 249 | ||
| 250 | /* reset the endpoint toggle */ | ||
| 251 | if (result >= 0) | 250 | if (result >= 0) |
| 252 | usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), | 251 | usb_reset_endpoint(us->pusb_dev, endp); |
| 253 | usb_pipeout(pipe), 0); | ||
| 254 | 252 | ||
| 255 | US_DEBUGP("%s: result = %d\n", __func__, result); | 253 | US_DEBUGP("%s: result = %d\n", __func__, result); |
| 256 | return result; | 254 | return result; |
diff --git a/include/linux/usb.h b/include/linux/usb.h index c6b2ab41b908..3aa2cd1f8d08 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -1387,6 +1387,7 @@ extern int usb_string(struct usb_device *dev, int index, | |||
| 1387 | extern int usb_clear_halt(struct usb_device *dev, int pipe); | 1387 | extern int usb_clear_halt(struct usb_device *dev, int pipe); |
| 1388 | extern int usb_reset_configuration(struct usb_device *dev); | 1388 | extern int usb_reset_configuration(struct usb_device *dev); |
| 1389 | extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); | 1389 | extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); |
| 1390 | extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr); | ||
| 1390 | 1391 | ||
| 1391 | /* this request isn't really synchronous, but it belongs with the others */ | 1392 | /* this request isn't really synchronous, but it belongs with the others */ |
| 1392 | extern int usb_driver_set_configuration(struct usb_device *udev, int config); | 1393 | extern int usb_driver_set_configuration(struct usb_device *udev, int config); |
| @@ -1491,14 +1492,6 @@ void usb_sg_wait(struct usb_sg_request *io); | |||
| 1491 | #define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL) | 1492 | #define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL) |
| 1492 | #define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK) | 1493 | #define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK) |
| 1493 | 1494 | ||
| 1494 | /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ | ||
| 1495 | #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) | ||
| 1496 | #define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep))) | ||
| 1497 | #define usb_settoggle(dev, ep, out, bit) \ | ||
| 1498 | ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | \ | ||
| 1499 | ((bit) << (ep))) | ||
| 1500 | |||
| 1501 | |||
| 1502 | static inline unsigned int __create_pipe(struct usb_device *dev, | 1495 | static inline unsigned int __create_pipe(struct usb_device *dev, |
| 1503 | unsigned int endpoint) | 1496 | unsigned int endpoint) |
| 1504 | { | 1497 | { |
