int i; 
static int prism2_config(dev_link_t *link){	struct net_device *dev;	struct hostap_interface *iface;	local_info_t *local;	int ret = 1;	tuple_t tuple;	cisparse_t *parse;	int last_fn, last_ret;	u_char buf[64];	config_info_t conf;	cistpl_cftable_entry_t dflt = { 0 };	PDEBUG(DEBUG_FLOW, "prism2_config()\n");	parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);	if (parse == NULL) {		ret = -ENOMEM;		goto failed;	}	tuple.DesiredTuple = CISTPL_CONFIG;	tuple.Attributes = 0;	tuple.TupleData = buf;	tuple.TupleDataMax = sizeof(buf);	tuple.TupleOffset = 0;	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple));	CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse));	link->conf.ConfigBase = parse->config.base;	link->conf.Present = parse->config.rmask[0];	CS_CHECK(GetConfigurationInfo,		 pcmcia_get_configuration_info(link->handle, &conf));	PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info,	       ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc);	link->conf.Vcc = conf.Vcc;	/* Look for an appropriate configuration table entry in the CIS */	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));	for (;;) {		cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);		CFG_CHECK2(GetTupleData,			   pcmcia_get_tuple_data(link->handle, &tuple));		CFG_CHECK2(ParseTuple,			   pcmcia_parse_tuple(link->handle, &tuple, parse));		if (cfg->flags & CISTPL_CFTABLE_DEFAULT)			dflt = *cfg;		if (cfg->index == 0)			goto next_entry;		link->conf.ConfigIndex = cfg->index;		PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "		       "(default 0x%02X)\n", cfg->index, dflt.index);			/* Does this card need audio output? */		if (cfg->flags & CISTPL_CFTABLE_AUDIO) {			link->conf.Attributes |= CONF_ENABLE_SPKR;			link->conf.Status = CCSR_AUDIO_ENA;		}			/* Use power settings for Vcc and Vpp if present */		/*  Note that the CIS values need to be rescaled */		if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {			if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /			    10000 && !ignore_cis_vcc) {				PDEBUG(DEBUG_EXTRA, "  Vcc mismatch - skipping"				       " this entry\n");				goto next_entry;			}		} else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {			if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] /			    10000 && !ignore_cis_vcc) {				PDEBUG(DEBUG_EXTRA, "  Vcc (default) mismatch "				       "- skipping this entry\n");				goto next_entry;			}		}		if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))			link->conf.Vpp1 = link->conf.Vpp2 =				cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;		else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))			link->conf.Vpp1 = link->conf.Vpp2 =				dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;		/* Do we need to allocate an interrupt? */		if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)			link->conf.Attributes |= CONF_ENABLE_IRQ;		else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) {			/* At least Compaq WL200 does not have IRQInfo1 set,			 * but it does not work without interrupts.. */			printk("Config has no IRQ info, but trying to enable "			       "IRQ anyway..\n");			link->conf.Attributes |= CONF_ENABLE_IRQ;		}		/* IO window settings */		PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "		       "dflt.io.nwin=%d\n",		       cfg->io.nwin, dflt.io.nwin);		link->io.NumPorts1 = link->io.NumPorts2 = 0;		if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {			cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;			link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;			PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "			       "io.base=0x%04x, len=%d\n", io->flags,			       io->win[0].base, io->win[0].len);			if (!(io->flags & CISTPL_IO_8BIT))				link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;			if (!(io->flags & CISTPL_IO_16BIT))				link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;			link->io.IOAddrLines = io->flags &				CISTPL_IO_LINES_MASK;			link->io.BasePort1 = io->win[0].base;			link->io.NumPorts1 = io->win[0].len;			if (io->nwin > 1) {				link->io.Attributes2 = link->io.Attributes1;				link->io.BasePort2 = io->win[1].base;				link->io.NumPorts2 = io->win[1].len;			}		}		/* This reserves IO space but doesn't actually enable it */		CFG_CHECK2(RequestIO,			   pcmcia_request_io(link->handle, &link->io));		/* This configuration table entry is OK */		break;	next_entry:		CS_CHECK(GetNextTuple,			 pcmcia_get_next_tuple(link->handle, &tuple));	}	/* Need to allocate net_device before requesting IRQ handler */	dev = prism2_init_local_data(&prism2_pccard_funcs, 0);	if (dev == NULL)		goto failed;	link->priv = dev;	/*	 * Allocate an interrupt line.  Note that this does not assign a	 * handler to the interrupt, unless the 'Handler' member of the	 * irq structure is initialized.	 */	if (link->conf.Attributes & CONF_ENABLE_IRQ) {		int i;		link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;		link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_LEVEL_ID;		if (irq_list[0] == -1)			link->irq.IRQInfo2 = irq_mask;		else			for (i = 0; i < 4; i++)				link->irq.IRQInfo2 |= 1 << irq_list[i];		link->irq.Handler = prism2_interrupt;		link->irq.Instance = dev;		CS_CHECK(RequestIRQ,			 pcmcia_request_irq(link->handle, &link->irq));	}	/*	 * This actually configures the PCMCIA socket -- setting up	 * the I/O windows and the interrupt mapping, and putting the	 * card and host interface into "Memory and IO" mode.	 */	CS_CHECK(RequestConfiguration,		 pcmcia_request_configuration(link->handle, &link->conf));	dev->irq = link->irq.AssignedIRQ;	dev->base_addr = link->io.BasePort1;	/* Finally, report what we've done */	printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",	       dev_info, link->conf.ConfigIndex,	       link->conf.Vcc / 10, link->conf.Vcc % 10);	if (link->conf.Vpp1)		printk(", Vpp %d.%d", link->conf.Vpp1 / 10,		       link->conf.Vpp1 % 10);	if (link->conf.Attributes & CONF_ENABLE_IRQ)		printk(", irq %d", link->irq.AssignedIRQ);	if (link->io.NumPorts1)		printk(", io 0x%04x-0x%04x", link->io.BasePort1,		       link->io.BasePort1+link->io.NumPorts1-1);	if (link->io.NumPorts2)		printk(" & 0x%04x-0x%04x", link->io.BasePort2,		       link->io.BasePort2+link->io.NumPorts2-1);	printk("\n");	link->state |= DEV_CONFIG;	link->state &= ~DEV_CONFIG_PENDING;	iface = netdev_priv(dev);	local = iface->local;	local->link = link;	strcpy(local->node.dev_name, dev->name);	link->dev = &local->node;	local->shutdown = 0;	sandisk_enable_wireless(dev);	ret = prism2_hw_config(dev, 1);	if (!ret) {		ret = hostap_hw_ready(dev);		if (ret == 0 && local->ddev)			strcpy(local->node.dev_name, local->ddev->name);	}	kfree(parse);	return ret; cs_failed:	cs_error(link->handle, last_fn, last_ret); failed:	kfree(parse);	prism2_release((u_long)link);	return ret;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/0ef79ee22cf5c1b177184c18b6525889bcc6681f/hostap_cs.c/buggy/drivers/net/wireless/hostap/hostap_cs.c