instance = kmalloc(instance_size, GFP_KERNEL); 
instance = kcalloc(1, sizeof(*instance) + sizeof(struct urb *) * (num_rcv_urbs + num_snd_urbs), GFP_KERNEL); 
int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,		     struct usbatm_driver *driver){	struct device *dev = &intf->dev;	struct usb_device *usb_dev = interface_to_usbdev(intf);	struct usbatm_data *instance;	char *buf;	size_t instance_size = sizeof(*instance) + sizeof(struct urb *) * (num_rcv_urbs + num_snd_urbs);	int error = -ENOMEM;	int i, length;	int need_heavy;	dev_dbg(dev, "%s: trying driver %s with vendor=0x%x, product=0x%x, ifnum %d\n",			__func__, driver->driver_name,			le16_to_cpu(usb_dev->descriptor.idVendor),			le16_to_cpu(usb_dev->descriptor.idProduct),			intf->altsetting->desc.bInterfaceNumber);	/* instance init */	instance = kmalloc(instance_size, GFP_KERNEL);	if (!instance) {		dev_dbg(dev, "%s: no memory for instance data!\n", __func__);		return -ENOMEM;	}	memset(instance, 0, instance_size);	/* public fields */	instance->driver = driver;	snprintf(instance->driver_name, sizeof(instance->driver_name), driver->driver_name);	instance->usb_dev = usb_dev;	instance->usb_intf = intf;	buf = instance->description;	length = sizeof(instance->description);	if ((i = usb_string(usb_dev, usb_dev->descriptor.iProduct, buf, length)) < 0)		goto bind;	buf += i;	length -= i;	i = scnprintf(buf, length, " (");	buf += i;	length -= i;	if (length <= 0 || (i = usb_make_path(usb_dev, buf, length)) < 0)		goto bind;	buf += i;	length -= i;	snprintf(buf, length, ")"); bind:	need_heavy = 1;	if (driver->bind && (error = driver->bind(instance, intf, id, &need_heavy)) < 0) {			dev_dbg(dev, "%s: bind failed: %d!\n", __func__, error);			goto fail_free;	}	/* private fields */	kref_init(&instance->refcount);		/* dropped in usbatm_usb_disconnect */	init_MUTEX(&instance->serialize);	instance->thread_pid = -1;	init_completion(&instance->thread_started);	init_completion(&instance->thread_exited);	INIT_LIST_HEAD(&instance->vcc_list);	usbatm_init_channel(&instance->rx_channel);	usbatm_init_channel(&instance->tx_channel);	tasklet_init(&instance->rx_channel.tasklet, usbatm_rx_process, (unsigned long)instance);	tasklet_init(&instance->tx_channel.tasklet, usbatm_tx_process, (unsigned long)instance);	instance->rx_channel.endpoint = usb_rcvbulkpipe(usb_dev, driver->in);	instance->tx_channel.endpoint = usb_sndbulkpipe(usb_dev, driver->out);	instance->rx_channel.stride = ATM_CELL_SIZE + driver->rx_padding;	instance->tx_channel.stride = ATM_CELL_SIZE + driver->tx_padding;	instance->rx_channel.buf_size = rcv_buf_size * instance->rx_channel.stride;	instance->tx_channel.buf_size = snd_buf_size * instance->tx_channel.stride;	instance->rx_channel.usbatm = instance->tx_channel.usbatm = instance;	skb_queue_head_init(&instance->sndqueue);	for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {		struct urb *urb;		u8 *buffer;		unsigned int iso_packets = 0, iso_size = 0;		struct usbatm_channel *channel = i < num_rcv_urbs ?			&instance->rx_channel : &instance->tx_channel;		if (usb_pipeisoc(channel->endpoint)) {			/* don't expect iso out endpoints */			iso_size = usb_maxpacket(instance->usb_dev, channel->endpoint, 0);			iso_size -= iso_size % channel->stride;	/* alignment */			BUG_ON(!iso_size);			iso_packets = (channel->buf_size - 1) / iso_size + 1;		}		urb = usb_alloc_urb(iso_packets, GFP_KERNEL);		if (!urb) {			dev_dbg(dev, "%s: no memory for urb %d!\n", __func__, i);			goto fail_unbind;		}		instance->urbs[i] = urb;		buffer = kmalloc(channel->buf_size, GFP_KERNEL);		if (!buffer) {			dev_dbg(dev, "%s: no memory for buffer %d!\n", __func__, i);			goto fail_unbind;		}		memset(buffer, 0, channel->buf_size);		usb_fill_bulk_urb(urb, instance->usb_dev, channel->endpoint,				  buffer, channel->buf_size, usbatm_complete, channel);		if (iso_packets) {			int j;			urb->interval = 1;			urb->transfer_flags = URB_ISO_ASAP;			urb->number_of_packets = iso_packets;			for (j = 0; j < iso_packets; j++) {				urb->iso_frame_desc[j].offset = iso_size * j;				urb->iso_frame_desc[j].length = min_t(int, iso_size,								      channel->buf_size - urb->iso_frame_desc[j].offset);			}		}		/* put all tx URBs on the list of spares */		if (i >= num_rcv_urbs)			list_add_tail(&urb->urb_list, &channel->list);		vdbg("%s: alloced buffer 0x%p buf size %u urb 0x%p",		     __func__, urb->transfer_buffer, urb->transfer_buffer_length, urb);	}	if (need_heavy && driver->heavy_init) {		error = usbatm_heavy_init(instance);	} else {		complete(&instance->thread_exited);	/* pretend that heavy_init was run */		error = usbatm_atm_init(instance);	}	if (error < 0)		goto fail_unbind;	usb_get_dev(usb_dev);	usb_set_intfdata(intf, instance);	return 0; fail_unbind:	if (instance->driver->unbind)		instance->driver->unbind(instance, intf); fail_free:	for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {		if (instance->urbs[i])			kfree(instance->urbs[i]->transfer_buffer);		usb_free_urb(instance->urbs[i]);	}	kfree (instance);	return error;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/f0706930091902641929f2229bfb106144782c94/usbatm.c/clean/drivers/usb/atm/usbatm.c