int sdla_set_config(struct net_device *dev, struct ifmap *map) 
static int sdla_set_config(struct net_device *dev, struct ifmap *map) 
int sdla_set_config(struct net_device *dev, struct ifmap *map){	struct frad_local *flp;	int               i;	char              byte;	unsigned base;	int err = -EINVAL;	flp = dev->priv;	if (flp->initialized)		return(-EINVAL);	for(i=0;i < sizeof(valid_port) / sizeof (int) ; i++)		if (valid_port[i] == map->base_addr)			break;   	if (i == sizeof(valid_port) / sizeof(int))		return(-EINVAL);	if (!request_region(map->base_addr, SDLA_IO_EXTENTS, dev->name)){		printk(KERN_WARNING "SDLA: io-port 0x%04lx in use \n", dev->base_addr);		return(-EINVAL);	}	base = map->base_addr;	/* test for card types, S502A, S502E, S507, S508                 */	/* these tests shut down the card completely, so clear the state */	flp->type = SDLA_UNKNOWN;	flp->state = 0;   	for(i=1;i<SDLA_IO_EXTENTS;i++)		if (inb(base + i) != 0xFF)			break;	if (i == SDLA_IO_EXTENTS) {   		outb(SDLA_HALT, base + SDLA_REG_Z80_CONTROL);		if ((inb(base + SDLA_S502_STS) & 0x0F) == 0x08) {			outb(SDLA_S502E_INTACK, base + SDLA_REG_CONTROL);			if ((inb(base + SDLA_S502_STS) & 0x0F) == 0x0C) {				outb(SDLA_HALT, base + SDLA_REG_CONTROL);				flp->type = SDLA_S502E;				goto got_type;			}		}	}	for(byte=inb(base),i=0;i<SDLA_IO_EXTENTS;i++)		if (inb(base + i) != byte)			break;	if (i == SDLA_IO_EXTENTS) {		outb(SDLA_HALT, base + SDLA_REG_CONTROL);		if ((inb(base + SDLA_S502_STS) & 0x7E) == 0x30) {			outb(SDLA_S507_ENABLE, base + SDLA_REG_CONTROL);			if ((inb(base + SDLA_S502_STS) & 0x7E) == 0x32) {				outb(SDLA_HALT, base + SDLA_REG_CONTROL);				flp->type = SDLA_S507;				goto got_type;			}		}	}	outb(SDLA_HALT, base + SDLA_REG_CONTROL);	if ((inb(base + SDLA_S508_STS) & 0x3F) == 0x00) {		outb(SDLA_S508_INTEN, base + SDLA_REG_CONTROL);		if ((inb(base + SDLA_S508_STS) & 0x3F) == 0x10) {			outb(SDLA_HALT, base + SDLA_REG_CONTROL);			flp->type = SDLA_S508;			goto got_type;		}	}	outb(SDLA_S502A_HALT, base + SDLA_REG_CONTROL);	if (inb(base + SDLA_S502_STS) == 0x40) {		outb(SDLA_S502A_START, base + SDLA_REG_CONTROL);		if (inb(base + SDLA_S502_STS) == 0x40) {			outb(SDLA_S502A_INTEN, base + SDLA_REG_CONTROL);			if (inb(base + SDLA_S502_STS) == 0x44) {				outb(SDLA_S502A_START, base + SDLA_REG_CONTROL);				flp->type = SDLA_S502A;				goto got_type;			}		}	}	printk(KERN_NOTICE "%s: Unknown card type\n", dev->name);	err = -ENODEV;	goto fail;got_type:	switch(base) {		case 0x270:		case 0x280:		case 0x380: 		case 0x390:			if (flp->type != SDLA_S508 && flp->type != SDLA_S507)				goto fail;	}	switch (map->irq) {		case 2:			if (flp->type != SDLA_S502E)				goto fail;			break;		case 10:		case 11:		case 12:		case 15:		case 4:			if (flp->type != SDLA_S508 && flp->type != SDLA_S507)				goto fail;			break;		case 3:		case 5:		case 7:			if (flp->type == SDLA_S502A)				goto fail;			break;		default:			goto fail;	}	err = -EAGAIN;	if (request_irq(dev->irq, &sdla_isr, 0, dev->name, dev)) 		goto fail;	if (flp->type == SDLA_S507) {		switch(dev->irq) {			case 3:				flp->state = SDLA_S507_IRQ3;				break;			case 4:				flp->state = SDLA_S507_IRQ4;				break;			case 5:				flp->state = SDLA_S507_IRQ5;				break;			case 7:				flp->state = SDLA_S507_IRQ7;				break;			case 10:				flp->state = SDLA_S507_IRQ10;				break;			case 11:				flp->state = SDLA_S507_IRQ11;				break;			case 12:				flp->state = SDLA_S507_IRQ12;				break;			case 15:				flp->state = SDLA_S507_IRQ15;				break;		}	}	for(i=0;i < sizeof(valid_mem) / sizeof (int) ; i++)		if (valid_mem[i] == map->mem_start)			break;   	err = -EINVAL;	if (i == sizeof(valid_mem) / sizeof(int))		goto fail2;	if (flp->type == SDLA_S502A && (map->mem_start & 0xF000) >> 12 == 0x0E)		goto fail2;	if (flp->type != SDLA_S507 && map->mem_start >> 16 == 0x0B)		goto fail2;	if (flp->type == SDLA_S507 && map->mem_start >> 16 == 0x0D)		goto fail2;	byte = flp->type != SDLA_S508 ? SDLA_8K_WINDOW : 0;	byte |= (map->mem_start & 0xF000) >> (12 + (flp->type == SDLA_S508 ? 1 : 0));	switch(flp->type) {		case SDLA_S502A:		case SDLA_S502E:			switch (map->mem_start >> 16) {				case 0x0A:					byte |= SDLA_S502_SEG_A;					break;				case 0x0C:					byte |= SDLA_S502_SEG_C;					break;				case 0x0D:					byte |= SDLA_S502_SEG_D;					break;				case 0x0E:					byte |= SDLA_S502_SEG_E;					break;			}			break;		case SDLA_S507:			switch (map->mem_start >> 16) {				case 0x0A:					byte |= SDLA_S507_SEG_A;					break;				case 0x0B:					byte |= SDLA_S507_SEG_B;					break;				case 0x0C:					byte |= SDLA_S507_SEG_C;					break;				case 0x0E:					byte |= SDLA_S507_SEG_E;					break;			}			break;		case SDLA_S508:			switch (map->mem_start >> 16) {				case 0x0A:					byte |= SDLA_S508_SEG_A;					break;				case 0x0C:					byte |= SDLA_S508_SEG_C;					break;				case 0x0D:					byte |= SDLA_S508_SEG_D;					break;				case 0x0E:					byte |= SDLA_S508_SEG_E;					break;			}			break;	}	/* set the memory bits, and enable access */	outb(byte, base + SDLA_REG_PC_WINDOW);	switch(flp->type)	{		case SDLA_S502E:			flp->state = SDLA_S502E_ENABLE;			break;		case SDLA_S507:			flp->state |= SDLA_MEMEN;			break;		case SDLA_S508:			flp->state = SDLA_MEMEN;			break;	}	outb(flp->state, base + SDLA_REG_CONTROL);	dev->irq = map->irq;	dev->base_addr = base;	dev->mem_start = map->mem_start;	dev->mem_end = dev->mem_start + 0x2000;	flp->initialized = 1;	return 0;fail2:	free_irq(map->irq, dev);fail:	release_region(base, SDLA_IO_EXTENTS);	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7665a08928f241247afe8c76865cdbe4ef5489bf/sdla.c/clean/drivers/net/wan/sdla.c