buf = usb_buffer_alloc(usb_dev, acm->writesize, GFP_KERNEL, &acm->write_dma); if (!buf) { 
if (acm_write_buffers_alloc(acm) < 0) { 
static int acm_probe (struct usb_interface *intf,		      const struct usb_device_id *id){	struct usb_cdc_union_desc *union_header = NULL;	char *buffer = intf->altsetting->extra;	int buflen = intf->altsetting->extralen;	struct usb_interface *control_interface;	struct usb_interface *data_interface;	struct usb_endpoint_descriptor *epctrl;	struct usb_endpoint_descriptor *epread;	struct usb_endpoint_descriptor *epwrite;	struct usb_device *usb_dev = interface_to_usbdev(intf);	struct acm *acm;	int minor;	int ctrlsize,readsize;	u8 *buf;	u8 ac_management_function = 0;	u8 call_management_function = 0;	int call_interface_num = -1;	int data_interface_num;	unsigned long quirks;	/* handle quirks deadly to normal probing*/	quirks = (unsigned long)id->driver_info;	if (quirks == NO_UNION_NORMAL) {		data_interface = usb_ifnum_to_if(usb_dev, 1);		control_interface = usb_ifnum_to_if(usb_dev, 0);		goto skip_normal_probe;	}		/* normal probing*/	if (!buffer) {		err("Wierd descriptor references\n");		return -EINVAL;	}	if (!buflen) {		if (intf->cur_altsetting->endpoint->extralen && intf->cur_altsetting->endpoint->extra) {			dev_dbg(&intf->dev,"Seeking extra descriptors on endpoint\n");			buflen = intf->cur_altsetting->endpoint->extralen;			buffer = intf->cur_altsetting->endpoint->extra;		} else {			err("Zero length descriptor references\n");			return -EINVAL;		}	}	while (buflen > 0) {		if (buffer [1] != USB_DT_CS_INTERFACE) {			err("skipping garbage\n");			goto next_desc;		}		switch (buffer [2]) {			case USB_CDC_UNION_TYPE: /* we've found it */				if (union_header) {					err("More than one union descriptor, skipping ...");					goto next_desc;				}				union_header = (struct usb_cdc_union_desc *)							buffer;				break;			case USB_CDC_COUNTRY_TYPE: /* maybe somehow export */				break; /* for now we ignore it */			case USB_CDC_HEADER_TYPE: /* maybe check version */ 				break; /* for now we ignore it */ 			case USB_CDC_ACM_TYPE:				ac_management_function = buffer[3];				break;			case USB_CDC_CALL_MANAGEMENT_TYPE:				call_management_function = buffer[3];				call_interface_num = buffer[4];				if ((call_management_function & 3) != 3)					err("This device cannot do calls on its own. It is no modem.");				break;							default:				err("Ignoring extra header, type %d, length %d", buffer[2], buffer[0]);				break;			}next_desc:		buflen -= buffer[0];		buffer += buffer[0];	}	if (!union_header) {		if (call_interface_num > 0) {			dev_dbg(&intf->dev,"No union descriptor, using call management descriptor\n");			data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = call_interface_num));			control_interface = intf;		} else {			dev_dbg(&intf->dev,"No union descriptor, giving up\n");			return -ENODEV;		}	} else {		control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);		data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = union_header->bSlaveInterface0));		if (!control_interface || !data_interface) {			dev_dbg(&intf->dev,"no interfaces\n");			return -ENODEV;		}	}		if (data_interface_num != call_interface_num)		dev_dbg(&intf->dev,"Seperate call control interface. That is not fully supported.\n");skip_normal_probe:	/*workaround for switched interfaces */	if (data_interface->cur_altsetting->desc.bInterfaceClass != CDC_DATA_INTERFACE_TYPE) {		if (control_interface->cur_altsetting->desc.bInterfaceClass == CDC_DATA_INTERFACE_TYPE) {			struct usb_interface *t;			dev_dbg(&intf->dev,"Your device has switched interfaces.\n");			t = control_interface;			control_interface = data_interface;			data_interface = t;		} else {			return -EINVAL;		}	}		if (usb_interface_claimed(data_interface)) { /* valid in this context */		dev_dbg(&intf->dev,"The data interface isn't available\n");		return -EBUSY;	}	if (data_interface->cur_altsetting->desc.bNumEndpoints < 2)		return -EINVAL;	epctrl = &control_interface->cur_altsetting->endpoint[0].desc;	epread = &data_interface->cur_altsetting->endpoint[0].desc;	epwrite = &data_interface->cur_altsetting->endpoint[1].desc;	/* workaround for switched endpoints */	if ((epread->bEndpointAddress & USB_DIR_IN) != USB_DIR_IN) {		/* descriptors are swapped */		struct usb_endpoint_descriptor *t;		dev_dbg(&intf->dev,"The data interface has switched endpoints\n");				t = epread;		epread = epwrite;		epwrite = t;	}	dbg("interfaces are valid");	for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++);	if (minor == ACM_TTY_MINORS) {		err("no more free acm devices");		return -ENODEV;	}	if (!(acm = kmalloc(sizeof(struct acm), GFP_KERNEL))) {		dev_dbg(&intf->dev, "out of memory (acm kmalloc)\n");		goto alloc_fail;	}	memset(acm, 0, sizeof(struct acm));	ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize);	readsize = le16_to_cpu(epread->wMaxPacketSize);	acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize);	acm->control = control_interface;	acm->data = data_interface;	acm->minor = minor;	acm->dev = usb_dev;	acm->ctrl_caps = ac_management_function;	acm->ctrlsize = ctrlsize;	acm->readsize = readsize;	acm->bh.func = acm_rx_tasklet;	acm->bh.data = (unsigned long) acm;	INIT_WORK(&acm->work, acm_softint, acm);	spin_lock_init(&acm->throttle_lock);	acm->ready_for_write = 1;	buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);	if (!buf) {		dev_dbg(&intf->dev, "out of memory (ctrl buffer alloc)\n");		goto alloc_fail2;	}	acm->ctrl_buffer = buf;	buf = usb_buffer_alloc(usb_dev, readsize, GFP_KERNEL, &acm->read_dma);	if (!buf) {		dev_dbg(&intf->dev, "out of memory (read buffer alloc)\n");		goto alloc_fail3;	}	acm->read_buffer = buf;	buf = usb_buffer_alloc(usb_dev, acm->writesize, GFP_KERNEL, &acm->write_dma);	if (!buf) {		dev_dbg(&intf->dev, "out of memory (write buffer alloc)\n");		goto alloc_fail4;	}	acm->write_buffer = buf;		acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);	if (!acm->ctrlurb) {		dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n");		goto alloc_fail5;	}	acm->readurb = usb_alloc_urb(0, GFP_KERNEL);	if (!acm->readurb) {		dev_dbg(&intf->dev, "out of memory (readurb kmalloc)\n");		goto alloc_fail6;	}	acm->writeurb = usb_alloc_urb(0, GFP_KERNEL);	if (!acm->writeurb) {		dev_dbg(&intf->dev, "out of memory (writeurb kmalloc)\n");		goto alloc_fail7;	}	usb_fill_int_urb(acm->ctrlurb, usb_dev, usb_rcvintpipe(usb_dev, epctrl->bEndpointAddress),			 acm->ctrl_buffer, ctrlsize, acm_ctrl_irq, acm, epctrl->bInterval);	acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	acm->ctrlurb->transfer_dma = acm->ctrl_dma;	usb_fill_bulk_urb(acm->readurb, usb_dev, usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress),			  acm->read_buffer, readsize, acm_read_bulk, acm);	acm->readurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP;	acm->readurb->transfer_dma = acm->read_dma;	usb_fill_bulk_urb(acm->writeurb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),			  acm->write_buffer, acm->writesize, acm_write_bulk, acm);	acm->writeurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP;	acm->writeurb->transfer_dma = acm->write_dma;	dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor);	acm_set_control(acm, acm->ctrlout);	acm->line.dwDTERate = cpu_to_le32(9600);	acm->line.bDataBits = 8;	acm_set_line(acm, &acm->line);	usb_driver_claim_interface(&acm_driver, data_interface, acm);	tty_register_device(acm_tty_driver, minor, &intf->dev);	acm_table[minor] = acm;	usb_set_intfdata (intf, acm);	return 0;alloc_fail7:	usb_free_urb(acm->readurb);alloc_fail6:	usb_free_urb(acm->ctrlurb);alloc_fail5:	usb_buffer_free(usb_dev, acm->writesize, acm->write_buffer, acm->write_dma);alloc_fail4:	usb_buffer_free(usb_dev, readsize, acm->read_buffer, acm->read_dma);alloc_fail3:	usb_buffer_free(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);alloc_fail2:	kfree(acm);alloc_fail:	return -ENOMEM;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/884b600f63dc7c646f415a5d8f356df1f66ff6f2/cdc-acm.c/clean/drivers/usb/class/cdc-acm.c