 /* See if the offered device matches what we can accept */ if ((udev->descriptor.idVendor != USB_KEYSPAN_VENDOR_ID) || (udev->descriptor.idProduct != USB_KEYSPAN_PRODUCT_UIA11) ) return -ENODEV; 
static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id){	int i;	int retval = -ENOMEM;	char path[64];	char *buf;	struct usb_keyspan *remote = NULL;	struct usb_host_interface *iface_desc;	struct usb_endpoint_descriptor *endpoint;	struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface));	/* See if the offered device matches what we can accept */	if ((udev->descriptor.idVendor != USB_KEYSPAN_VENDOR_ID) ||	    (udev->descriptor.idProduct != USB_KEYSPAN_PRODUCT_UIA11) )		return -ENODEV;	/* allocate memory for our device state and initialize it */	remote = kmalloc(sizeof(*remote), GFP_KERNEL);	if (remote == NULL) {		err("Out of memory\n");		goto error;	}	memset(remote, 0x00, sizeof(*remote));	remote->udev = udev;	remote->interface = interface;	remote->toggle = -1;	/* Set to -1 so we will always not match the toggle from the first remote message. */	/* set up the endpoint information */	/* use only the first in interrupt endpoint */	iface_desc = interface->cur_altsetting;	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {		endpoint = &iface_desc->endpoint[i].desc;		if (!remote->in_endpoint &&		    (endpoint->bEndpointAddress & USB_DIR_IN) &&		    ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {			/* we found our interrupt in endpoint */			remote->in_endpoint = endpoint;			remote->in_buffer = usb_buffer_alloc(remote->udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma);			if (!remote->in_buffer) {				retval = -ENOMEM;				goto error;			}		}	}	if (!remote->in_endpoint) {		err("Could not find interrupt input endpoint.\n");		retval = -ENODEV;		goto error;	}	remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!remote->irq_urb) {		err("Failed to allocate urb.\n");		retval = -ENOMEM;		goto error;	}	retval = keyspan_setup(remote->udev);	if (retval) {		err("Failed to setup device.\n");		retval = -ENODEV;		goto error;	}	/*	 * Setup the input system with the bits we are going to be reporting	 */	remote->input.evbit[0] = BIT(EV_KEY);		/* We will only report KEY events. */	for (i = 0; i < 32; ++i) {		if (keyspan_key_table[i] != KEY_RESERVED) {			set_bit(keyspan_key_table[i], remote->input.keybit);		}	}	remote->input.private = remote;	remote->input.open = keyspan_open;	remote->input.close = keyspan_close;	usb_make_path(remote->udev, path, 64);	sprintf(remote->phys, "%s/input0", path);	remote->input.name = remote->name;	remote->input.phys = remote->phys;	remote->input.id.bustype = BUS_USB;	remote->input.id.vendor = le16_to_cpu(remote->udev->descriptor.idVendor);	remote->input.id.product = le16_to_cpu(remote->udev->descriptor.idProduct);	remote->input.id.version = le16_to_cpu(remote->udev->descriptor.bcdDevice);	if (!(buf = kmalloc(63, GFP_KERNEL))) {		usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);		kfree(remote);		return -ENOMEM;	}	if (remote->udev->descriptor.iManufacturer &&	    usb_string(remote->udev, remote->udev->descriptor.iManufacturer, buf, 63) > 0)		strcat(remote->name, buf);	if (remote->udev->descriptor.iProduct &&	    usb_string(remote->udev, remote->udev->descriptor.iProduct, buf, 63) > 0)		sprintf(remote->name, "%s %s", remote->name, buf);	if (!strlen(remote->name))		sprintf(remote->name, "USB Keyspan Remote %04x:%04x",			remote->input.id.vendor, remote->input.id.product);	kfree(buf);	/*	 * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open()	 */	usb_fill_int_urb(remote->irq_urb,			 remote->udev, usb_rcvintpipe(remote->udev, remote->in_endpoint->bEndpointAddress),			 remote->in_buffer, RECV_SIZE, keyspan_irq_recv, remote,			 remote->in_endpoint->bInterval);	remote->irq_urb->transfer_dma = remote->in_dma;	remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	/* we can register the device now, as it is ready */	input_register_device(&remote->input);	/* save our data pointer in this interface device */	usb_set_intfdata(interface, remote);	/* let the user know what node this device is now attached to */	info("connected: %s on %s", remote->name, path);	return 0;error:	/*	 * In case of error we need to clean up any allocated buffers	 */	if (remote->irq_urb)		usb_free_urb(remote->irq_urb);	if (remote->in_buffer)		usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);	if (remote)		kfree(remote);	return retval;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/ef0840286045fe7ce84cb77e7608f0844c81001c/keyspan_remote.c/buggy/drivers/usb/input/keyspan_remote.c