/* 9.1.1.5 says: * *	Configuring a device or changing an alternate setting *	causes all of the status and configuration values *	associated with endpoints in the affected interfaces to *	be set to their default values. This includes setting *	the data toggle of any endpoint using data toggles to *	the value DATA0. * * Some devices take this too literally and don't reset the data * toggles if the new altsetting is the same as the old one (the * command isn't "changing" an alternate setting).  We will manually * reset the toggles when the new and old altsettings are the same. * Most devices won't need this, but fortunately it doesn't happen * often. */ if (iface->cur_altsetting == alt) manual = 1; 
int usb_set_interface(struct usb_device *dev, int interface, int alternate){	struct usb_interface *iface;	struct usb_host_interface *alt;	int ret;	int manual = 0;	if (dev->state == USB_STATE_SUSPENDED)		return -EHOSTUNREACH;	iface = usb_ifnum_to_if(dev, interface);	if (!iface) {		dev_dbg(&dev->dev, "selecting invalid interface %d\n",			interface);		return -EINVAL;	}	alt = usb_altnum_to_altsetting(iface, alternate);	if (!alt) {		warn("selecting invalid altsetting %d", alternate);		return -EINVAL;	}	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),				   USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,				   alternate, interface, NULL, 0, 5000);	/* 9.4.10 says devices don't need this and are free to STALL the	 * request if the interface only has one alternate setting.	 */	if (ret == -EPIPE && iface->num_altsetting == 1) {		dev_dbg(&dev->dev,			"manual set_interface for iface %d, alt %d\n",			interface, alternate);		manual = 1;	} else if (ret < 0)		return ret;	/* FIXME drivers shouldn't need to replicate/bugfix the logic here	 * when they implement async or easily-killable versions of this or	 * other "should-be-internal" functions (like clear_halt).	 * should hcd+usbcore postprocess control requests?	 */	/* prevent submissions using previous endpoint settings */	usb_disable_interface(dev, iface);	/* 9.1.1.5 says:	 *	 *	Configuring a device or changing an alternate setting	 *	causes all of the status and configuration values	 *	associated with endpoints in the affected interfaces to	 *	be set to their default values. This includes setting	 *	the data toggle of any endpoint using data toggles to	 *	the value DATA0.	 *	 * Some devices take this too literally and don't reset the data	 * toggles if the new altsetting is the same as the old one (the	 * command isn't "changing" an alternate setting).  We will manually	 * reset the toggles when the new and old altsettings are the same.	 * Most devices won't need this, but fortunately it doesn't happen	 * often.	 */	if (iface->cur_altsetting == alt)		manual = 1;	iface->cur_altsetting = alt;	/* If the interface only has one altsetting and the device didn't	 * accept the request (or whenever the old altsetting is the same	 * as the new one), we attempt to carry out the equivalent action	 * by manually clearing the HALT feature for each endpoint in the	 * new altsetting.	 */	if (manual) {		int i;		for (i = 0; i < alt->desc.bNumEndpoints; i++) {			unsigned int epaddr =				alt->endpoint[i].desc.bEndpointAddress;			unsigned int pipe =	__create_pipe(dev, USB_ENDPOINT_NUMBER_MASK & epaddr)	| (usb_endpoint_out(epaddr) ? USB_DIR_OUT : USB_DIR_IN);			usb_clear_halt(dev, pipe);		}	}	/* 9.1.1.5: reset toggles for all endpoints in the new altsetting	 *	 * Note:	 * Despite EP0 is always present in all interfaces/AS, the list of	 * endpoints from the descriptor does not contain EP0. Due to its	 * omnipresence one might expect EP0 being considered "affected" by	 * any SetInterface request and hence assume toggles need to be reset.	 * However, EP0 toggles are re-synced for every individual transfer	 * during the SETUP stage - hence EP0 toggles are "don't care" here.	 * (Likewise, EP0 never "halts" on well designed devices.)	 */	usb_enable_interface(dev, iface);	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/a81e7ecca369afee0b07b4758d8c32542ffc587a/message.c/clean/drivers/usb/core/message.c