pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); 
if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL))) sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE1; else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, NULL))) sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3; else sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2; 
static int __devinit sonypi_probe(void){	int i, ret;	struct sonypi_ioport_list *ioport_list;	struct sonypi_irq_list *irq_list;	struct pci_dev *pcidev;	pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,				PCI_DEVICE_ID_INTEL_82371AB_3, NULL);	sonypi_device.dev = pcidev;	sonypi_device.model = pcidev ?		SONYPI_DEVICE_MODEL_TYPE1 : SONYPI_DEVICE_MODEL_TYPE2;	spin_lock_init(&sonypi_device.fifo_lock);	sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,					 &sonypi_device.fifo_lock);	if (IS_ERR(sonypi_device.fifo)) {		printk(KERN_ERR "sonypi: kfifo_alloc failed\n");		ret = PTR_ERR(sonypi_device.fifo);		goto out_fifo;	}	init_waitqueue_head(&sonypi_device.fifo_proc_list);	init_MUTEX(&sonypi_device.lock);	sonypi_device.bluetooth_power = -1;	if (pcidev && pci_enable_device(pcidev)) {		printk(KERN_ERR "sonypi: pci_enable_device failed\n");		ret = -EIO;		goto out_pcienable;	}	if (minor != -1)		sonypi_misc_device.minor = minor;	if ((ret = misc_register(&sonypi_misc_device))) {		printk(KERN_ERR "sonypi: misc_register failed\n");		goto out_miscreg;	}	if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) {		ioport_list = sonypi_type2_ioport_list;		sonypi_device.region_size = SONYPI_TYPE2_REGION_SIZE;		sonypi_device.evtype_offset = SONYPI_TYPE2_EVTYPE_OFFSET;		irq_list = sonypi_type2_irq_list;	} else {		ioport_list = sonypi_type1_ioport_list;		sonypi_device.region_size = SONYPI_TYPE1_REGION_SIZE;		sonypi_device.evtype_offset = SONYPI_TYPE1_EVTYPE_OFFSET;		irq_list = sonypi_type1_irq_list;	}	for (i = 0; ioport_list[i].port1; i++) {		if (request_region(ioport_list[i].port1,				   sonypi_device.region_size,				   "Sony Programable I/O Device")) {			/* get the ioport */			sonypi_device.ioport1 = ioport_list[i].port1;			sonypi_device.ioport2 = ioport_list[i].port2;			break;		}	}	if (!sonypi_device.ioport1) {		printk(KERN_ERR "sonypi: request_region failed\n");		ret = -ENODEV;		goto out_reqreg;	}	for (i = 0; irq_list[i].irq; i++) {		sonypi_device.irq = irq_list[i].irq;		sonypi_device.bits = irq_list[i].bits;		if (!request_irq(sonypi_device.irq, sonypi_irq,				 SA_SHIRQ, "sonypi", sonypi_irq))			break;	}	if (!irq_list[i].irq) {		printk(KERN_ERR "sonypi: request_irq failed\n");		ret = -ENODEV;		goto out_reqirq;	}	if (useinput) {		/* Initialize the Input Drivers: jogdial */		int i;		sonypi_device.input_jog_dev.evbit[0] =			BIT(EV_KEY) | BIT(EV_REL);		sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] =			BIT(BTN_MIDDLE);		sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL);		sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME;		sonypi_device.input_jog_dev.id.bustype = BUS_ISA;		sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY;		input_register_device(&sonypi_device.input_jog_dev);		printk(KERN_INFO "%s input method installed.\n",		       sonypi_device.input_jog_dev.name);		/* Initialize the Input Drivers: special keys */		sonypi_device.input_key_dev.evbit[0] = BIT(EV_KEY);		for (i = 0; sonypi_inputkeys[i].sonypiev; i++)			if (sonypi_inputkeys[i].inputev)				set_bit(sonypi_inputkeys[i].inputev,					sonypi_device.input_key_dev.keybit);		sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME;		sonypi_device.input_key_dev.id.bustype = BUS_ISA;		sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY;		input_register_device(&sonypi_device.input_key_dev);		printk(KERN_INFO "%s input method installed.\n",		       sonypi_device.input_key_dev.name);		spin_lock_init(&sonypi_device.input_fifo_lock);		sonypi_device.input_fifo =			kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,				    &sonypi_device.input_fifo_lock);		if (IS_ERR(sonypi_device.input_fifo)) {			printk(KERN_ERR "sonypi: kfifo_alloc failed\n");			ret = PTR_ERR(sonypi_device.input_fifo);			goto out_infifo;		}		INIT_WORK(&sonypi_device.input_work, input_keyrelease, NULL);	}	sonypi_device.pdev = platform_device_register_simple("sonypi", -1,							     NULL, 0);	if (IS_ERR(sonypi_device.pdev)) {		ret = PTR_ERR(sonypi_device.pdev);		goto out_platformdev;	}	sonypi_enable(0);	printk(KERN_INFO "sonypi: Sony Programmable I/O Controller Driver"	       "v%s.\n", SONYPI_DRIVER_VERSION);	printk(KERN_INFO "sonypi: detected %s model, "	       "verbose = %d, fnkeyinit = %s, camera = %s, "	       "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n",	       (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE1) ?			"type1" : "type2",	       verbose,	       fnkeyinit ? "on" : "off",	       camera ? "on" : "off",	       compat ? "on" : "off",	       mask,	       useinput ? "on" : "off",	       SONYPI_ACPI_ACTIVE ? "on" : "off");	printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n",	       sonypi_device.irq,	       sonypi_device.ioport1, sonypi_device.ioport2);	if (minor == -1)		printk(KERN_INFO "sonypi: device allocated minor is %d\n",		       sonypi_misc_device.minor);	return 0;out_platformdev:	kfifo_free(sonypi_device.input_fifo);out_infifo:	input_unregister_device(&sonypi_device.input_key_dev);	input_unregister_device(&sonypi_device.input_jog_dev);	free_irq(sonypi_device.irq, sonypi_irq);out_reqirq:	release_region(sonypi_device.ioport1, sonypi_device.region_size);out_reqreg:	misc_deregister(&sonypi_misc_device);out_miscreg:	if (pcidev)		pci_disable_device(pcidev);out_pcienable:	kfifo_free(sonypi_device.fifo);out_fifo:	pci_dev_put(sonypi_device.dev);	return ret;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/d2052c1676a39cae101a81f3da8a4ade8b668c88/sonypi.c/clean/drivers/char/sonypi.c