int err = 0, eeprom_outdated = 0; 
int err, eeprom_outdated = 0; 
cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent){	static int first_time = 1;	ucchar cpc_rev_id;	int err = 0, eeprom_outdated = 0;	ucshort device_id;	pc300_t *card;	if (first_time) {		first_time = 0;		show_version();#ifdef CONFIG_PC300_MLPPP		cpc_tty_reset_var();#endif	}	card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL);	if (card == NULL) {		printk("PC300 found at RAM 0x%08lx, "		       "but could not allocate card structure.\n",		       pci_resource_start(pdev, 3));		return -ENOMEM;	}	memset(card, 0, sizeof(pc300_t));	/* read PCI configuration area */	device_id = ent->device;	card->hw.irq = pdev->irq;	card->hw.iophys = pci_resource_start(pdev, 1);	card->hw.iosize = pci_resource_len(pdev, 1);	card->hw.scaphys = pci_resource_start(pdev, 2);	card->hw.scasize = pci_resource_len(pdev, 2);	card->hw.ramphys = pci_resource_start(pdev, 3);	card->hw.alloc_ramsize = pci_resource_len(pdev, 3);	card->hw.falcphys = pci_resource_start(pdev, 4);	card->hw.falcsize = pci_resource_len(pdev, 4);	card->hw.plxphys = pci_resource_start(pdev, 5);	card->hw.plxsize = pci_resource_len(pdev, 5);	pci_read_config_byte(pdev, PCI_REVISION_ID, &cpc_rev_id);	switch (device_id) {		case PCI_DEVICE_ID_PC300_RX_1:		case PCI_DEVICE_ID_PC300_TE_1:		case PCI_DEVICE_ID_PC300_TE_M_1:			card->hw.nchan = 1;			break;		case PCI_DEVICE_ID_PC300_RX_2:		case PCI_DEVICE_ID_PC300_TE_2:		case PCI_DEVICE_ID_PC300_TE_M_2:		default:			card->hw.nchan = PC300_MAXCHAN;			break;	}#ifdef PC300_DEBUG_PCI	printk("cpc (bus=0x0%x,pci_id=0x%x,", pdev->bus->number, pdev->devfn);	printk("rev_id=%d) IRQ%d\n", cpc_rev_id, card->hw.irq);	printk("cpc:found  ramaddr=0x%08lx plxaddr=0x%08lx "	       "ctladdr=0x%08lx falcaddr=0x%08lx\n",	       card->hw.ramphys, card->hw.plxphys, card->hw.scaphys,	       card->hw.falcphys);#endif	/* Although we don't use this I/O region, we should	 * request it from the kernel anyway, to avoid problems	 * with other drivers accessing it. */	if (!request_region(card->hw.iophys, card->hw.iosize, "PLX Registers")) {		/* In case we can't allocate it, warn user */		printk("WARNING: couldn't allocate I/O region for PC300 board "		       "at 0x%08x!\n", card->hw.ramphys);	}	if (card->hw.plxphys) {		pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, card->hw.plxphys);	} else {		eeprom_outdated = 1;		card->hw.plxphys = pci_resource_start(pdev, 0);		card->hw.plxsize = pci_resource_len(pdev, 0);	}	if (!request_mem_region(card->hw.plxphys, card->hw.plxsize,				"PLX Registers")) {		printk("PC300 found at RAM 0x%08x, "		       "but could not allocate PLX mem region.\n",		       card->hw.ramphys);		err = -ENODEV;		goto err_release_io;	}	if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize,				"On-board RAM")) {		printk("PC300 found at RAM 0x%08x, "		       "but could not allocate RAM mem region.\n",		       card->hw.ramphys);		err = -ENODEV;		goto err_release_plx;	}	if (!request_mem_region(card->hw.scaphys, card->hw.scasize,				"SCA-II Registers")) {		printk("PC300 found at RAM 0x%08x, "		       "but could not allocate SCA mem region.\n",		       card->hw.ramphys);		err = -ENODEV;		goto err_release_ram;	}	if ((err = pci_enable_device(pdev)) != 0)		goto err_release_sca;	card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize);	card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize);	card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize);	switch (device_id) {		case PCI_DEVICE_ID_PC300_TE_1:		case PCI_DEVICE_ID_PC300_TE_2:		case PCI_DEVICE_ID_PC300_TE_M_1:		case PCI_DEVICE_ID_PC300_TE_M_2:			request_mem_region(card->hw.falcphys, card->hw.falcsize,					   "FALC Registers");			card->hw.falcbase = ioremap(card->hw.falcphys, card->hw.falcsize);			break;		case PCI_DEVICE_ID_PC300_RX_1:		case PCI_DEVICE_ID_PC300_RX_2:		default:			card->hw.falcbase = NULL;			break;	}#ifdef PC300_DEBUG_PCI	printk("cpc: relocate ramaddr=0x%08lx plxaddr=0x%08lx "	       "ctladdr=0x%08lx falcaddr=0x%08lx\n",	       card->hw.rambase, card->hw.plxbase, card->hw.scabase,	       card->hw.falcbase);#endif	/* Set PCI drv pointer to the card structure */	pci_set_drvdata(pdev, card);	/* Set board type */	switch (device_id) {		case PCI_DEVICE_ID_PC300_TE_1:		case PCI_DEVICE_ID_PC300_TE_2:		case PCI_DEVICE_ID_PC300_TE_M_1:		case PCI_DEVICE_ID_PC300_TE_M_2:			card->hw.type = PC300_TE;			if ((device_id == PCI_DEVICE_ID_PC300_TE_M_1) ||			    (device_id == PCI_DEVICE_ID_PC300_TE_M_2)) {				card->hw.bus = PC300_PMC;				/* Set PLX register offsets */				card->hw.gpioc_reg = 0x54;				card->hw.intctl_reg = 0x4c;			} else {				card->hw.bus = PC300_PCI;				/* Set PLX register offsets */				card->hw.gpioc_reg = 0x50;				card->hw.intctl_reg = 0x4c;			}			break;		case PCI_DEVICE_ID_PC300_RX_1:		case PCI_DEVICE_ID_PC300_RX_2:		default:			card->hw.bus = PC300_PCI;			/* Set PLX register offsets */			card->hw.gpioc_reg = 0x50;			card->hw.intctl_reg = 0x4c;			if ((cpc_readl(card->hw.plxbase + card->hw.gpioc_reg) & PC300_CTYPE_MASK)) {				card->hw.type = PC300_X21;			} else {				card->hw.type = PC300_RSV;			}			break;	}	/* Allocate IRQ */	if (request_irq(card->hw.irq, cpc_intr, SA_SHIRQ, "Cyclades-PC300", card)) {		printk ("PC300 found at RAM 0x%08x, but could not allocate IRQ%d.\n",			 card->hw.ramphys, card->hw.irq);		goto err_io_unmap;	}	cpc_init_card(card);	if (eeprom_outdated)		printk("WARNING: PC300 with outdated EEPROM.\n");	return 0;err_io_unmap:	iounmap(card->hw.plxbase);	iounmap(card->hw.scabase);	iounmap(card->hw.rambase);	if (card->hw.type == PC300_TE) {		iounmap(card->hw.falcbase);		release_mem_region(card->hw.falcphys, card->hw.falcsize);	}err_release_sca:	release_mem_region(card->hw.scaphys, card->hw.scasize);err_release_ram:	release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize);err_release_plx:	release_mem_region(card->hw.plxphys, card->hw.plxsize);err_release_io:	release_region(card->hw.iophys, card->hw.iosize);	kfree(card);	return -ENODEV;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/e8108c98dd6d65613fa0ec9d2300f89c48d554bf/pc300_drv.c/clean/drivers/net/wan/pc300_drv.c