static int awc_i365_init(struct i365_socket * s) {

    struct net_device * dev;
    int i;


    dev = init_etherdev(0, sizeof(struct awc_private) );

//	dev->tx_queue_len = tx_queue_len;
    ether_setup(dev);

    dev->hard_start_xmit = 		&awc_start_xmit;
//	dev->set_config = 		&awc_config_misiganes,aga mitte awc_config;
    dev->get_stats = 		&awc_get_stats;
    dev->set_multicast_list = 	&awc_set_multicast_list;

    dev->init = &awc_init;
    dev->open = &awc_open;
    dev->stop = &awc_close;
    dev->irq = s->irq;
    dev->base_addr = s->io;
    dev->tx_timeout = &awc_tx_timeout;
    dev->watchdog_timeo = AWC_TX_TIMEOUT;


    awc_private_init( dev);

    i=0;
    while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
    if (!aironet4500_devices[i]) {
        aironet4500_devices[i]=dev;

        ((struct awc_private *)
         aironet4500_devices[i]->priv)->card_type = AIRONET4500_365;

        if (awc_proc_set_fun)
            awc_proc_set_fun(i);
    }

    if (register_netdev(dev) != 0) {
        printk(KERN_NOTICE "awc_cs: register_netdev() failed\n");
        goto failed;
    }

    return 0;

failed:
    return -1;
}
int awc4500_isa_probe(struct net_device *dev)
{
//	int cards_found = 0;
//	static int isa_index;	/* Static, for multiple probe calls. */
    int isa_irq_line = 0;
    int isa_ioaddr = 0;
//	int p;
    int card = 0;
    int i=0;

    if (! io[0] || ! irq[0]) {

//		printk("       Both irq and io params must be supplied  for ISA mode !!!\n");
        return -ENODEV;
    }

    printk(KERN_WARNING "     Aironet ISA Card in non-PNP(ISA) mode sometimes feels bad on interrupt \n");
    printk(KERN_WARNING "     Use aironet4500_pnp if any problems(i.e. card malfunctioning). \n");
    printk(KERN_WARNING "     Note that this isa probe is not friendly... must give exact parameters \n");

    while (irq[card] != 0) {

        isa_ioaddr = io[card];
        isa_irq_line = irq[card];

        request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr");

        if (!dev) {
            dev = init_etherdev(NULL, 0);
            if (!dev) {
                release_region(isa_ioaddr, AIRONET4X00_IO_SIZE);
                return (card == 0) ? -ENOMEM : 0;
            }
        }
        dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
        memset(dev->priv,0,sizeof(struct awc_private));
        if (!dev->priv) {
            printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
            return -1;
        };

        //	ether_setup(dev);

        //	dev->tx_queue_len = tx_queue_len;

        dev->hard_start_xmit = 		&awc_start_xmit;
        //	dev->set_config = 		&awc_config_misiganes,aga mitte awc_config;
        dev->get_stats = 		&awc_get_stats;
        //	dev->set_multicast_list = 	&awc_set_multicast_list;
        dev->change_mtu		=	awc_change_mtu;
        dev->init = &awc_init;
        dev->open = &awc_open;
        dev->stop = &awc_close;
        dev->base_addr = isa_ioaddr;
        dev->irq = isa_irq_line;
        dev->tx_timeout = &awc_tx_timeout;
        dev->watchdog_timeo = AWC_TX_TIMEOUT;

        request_irq(dev->irq,awc_interrupt ,SA_INTERRUPT ,"Aironet 4X00",dev);

        awc_private_init( dev);
        if ( awc_init(dev) ) {
            printk("card not found at irq %x mem %x\n",irq[card],io[card]);
            if (card==0)
                return -1;
            break;
        }

        i=0;
        while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
        if (!aironet4500_devices[i]) {
            aironet4500_devices[i]=dev;
            ((struct awc_private *)
             aironet4500_devices[i]->priv)->card_type = AIRONET4500_ISA;

            if (awc_proc_set_fun)
                awc_proc_set_fun(i);
        }

        card++;
    }
    if (card == 0 ) {
        return -ENODEV;
    };
    return 0;
}
static int awc_pci_init(struct net_device * dev, struct pci_dev *pdev,
                        int ioaddr, int cis_addr, int mem_addr, u8 pci_irq_line) {

    int i, allocd_dev = 0;

    if (!dev) {
        dev = init_etherdev(NULL, 0);
        if (!dev)
            return -ENOMEM;
        allocd_dev = 1;
    }
    dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
    if (!dev->priv) {
        if (allocd_dev) {
            unregister_netdev(dev);
            kfree(dev);
        }
        return -ENOMEM;
    }
    memset(dev->priv,0,sizeof(struct awc_private));
    if (!dev->priv) {
        printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
        if (allocd_dev) {
            unregister_netdev(dev);
            kfree(dev);
        }
        return -ENOMEM;
    };

//	ether_setup(dev);

//	dev->tx_queue_len = tx_queue_len;

    dev->hard_start_xmit = 		&awc_start_xmit;
//	dev->set_config = 		&awc_config_misiganes,aga mitte awc_config;
    dev->get_stats = 		&awc_get_stats;
//	dev->set_multicast_list = 	&awc_set_multicast_list;
    dev->change_mtu		=	awc_change_mtu;
    dev->init = &awc_init;
    dev->open = &awc_open;
    dev->stop = &awc_close;
    dev->base_addr = ioaddr;
    dev->irq = pci_irq_line;
    dev->tx_timeout = &awc_tx_timeout;
    dev->watchdog_timeo = AWC_TX_TIMEOUT;


    i = request_irq(dev->irq,awc_interrupt, SA_SHIRQ | SA_INTERRUPT, dev->name, dev);
    if (i) {
        kfree(dev->priv);
        dev->priv = NULL;
        if (allocd_dev) {
            unregister_netdev(dev);
            kfree(dev);
        }
        return i;
    }

    awc_private_init( dev);
    awc_init(dev);

    i=0;
    while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
    if (!aironet4500_devices[i]) {
        aironet4500_devices[i]=dev;
        ((struct awc_private *)
         aironet4500_devices[i]->priv)->card_type = AIRONET4500_PCI;

        if (awc_proc_set_fun)
            awc_proc_set_fun(i);
    }

//	if (register_netdev(dev) != 0) {
//		printk(KERN_NOTICE "awc_cs: register_netdev() failed\n");
//		goto failed;
//	}

    return 0;
//  failed:
//  	return -1;

}
int awc4500_pnp_probe(struct net_device *dev)
{
    int isa_index = 0;
    int isa_irq_line = 0;
    int isa_ioaddr = 0;
    int card = 0;
    int i=0;
    struct isapnp_dev * pnp_dev ;
    struct isapnp_logdev *logdev;

    while (1) {

        pnp_dev = isapnp_find_device(
                      ISAPNP_VENDOR('A','W','L'),
                      ISAPNP_DEVICE(1),
                      0);

        if (!pnp_dev) break;

        isa_index++;

        logdev = isapnp_find_logdev(pnp_dev, ISAPNP_VENDOR('A','W','L'),
                                    ISAPNP_FUNCTION(1),
                                    0);
        if (!logdev) {
            printk("No logical device found on Aironet board \n");
            return -ENODEV;
        }
        if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER) < 0) {
            printk("cfg begin failed for csn %x devnum %x \n",
                   logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
            return -EAGAIN;
        }
        isapnp_activate(logdev->PNP_DEV_NUMBER);	/* activate device */
        isapnp_cfg_end();

        isa_irq_line = logdev->irq;
        isa_ioaddr = logdev->resource[0].start;
        request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr");

        if (!dev) {
            dev = init_etherdev(NULL, 0);
            if (!dev) {
                release_region(isa_ioaddr, AIRONET4X00_IO_SIZE);
                isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER,
                                 logdev->PNP_DEV_NUMBER);
                isapnp_deactivate(logdev->PNP_DEV_NUMBER);
                isapnp_cfg_end();
                return -ENOMEM;
            }
        }
        dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
        memset(dev->priv,0,sizeof(struct awc_private));
        if (!dev->priv) {
            printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
            return -1;
        };
        ((struct awc_private *)dev->priv)->bus =  logdev;

        //	ether_setup(dev);

        //	dev->tx_queue_len = tx_queue_len;

        dev->hard_start_xmit = 		&awc_start_xmit;
        //	dev->set_config = 		&awc_config_misiganes,aga mitte awc_config;
        dev->get_stats = 		&awc_get_stats;
        //	dev->set_multicast_list = 	&awc_set_multicast_list;
        dev->change_mtu		=	awc_change_mtu;
        dev->init = &awc_init;
        dev->open = &awc_open;
        dev->stop = &awc_close;
        dev->base_addr = isa_ioaddr;
        dev->irq = isa_irq_line;
        dev->tx_timeout = &awc_tx_timeout;
        dev->watchdog_timeo = AWC_TX_TIMEOUT;

        netif_start_queue (dev);

        request_irq(dev->irq,awc_interrupt , SA_SHIRQ | SA_INTERRUPT ,"Aironet 4X00",dev);

        awc_private_init( dev);

        ((struct awc_private *)dev->priv)->bus =  logdev;

        cli();
        if ( awc_init(dev) ) {
            printk("card not found at irq %x io %lx\n",dev->irq, dev->base_addr);
            if (card==0) {
                sti();
                return -1;
            }
            sti();
            break;
        }
        udelay(10);
        sti();
        i=0;
        while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
        if (!aironet4500_devices[i] && i < MAX_AWCS-1 ) {
            aironet4500_devices[i]=dev;

            ((struct awc_private *)
             aironet4500_devices[i]->priv)->card_type = AIRONET4500_PNP;

            if (awc_proc_set_fun)
                awc_proc_set_fun(i);
        } else {
            printk(KERN_CRIT "Out of resources (MAX_AWCS) \n");
            return -1;
        }

        card++;
    }

    if (card == 0) return -ENODEV;
    return 0;
}
static void awc_pcmcia_config(dev_link_t *link)
{
	client_handle_t handle;
	struct net_device *dev;
	struct awc_private *lp;
	tuple_t tuple;
	int ii;
	cisparse_t parse;
	u_short buf[64];
	int last_fn, last_ret, i = 0;
//	int ioaddr;
	u16 *phys_addr;
	int retval;
	
	handle = link->handle;
	dev = link->priv;
	phys_addr = (u16 *)dev->dev_addr;

	PC_DEBUG(0, "awc_pcmcia_config(0x%p)\n", link);

	tuple.Attributes = 0;
	tuple.DesiredTuple = CISTPL_CONFIG;
	CS_CHECK(GetFirstTuple, handle, &tuple);
	tuple.TupleData = (cisdata_t *)buf;
	tuple.TupleDataMax = 64;
	tuple.TupleOffset = 0;
	CS_CHECK(GetTupleData, handle, &tuple);
	CS_CHECK(ParseTuple, handle, &tuple, &parse);
	link->conf.ConfigBase = parse.config.base;
	link->conf.Present = parse.config.rmask[0];


	/* Configure card */
	link->state |= DEV_CONFIG;

     	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
        CS_CHECK(GetFirstTuple, handle, &tuple);

    	while (1) {
		cistpl_cftable_entry_t dflt = { 0 };
		cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
		CFG_CHECK(GetTupleData, handle, &tuple);
		CFG_CHECK(ParseTuple, handle, &tuple, &parse);

		if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
		if (cfg->index == 0) goto next_entry;
		link->conf.ConfigIndex = cfg->index;

		/* 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))
		    link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000;
		else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM))
		    link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000;
	    
		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;
	
		/* IO window settings */
		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;
	    		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;
				printk(KERN_CRIT "8-bit IO not supported on this aironet 4500 driver \n");
	    		}
	    		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;
	    		}
		}
		ii = 0;
		last_fn = RequestIO;
		while ((last_ret = CardServices(RequestIO, link->handle, &link->io)) ){
		
			if (ii > 4) 
				goto cs_failed;
			link->io.BasePort1 = awc_ports[ii];
			ii++;
		};


		break;
	
    	next_entry:
		if (CardServices(GetNextTuple, handle, &tuple))
			break;
    	}
    
    	if (link->conf.Attributes & CONF_ENABLE_IRQ){
	
		ii = 0;  last_fn = RequestIRQ; 
		while ((last_ret  = CardServices(RequestIRQ, link->handle, &link->irq)) ){
		
			ii++;	
			while (!(irq_mask & (1 << ii) ) && ii < 15)
			 	ii++;
			link->irq.IRQInfo2 = 1 << ii;

			if(ii > 15)
				goto cs_failed;
			printk("trying irq %d , mask %x \n",ii, link->irq.IRQInfo2); 
			 
		};
	}

    	CS_CHECK(RequestConfiguration, link->handle, &link->conf);


    	dev->irq = link->irq.AssignedIRQ;
    	dev->base_addr = link->io.BasePort1;


	awc_private_init( dev);


	
	retval = register_netdev(dev);
	if (retval != 0) {
		printk(KERN_NOTICE "awc_cs: register_netdev() failed for dev %x retval %x\n",(unsigned int)dev,retval);
		goto failed;
	}

    	if(awc_pcmcia_init(dev)) goto failed;

	i=0;
	while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
	if (!aironet4500_devices[i]){
		aironet4500_devices[i]=dev;
		if (awc_proc_set_fun)
			awc_proc_set_fun(i);
	}
	

	link->state &= ~DEV_CONFIG_PENDING;

	lp = (struct awc_private *)dev->priv;

	DEBUG(1,"pcmcia config complete on port %x \n",(unsigned int)dev->base_addr);

	return;

cs_failed:
	cs_error(link->handle, last_fn, last_ret);
	link->dev=NULL;
failed:

	awc_release((u_long)link);
	return;

} /* awc_pcmcia_config */