* is mapped to /{devfs}/input/eventN. 
* is mapped to input/eventN. 
aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *usbdev = interface_to_usbdev(intf);	struct usb_endpoint_descriptor *endpoint;	struct aiptek *aiptek;	struct input_dev *inputdev;	struct input_handle *inputhandle;	struct list_head *node, *next;	int i;	int speeds[] = { 0,		AIPTEK_PROGRAMMABLE_DELAY_50,		AIPTEK_PROGRAMMABLE_DELAY_400,		AIPTEK_PROGRAMMABLE_DELAY_25,		AIPTEK_PROGRAMMABLE_DELAY_100,		AIPTEK_PROGRAMMABLE_DELAY_200,		AIPTEK_PROGRAMMABLE_DELAY_300	};	/* programmableDelay is where the command-line specified	 * delay is kept. We make it the first element of speeds[],	 * so therefore, your override speed is tried first, then the	 * remainder. Note that the default value of 400ms will be tried	 * if you do not specify any command line parameter.	 */	speeds[0] = programmableDelay;	aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL);	inputdev = input_allocate_device();	if (!aiptek || !inputdev)		goto fail1;	aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,					SLAB_ATOMIC, &aiptek->data_dma);	if (!aiptek->data)		goto fail1;	aiptek->urb = usb_alloc_urb(0, GFP_KERNEL);	if (!aiptek->urb)		goto fail2;	aiptek->inputdev = inputdev;	aiptek->usbdev = usbdev;	aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber;	aiptek->inDelay = 0;	aiptek->endDelay = 0;	aiptek->previousJitterable = 0;	/* Set up the curSettings struct. Said struct contains the current	 * programmable parameters. The newSetting struct contains changes	 * the user makes to the settings via the sysfs interface. Those	 * changes are not "committed" to curSettings until the user	 * writes to the sysfs/.../execute file.	 */	aiptek->curSetting.pointerMode = AIPTEK_POINTER_EITHER_MODE;	aiptek->curSetting.coordinateMode = AIPTEK_COORDINATE_ABSOLUTE_MODE;	aiptek->curSetting.toolMode = AIPTEK_TOOL_BUTTON_PEN_MODE;	aiptek->curSetting.xTilt = AIPTEK_TILT_DISABLE;	aiptek->curSetting.yTilt = AIPTEK_TILT_DISABLE;	aiptek->curSetting.mouseButtonLeft = AIPTEK_MOUSE_LEFT_BUTTON;	aiptek->curSetting.mouseButtonMiddle = AIPTEK_MOUSE_MIDDLE_BUTTON;	aiptek->curSetting.mouseButtonRight = AIPTEK_MOUSE_RIGHT_BUTTON;	aiptek->curSetting.stylusButtonUpper = AIPTEK_STYLUS_UPPER_BUTTON;	aiptek->curSetting.stylusButtonLower = AIPTEK_STYLUS_LOWER_BUTTON;	aiptek->curSetting.jitterDelay = jitterDelay;	aiptek->curSetting.programmableDelay = programmableDelay;	/* Both structs should have equivalent settings	 */	aiptek->newSetting = aiptek->curSetting;	/* Determine the usb devices' physical path.	 * Asketh not why we always pretend we're using "../input0",	 * but I suspect this will have to be refactored one	 * day if a single USB device can be a keyboard & a mouse	 * & a tablet, and the inputX number actually will tell	 * us something...	 */	usb_make_path(usbdev, aiptek->features.usbPath,			sizeof(aiptek->features.usbPath));	strlcat(aiptek->features.usbPath, "/input0",		sizeof(aiptek->features.usbPath));	/* Set up client data, pointers to open and close routines	 * for the input device.	 */	inputdev->name = "Aiptek";	inputdev->phys = aiptek->features.usbPath;	usb_to_input_id(usbdev, &inputdev->id);	inputdev->cdev.dev = &intf->dev;	inputdev->private = aiptek;	inputdev->open = aiptek_open;	inputdev->close = aiptek_close;	/* Now program the capacities of the tablet, in terms of being	 * an input device.	 */	inputdev->evbit[0] |= BIT(EV_KEY)	    | BIT(EV_ABS)	    | BIT(EV_REL)	    | BIT(EV_MSC);	inputdev->absbit[0] |= BIT(ABS_MISC);	inputdev->relbit[0] |=	    (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC));	inputdev->keybit[LONG(BTN_LEFT)] |=	    (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE));	inputdev->keybit[LONG(BTN_DIGI)] |=	    (BIT(BTN_TOOL_PEN) |	     BIT(BTN_TOOL_RUBBER) |	     BIT(BTN_TOOL_PENCIL) |	     BIT(BTN_TOOL_AIRBRUSH) |	     BIT(BTN_TOOL_BRUSH) |	     BIT(BTN_TOOL_MOUSE) |	     BIT(BTN_TOOL_LENS) |	     BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2));	inputdev->mscbit[0] = BIT(MSC_SERIAL);	/* Programming the tablet macro keys needs to be done with a for loop	 * as the keycodes are discontiguous.	 */	for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i)		set_bit(macroKeyEvents[i], inputdev->keybit);	/*	 * Program the input device coordinate capacities. We do not yet	 * know what maximum X, Y, and Z values are, so we're putting fake	 * values in. Later, we'll ask the tablet to put in the correct	 * values.	 */	input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0);	input_set_abs_params(inputdev, ABS_X, 0, 2249, 0, 0);	input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0);	input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);	input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);	input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0);	endpoint = &intf->altsetting[0].endpoint[0].desc;	/* Go set up our URB, which is called when the tablet receives	 * input.	 */	usb_fill_int_urb(aiptek->urb,			 aiptek->usbdev,			 usb_rcvintpipe(aiptek->usbdev,					endpoint->bEndpointAddress),			 aiptek->data, 8, aiptek_irq, aiptek,			 endpoint->bInterval);	aiptek->urb->transfer_dma = aiptek->data_dma;	aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	/* Program the tablet. This sets the tablet up in the mode	 * specified in newSetting, and also queries the tablet's	 * physical capacities.	 *	 * Sanity check: if a tablet doesn't like the slow programmatic	 * delay, we often get sizes of 0x0. Let's use that as an indicator	 * to try faster delays, up to 25 ms. If that logic fails, well, you'll	 * have to explain to us how your tablet thinks it's 0x0, and yet that's	 * not an error :-)	 */	for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) {		aiptek->curSetting.programmableDelay = speeds[i];		(void)aiptek_program_tablet(aiptek);		if (aiptek->inputdev->absmax[ABS_X] > 0) {			info("input: Aiptek using %d ms programming speed\n",			     aiptek->curSetting.programmableDelay);			break;		}	}	/* Register the tablet as an Input Device	 */	input_register_device(aiptek->inputdev);	/* We now will look for the evdev device which is mapped to	 * the tablet. The partial name is kept in the link list of	 * input_handles associated with this input device.	 * What identifies an evdev input_handler is that it begins	 * with 'event', continues with a digit, and that in turn	 * is mapped to /{devfs}/input/eventN.	 */	list_for_each_safe(node, next, &inputdev->h_list) {		inputhandle = to_handle(node);		if (strncmp(inputhandle->name, "event", 5) == 0) {			strcpy(aiptek->features.inputPath, inputhandle->name);			break;		}	}	/* Associate this driver's struct with the usb interface.	 */	usb_set_intfdata(intf, aiptek);	/* Set up the sysfs files	 */	aiptek_add_files(&intf->dev);	/* Make sure the evdev module is loaded. Assuming evdev IS a module :-)	 */	if (request_module("evdev") != 0)		info("aiptek: error loading 'evdev' module");	return 0;fail2:	usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,			aiptek->data_dma);fail1:	input_free_device(inputdev);	kfree(aiptek);	return -ENOMEM;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/d6e5bcf4a7ebbe258124a931f1449338340a99b5/aiptek.c/buggy/drivers/usb/input/aiptek.c