aiptek->inputdev.dev = &intf->dev; 
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;	char path[64 + 1];	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;	if ((aiptek = kmalloc(sizeof(struct aiptek), GFP_KERNEL)) == NULL)		return -ENOMEM;	memset(aiptek, 0, sizeof(struct aiptek));	aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,					SLAB_ATOMIC, &aiptek->data_dma);	if (aiptek->data == NULL) {		kfree(aiptek);		return -ENOMEM;	}	aiptek->urb = usb_alloc_urb(0, GFP_KERNEL);	if (aiptek->urb == NULL) {		usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,				aiptek->data_dma);		kfree(aiptek);		return -ENOMEM;	}	/* 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	 */	memcpy(&aiptek->newSetting, &aiptek->curSetting,	       sizeof(struct aiptek_settings));	/* Now program the capacities of the tablet, in terms of being	 * an input device.	 */	aiptek->inputdev.evbit[0] |= BIT(EV_KEY)	    | BIT(EV_ABS)	    | BIT(EV_REL)	    | BIT(EV_MSC);	aiptek->inputdev.absbit[0] |=	    (BIT(ABS_X) |	     BIT(ABS_Y) |	     BIT(ABS_PRESSURE) |	     BIT(ABS_TILT_X) |	     BIT(ABS_TILT_Y) | BIT(ABS_WHEEL) | BIT(ABS_MISC));	aiptek->inputdev.relbit[0] |=	    (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC));	aiptek->inputdev.keybit[LONG(BTN_LEFT)] |=	    (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE));	aiptek->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));	aiptek->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], aiptek->inputdev.keybit);	/* Set up client data, pointers to open and close routines	 * for the input device.	 */	aiptek->inputdev.private = aiptek;	aiptek->inputdev.open = aiptek_open;	aiptek->inputdev.close = aiptek_close;	/* 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...	 */	if (usb_make_path(usbdev, path, 64) > 0)		sprintf(aiptek->features.usbPath, "%s/input0", path);	/* 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.	 */	aiptek->inputdev.absmin[ABS_X] = 0;	aiptek->inputdev.absmax[ABS_X] = 2999;	aiptek->inputdev.absmin[ABS_Y] = 0;	aiptek->inputdev.absmax[ABS_Y] = 2249;	aiptek->inputdev.absmin[ABS_PRESSURE] = 0;	aiptek->inputdev.absmax[ABS_PRESSURE] = 511;	aiptek->inputdev.absmin[ABS_TILT_X] = AIPTEK_TILT_MIN;	aiptek->inputdev.absmax[ABS_TILT_X] = AIPTEK_TILT_MAX;	aiptek->inputdev.absmin[ABS_TILT_Y] = AIPTEK_TILT_MIN;	aiptek->inputdev.absmax[ABS_TILT_Y] = AIPTEK_TILT_MAX;	aiptek->inputdev.absmin[ABS_WHEEL] = AIPTEK_WHEEL_MIN;	aiptek->inputdev.absmax[ABS_WHEEL] = AIPTEK_WHEEL_MAX - 1;	aiptek->inputdev.absfuzz[ABS_X] = 0;	aiptek->inputdev.absfuzz[ABS_Y] = 0;	aiptek->inputdev.absfuzz[ABS_PRESSURE] = 0;	aiptek->inputdev.absfuzz[ABS_TILT_X] = 0;	aiptek->inputdev.absfuzz[ABS_TILT_Y] = 0;	aiptek->inputdev.absfuzz[ABS_WHEEL] = 0;	aiptek->inputdev.absflat[ABS_X] = 0;	aiptek->inputdev.absflat[ABS_Y] = 0;	aiptek->inputdev.absflat[ABS_PRESSURE] = 0;	aiptek->inputdev.absflat[ABS_TILT_X] = 0;	aiptek->inputdev.absflat[ABS_TILT_Y] = 0;	aiptek->inputdev.absflat[ABS_WHEEL] = 0;	aiptek->inputdev.name = "Aiptek";	aiptek->inputdev.phys = aiptek->features.usbPath;	aiptek->inputdev.id.bustype = BUS_USB;	aiptek->inputdev.id.vendor = le16_to_cpu(usbdev->descriptor.idVendor);	aiptek->inputdev.id.product = le16_to_cpu(usbdev->descriptor.idProduct);	aiptek->inputdev.id.version = le16_to_cpu(usbdev->descriptor.bcdDevice);	aiptek->usbdev = usbdev;	aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber;	aiptek->inDelay = 0;	aiptek->endDelay = 0;	aiptek->previousJitterable = 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;	/* 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.	 */	inputdev = &aiptek->inputdev;	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;		}	}	info("input: Aiptek on %s (%s)\n", path, aiptek->features.inputPath);	/* 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;		}	}	/* 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;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/e838a0d4d5260bce452c96914a6e86b217c53c55/aiptek.c/clean/drivers/usb/input/aiptek.c