|
@@ -1002,8 +1002,7 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
|
|
|
* the copy in usb-storage, for as long as we need two copies.
|
|
|
*/
|
|
|
|
|
|
- /* toggle was reset by the clear */
|
|
|
- usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0);
|
|
|
+ usb_reset_endpoint(dev, endp);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -1075,6 +1074,30 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * usb_reset_endpoint - Reset an endpoint's state.
|
|
|
+ * @dev: the device whose endpoint is to be reset
|
|
|
+ * @epaddr: the endpoint's address. Endpoint number for output,
|
|
|
+ * endpoint number + USB_DIR_IN for input
|
|
|
+ *
|
|
|
+ * Resets any host-side endpoint state such as the toggle bit,
|
|
|
+ * sequence number or current window.
|
|
|
+ */
|
|
|
+void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr)
|
|
|
+{
|
|
|
+ unsigned int epnum = epaddr & USB_ENDPOINT_NUMBER_MASK;
|
|
|
+ struct usb_host_endpoint *ep;
|
|
|
+
|
|
|
+ if (usb_endpoint_out(epaddr))
|
|
|
+ ep = dev->ep_out[epnum];
|
|
|
+ else
|
|
|
+ ep = dev->ep_in[epnum];
|
|
|
+ if (ep)
|
|
|
+ usb_hcd_reset_endpoint(dev, ep);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(usb_reset_endpoint);
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* usb_disable_interface -- Disable all endpoints for an interface
|
|
|
* @dev: the device whose interface is being disabled
|
|
@@ -1117,7 +1140,6 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
|
|
|
usb_disable_endpoint(dev, i, true);
|
|
|
usb_disable_endpoint(dev, i + USB_DIR_IN, true);
|
|
|
}
|
|
|
- dev->toggle[0] = dev->toggle[1] = 0;
|
|
|
|
|
|
/* getting rid of interfaces will disconnect
|
|
|
* any drivers bound to them (a key side effect)
|
|
@@ -1154,28 +1176,24 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
|
|
|
* usb_enable_endpoint - Enable an endpoint for USB communications
|
|
|
* @dev: the device whose interface is being enabled
|
|
|
* @ep: the endpoint
|
|
|
- * @reset_toggle: flag to set the endpoint's toggle back to 0
|
|
|
+ * @reset_ep: flag to reset the endpoint state
|
|
|
*
|
|
|
- * Resets the endpoint toggle if asked, and sets dev->ep_{in,out} pointers.
|
|
|
+ * Resets the endpoint state if asked, and sets dev->ep_{in,out} pointers.
|
|
|
* For control endpoints, both the input and output sides are handled.
|
|
|
*/
|
|
|
void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep,
|
|
|
- bool reset_toggle)
|
|
|
+ bool reset_ep)
|
|
|
{
|
|
|
int epnum = usb_endpoint_num(&ep->desc);
|
|
|
int is_out = usb_endpoint_dir_out(&ep->desc);
|
|
|
int is_control = usb_endpoint_xfer_control(&ep->desc);
|
|
|
|
|
|
- if (is_out || is_control) {
|
|
|
- if (reset_toggle)
|
|
|
- usb_settoggle(dev, epnum, 1, 0);
|
|
|
+ if (reset_ep)
|
|
|
+ usb_hcd_reset_endpoint(dev, ep);
|
|
|
+ if (is_out || is_control)
|
|
|
dev->ep_out[epnum] = ep;
|
|
|
- }
|
|
|
- if (!is_out || is_control) {
|
|
|
- if (reset_toggle)
|
|
|
- usb_settoggle(dev, epnum, 0, 0);
|
|
|
+ if (!is_out || is_control)
|
|
|
dev->ep_in[epnum] = ep;
|
|
|
- }
|
|
|
ep->enabled = 1;
|
|
|
}
|
|
|
|
|
@@ -1183,18 +1201,18 @@ void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep,
|
|
|
* usb_enable_interface - Enable all the endpoints for an interface
|
|
|
* @dev: the device whose interface is being enabled
|
|
|
* @intf: pointer to the interface descriptor
|
|
|
- * @reset_toggles: flag to set the endpoints' toggles back to 0
|
|
|
+ * @reset_eps: flag to reset the endpoints' state
|
|
|
*
|
|
|
* Enables all the endpoints for the interface's current altsetting.
|
|
|
*/
|
|
|
void usb_enable_interface(struct usb_device *dev,
|
|
|
- struct usb_interface *intf, bool reset_toggles)
|
|
|
+ struct usb_interface *intf, bool reset_eps)
|
|
|
{
|
|
|
struct usb_host_interface *alt = intf->cur_altsetting;
|
|
|
int i;
|
|
|
|
|
|
for (i = 0; i < alt->desc.bNumEndpoints; ++i)
|
|
|
- usb_enable_endpoint(dev, &alt->endpoint[i], reset_toggles);
|
|
|
+ usb_enable_endpoint(dev, &alt->endpoint[i], reset_eps);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1335,7 +1353,7 @@ EXPORT_SYMBOL_GPL(usb_set_interface);
|
|
|
* This issues a standard SET_CONFIGURATION request to the device using
|
|
|
* the current configuration. The effect is to reset most USB-related
|
|
|
* state in the device, including interface altsettings (reset to zero),
|
|
|
- * endpoint halts (cleared), and data toggle (only for bulk and interrupt
|
|
|
+ * endpoint halts (cleared), and endpoint state (only for bulk and interrupt
|
|
|
* endpoints). Other usbcore state is unchanged, including bindings of
|
|
|
* usb device drivers to interfaces.
|
|
|
*
|
|
@@ -1343,7 +1361,7 @@ EXPORT_SYMBOL_GPL(usb_set_interface);
|
|
|
* (multi-interface) devices. Instead, the driver for each interface may
|
|
|
* use usb_set_interface() on the interfaces it claims. Be careful though;
|
|
|
* some devices don't support the SET_INTERFACE request, and others won't
|
|
|
- * reset all the interface state (notably data toggles). Resetting the whole
|
|
|
+ * reset all the interface state (notably endpoint state). Resetting the whole
|
|
|
* configuration would affect other drivers' interfaces.
|
|
|
*
|
|
|
* The caller must own the device lock.
|
|
@@ -1376,8 +1394,6 @@ int usb_reset_configuration(struct usb_device *dev)
|
|
|
if (retval < 0)
|
|
|
return retval;
|
|
|
|
|
|
- dev->toggle[0] = dev->toggle[1] = 0;
|
|
|
-
|
|
|
/* re-init hc/hcd interface/endpoint state */
|
|
|
for (i = 0; i < config->desc.bNumInterfaces; i++) {
|
|
|
struct usb_interface *intf = config->interface[i];
|