stk = kmalloc(sizeof(*stk), GFP_KERNEL); 
stk = kzalloc(sizeof(*stk), GFP_KERNEL); 
static void ide_config(dev_link_t *link){    client_handle_t handle = link->handle;    ide_info_t *info = link->priv;    tuple_t tuple;    struct {	u_short		buf[128];	cisparse_t	parse;	config_info_t	conf;	cistpl_cftable_entry_t dflt;    } *stk = NULL;    cistpl_cftable_entry_t *cfg;    int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0;    unsigned long io_base, ctl_base;    DEBUG(0, "ide_config(0x%p)\n", link);    stk = kmalloc(sizeof(*stk), GFP_KERNEL);    if (!stk) goto err_mem;    memset(stk, 0, sizeof(*stk));    cfg = &stk->parse.cftable_entry;    tuple.TupleData = (cisdata_t *)&stk->buf;    tuple.TupleOffset = 0;    tuple.TupleDataMax = 255;    tuple.Attributes = 0;    tuple.DesiredTuple = CISTPL_CONFIG;    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &stk->parse));    link->conf.ConfigBase = stk->parse.config.base;    link->conf.Present = stk->parse.config.rmask[0];    tuple.DesiredTuple = CISTPL_MANFID;    if (!pcmcia_get_first_tuple(handle, &tuple) &&	!pcmcia_get_tuple_data(handle, &tuple) &&	!pcmcia_parse_tuple(handle, &tuple, &stk->parse))	is_kme = ((stk->parse.manfid.manf == MANFID_KME) &&		  ((stk->parse.manfid.card == PRODID_KME_KXLC005_A) ||		   (stk->parse.manfid.card == PRODID_KME_KXLC005_B)));    /* Configure card */    link->state |= DEV_CONFIG;    /* Not sure if this is right... look up the current Vcc */    CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &stk->conf));    link->conf.Vcc = stk->conf.Vcc;    pass = io_base = ctl_base = 0;    tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;    tuple.Attributes = 0;    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));    while (1) {    	if (pcmcia_get_tuple_data(handle, &tuple) != 0) goto next_entry;	if (pcmcia_parse_tuple(handle, &tuple, &stk->parse) != 0) goto next_entry;	/* Check for matching Vcc, unless we're desperate */	if (!pass) {	    if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {		if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)		    goto next_entry;	    } else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {		if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000)		    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 (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))	    link->conf.Vpp1 = link->conf.Vpp2 =		stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;	if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) {	    cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io;	    link->conf.ConfigIndex = cfg->index;	    link->io.BasePort1 = io->win[0].base;	    link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;	    if (!(io->flags & CISTPL_IO_16BIT))		link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;	    if (io->nwin == 2) {		link->io.NumPorts1 = 8;		link->io.BasePort2 = io->win[1].base;		link->io.NumPorts2 = (is_kme) ? 2 : 1;		if (pcmcia_request_io(link->handle, &link->io) != 0)			goto next_entry;		io_base = link->io.BasePort1;		ctl_base = link->io.BasePort2;	    } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {		link->io.NumPorts1 = io->win[0].len;		link->io.NumPorts2 = 0;		if (pcmcia_request_io(link->handle, &link->io) != 0)			goto next_entry;		io_base = link->io.BasePort1;		ctl_base = link->io.BasePort1 + 0x0e;	    } else goto next_entry;	    /* If we've got this far, we're done */	    break;	}    next_entry:	if (cfg->flags & CISTPL_CFTABLE_DEFAULT)	    memcpy(&stk->dflt, cfg, sizeof(stk->dflt));	if (pass) {	    CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));	} else if (pcmcia_get_next_tuple(handle, &tuple) != 0) {	    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));	    memset(&stk->dflt, 0, sizeof(stk->dflt));	    pass++;	}    }    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));    /* disable drive interrupts during IDE probe */    outb(0x02, ctl_base);    /* special setup for KXLC005 card */    if (is_kme)	outb(0x81, ctl_base+1);    /* retry registration in case device is still spinning up */    for (hd = -1, i = 0; i < 10; i++) {	hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ);	if (hd >= 0) break;	if (link->io.NumPorts1 == 0x20) {	    outb(0x02, ctl_base + 0x10);	    hd = idecs_register(io_base + 0x10, ctl_base + 0x10,				link->irq.AssignedIRQ);	    if (hd >= 0) {		io_base += 0x10;		ctl_base += 0x10;		break;	    }	}	msleep(100);    }    if (hd < 0) {	printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3lx & 0x%3lx"	       ", irq %u failed\n", io_base, ctl_base,	       link->irq.AssignedIRQ);	goto failed;    }    info->ndev = 1;    sprintf(info->node.dev_name, "hd%c", 'a' + (hd * 2));    info->node.major = ide_major[hd];    info->node.minor = 0;    info->hd = hd;    link->dev = &info->node;    printk(KERN_INFO "ide-cs: %s: Vcc = %d.%d, Vpp = %d.%d\n",	   info->node.dev_name, link->conf.Vcc / 10, link->conf.Vcc % 10,	   link->conf.Vpp1 / 10, link->conf.Vpp1 % 10);    link->state &= ~DEV_CONFIG_PENDING;    kfree(stk);    return;err_mem:    printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n");    goto failed;cs_failed:    cs_error(link->handle, last_fn, last_ret);failed:    kfree(stk);    ide_release(link);    link->state &= ~DEV_CONFIG_PENDING;} /* ide_config */
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/f5e3c2faa20615e900ab26bd957f898400435924/ide-cs.c/buggy/drivers/ide/legacy/ide-cs.c