for (j = 0; j < 2; j++) if (tmdc->exists & (1 << j)) { 
for (i = 0; i < 2; i++) { if (tmdc->exists & (1 << i)) { 
static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv){	static struct models {		unsigned char id;		char *name;		char abs;		char hats;		char btnc[4];		char btno[4];		signed char *axes;		short *buttons;	} models[] = {	{   1, "ThrustMaster Millenium 3D Inceptor",	  6, 2, { 4, 2 }, { 4, 6 }, tmdc_abs, tmdc_btn_joy },			{   3, "ThrustMaster Rage 3D Gamepad",		  2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad },			{   4, "ThrustMaster Attack Throttle",		  5, 2, { 4, 6 }, { 4, 2 }, tmdc_abs_at, tmdc_btn_at },			{   8, "ThrustMaster FragMaster",		  4, 0, { 8, 2 }, { 0, 0 }, tmdc_abs_fm, tmdc_btn_fm },			{ 163, "Thrustmaster Fusion GamePad",		  2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad },			{   0, "Unknown %d-axis, %d-button TM device %d", 0, 0, { 0, 0 }, { 0, 0 }, tmdc_abs, tmdc_btn_joy }};	unsigned char data[2][TMDC_MAX_LENGTH];	struct tmdc *tmdc;	int i, j, k, l, m;	int err;	if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL)))		return -ENOMEM;	tmdc->gameport = gameport;	gameport_set_drvdata(gameport, tmdc);	err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);	if (err)		goto fail1;	if (!(tmdc->exists = tmdc_read_packet(gameport, data))) {		err = -ENODEV;		goto fail2;	}	gameport_set_poll_handler(gameport, tmdc_poll);	gameport_set_poll_interval(gameport, 20);	for (j = 0; j < 2; j++)		if (tmdc->exists & (1 << j)) {			tmdc->mode[j] = data[j][TMDC_BYTE_ID];			for (m = 0; models[m].id && models[m].id != tmdc->mode[j]; m++);			tmdc->abs[j] = models[m].axes;			tmdc->btn[j] = models[m].buttons;			if (!models[m].id) {				models[m].abs = data[j][TMDC_BYTE_DEF] >> 4;				for (k = 0; k < 4; k++)					models[m].btnc[k] = k < (data[j][TMDC_BYTE_DEF] & 0xf) ? 8 : 0;			}			tmdc->absc[j] = models[m].abs;			for (k = 0; k < 4; k++) {				tmdc->btnc[j][k] = models[m].btnc[k];				tmdc->btno[j][k] = models[m].btno[k];			}			sprintf(tmdc->name[j], models[m].name, models[m].abs,				(data[j][TMDC_BYTE_DEF] & 0xf) << 3, tmdc->mode[j]);			sprintf(tmdc->phys[j], "%s/input%d", gameport->phys, j);			tmdc->dev[j].private = tmdc;			tmdc->dev[j].open = tmdc_open;			tmdc->dev[j].close = tmdc_close;			tmdc->dev[j].name = tmdc->name[j];			tmdc->dev[j].phys = tmdc->phys[j];			tmdc->dev[j].id.bustype = BUS_GAMEPORT;			tmdc->dev[j].id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER;			tmdc->dev[j].id.product = models[m].id;			tmdc->dev[j].id.version = 0x0100;			tmdc->dev[j].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);			for (i = 0; i < models[m].abs && i < TMDC_ABS; i++)				if (tmdc->abs[j][i] >= 0)					input_set_abs_params(&tmdc->dev[j], tmdc->abs[j][i], 8, 248, 2, 4);			for (i = 0; i < models[m].hats && i < TMDC_ABS_HAT; i++)				input_set_abs_params(&tmdc->dev[j], tmdc_abs_hat[i], -1, 1, 0, 0);			for (k = l = 0; k < 4; k++) {				for (i = 0; i < models[m].btnc[k] && i < TMDC_BTN; i++)					set_bit(tmdc->btn[j][i + l], tmdc->dev[j].keybit);				l += models[m].btnc[k];			}			input_register_device(tmdc->dev + j);			printk(KERN_INFO "input: %s on %s\n", tmdc->name[j], gameport->phys);		}	return 0;fail2:	gameport_close(gameport);fail1:	gameport_set_drvdata(gameport, NULL);	kfree(tmdc);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/17dd3f0f7aa729a042af5d3318ff9b3e7781b45b/tmdc.c/buggy/drivers/input/joystick/tmdc.c