hid->input = input_dev; 
adbhid_input_register(int id, int default_id, int original_handler_id,		      int current_handler_id, int mouse_kind){	struct adbhid *hid;	struct input_dev *input_dev;	int err;	int i;	if (adbhid[id]) {		printk(KERN_ERR "Trying to reregister ADB HID on ID %d\n", id);		return -EEXIST;	}	adbhid[id] = hid = kzalloc(sizeof(struct adbhid), GFP_KERNEL);	input_dev = input_allocate_device();	if (!hid || !input_dev) {		err = -ENOMEM;		goto fail;	}	sprintf(hid->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id);	hid->id = default_id;	hid->original_handler_id = original_handler_id;	hid->current_handler_id = current_handler_id;	hid->mouse_kind = mouse_kind;	hid->flags = 0;	input_dev->private = hid;	input_dev->name = hid->name;	input_dev->phys = hid->phys;	input_dev->id.bustype = BUS_ADB;	input_dev->id.vendor = 0x0001;	input_dev->id.product = (id << 12) | (default_id << 8) | original_handler_id;	input_dev->id.version = 0x0100;	switch (default_id) {	case ADB_KEYBOARD:		hid->keycode = kmalloc(sizeof(adb_to_linux_keycodes), GFP_KERNEL);		if (!hid->keycode) {			err = -ENOMEM;			goto fail;		}		sprintf(hid->name, "ADB keyboard");		memcpy(hid->keycode, adb_to_linux_keycodes, sizeof(adb_to_linux_keycodes));		printk(KERN_INFO "Detected ADB keyboard, type ");		switch (original_handler_id) {		default:			printk("<unknown>.\n");			input_dev->id.version = ADB_KEYBOARD_UNKNOWN;			break;		case 0x01: case 0x02: case 0x03: case 0x06: case 0x08:		case 0x0C: case 0x10: case 0x18: case 0x1B: case 0x1C:		case 0xC0: case 0xC3: case 0xC6:			printk("ANSI.\n");			input_dev->id.version = ADB_KEYBOARD_ANSI;			break;		case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D:		case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1:		case 0xC4: case 0xC7:			printk("ISO, swapping keys.\n");			input_dev->id.version = ADB_KEYBOARD_ISO;			i = hid->keycode[10];			hid->keycode[10] = hid->keycode[50];			hid->keycode[50] = i;			break;		case 0x12: case 0x15: case 0x16: case 0x17: case 0x1A:		case 0x1E: case 0xC2: case 0xC5: case 0xC8: case 0xC9:			printk("JIS.\n");			input_dev->id.version = ADB_KEYBOARD_JIS;			break;		}		for (i = 0; i < 128; i++)			if (hid->keycode[i])				set_bit(hid->keycode[i], input_dev->keybit);		input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);		input_dev->ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML);		input_dev->event = adbhid_kbd_event;		input_dev->keycodemax = 127;		input_dev->keycodesize = 1;		break;	case ADB_MOUSE:		sprintf(hid->name, "ADB mouse");		input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);		input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);		input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);		break;	case ADB_MISC:		switch (original_handler_id) {		case 0x02: /* Adjustable keyboard button device */			sprintf(hid->name, "ADB adjustable keyboard buttons");			input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);			set_bit(KEY_SOUND, input_dev->keybit);			set_bit(KEY_MUTE, input_dev->keybit);			set_bit(KEY_VOLUMEUP, input_dev->keybit);			set_bit(KEY_VOLUMEDOWN, input_dev->keybit);			break;		case 0x1f: /* Powerbook button device */			sprintf(hid->name, "ADB Powerbook buttons");			input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);			set_bit(KEY_MUTE, input_dev->keybit);			set_bit(KEY_VOLUMEUP, input_dev->keybit);			set_bit(KEY_VOLUMEDOWN, input_dev->keybit);			set_bit(KEY_BRIGHTNESSUP, input_dev->keybit);			set_bit(KEY_BRIGHTNESSDOWN, input_dev->keybit);			set_bit(KEY_EJECTCD, input_dev->keybit);			set_bit(KEY_SWITCHVIDEOMODE, input_dev->keybit);			set_bit(KEY_KBDILLUMTOGGLE, input_dev->keybit);			set_bit(KEY_KBDILLUMDOWN, input_dev->keybit);			set_bit(KEY_KBDILLUMUP, input_dev->keybit);			break;		}		if (hid->name[0])			break;		/* else fall through */	default:		printk(KERN_INFO "Trying to register unknown ADB device to input layer.\n");		err = -ENODEV;		goto fail;	}	input_dev->keycode = hid->keycode;	input_register_device(input_dev);	if (default_id == ADB_KEYBOARD) {		/* HACK WARNING!! This should go away as soon there is an utility		 * to control that for event devices.		 */		input_dev->rep[REP_DELAY] = 500;   /* input layer default: 250 */		input_dev->rep[REP_PERIOD] = 66; /* input layer default: 33 */	}	return 0; fail:	input_free_device(input_dev);	kfree(hid);	adbhid[id] = NULL;	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/eb16292ba8a6655a560ab10a7d73a7816f0c0ac0/adbhid.c/clean/drivers/macintosh/adbhid.c