Пример #1
0
struct net_device *__init mambonet_probe(int unit)
{
	struct net_device *dev = alloc_etherdev(0);
	int err;

	if (!dev)
		return ERR_PTR(-ENODEV);

	sprintf(dev->name, "eth%d", unit);
	netdev_boot_setup_check(dev);

	err = do_mambonet_probe(dev);

	if (err)
		goto out;

	err = register_netdev(dev);
	if (err)
		goto out;

	return dev;

      out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #2
0
__NOMIPS16
#endif 
static struct net_device *init_netdev(struct net_device *dev, int sizeof_priv,
				      char *mask, void (*setup)(struct net_device *))
{
	int new_device = 0;

	/*
	 *	Allocate a device if one is not provided.
	 */
	 
	if (dev == NULL) {
		dev=init_alloc_dev(sizeof_priv);
		if(dev==NULL)
			return NULL;
		new_device = 1;
	}

	/*
	 *	Allocate a name
	 */
	 
	if (dev->name[0] == '\0' || dev->name[0] == ' ') {
		strcpy(dev->name, mask);
		if (dev_alloc_name(dev, mask)<0) {
			if (new_device)
				kfree(dev);
			return NULL;
		}
	}

	netdev_boot_setup_check(dev);
	
	/*
	 *	Configure via the caller provided setup function then
	 *	register if needed.
	 */
	
	setup(dev);
	
	if (new_device) {
		int err;

		rtnl_lock();
		err = register_netdevice(dev);
		rtnl_unlock();

		if (err < 0) {
			kfree(dev);
			dev = NULL;
		}
	}
	return dev;
}
Пример #3
0
struct net_device * __init sun3_82586_probe(int unit)
{
	struct net_device *dev;
	unsigned long ioaddr;
	static int found = 0;
	int err = -ENOMEM;

	/* check that this machine has an onboard 82586 */
	switch(idprom->id_machtype) {
	case SM_SUN3|SM_3_160:
	case SM_SUN3|SM_3_260:
		/* these machines have 82586 */
		break;

	default:
		return ERR_PTR(-ENODEV);
	}

	if (found)
		return ERR_PTR(-ENODEV);

	ioaddr = (unsigned long)ioremap(IE_OBIO, SUN3_82586_TOTAL_SIZE);
	if (!ioaddr)
		return ERR_PTR(-ENOMEM);
	found = 1;

	dev = alloc_etherdev(sizeof(struct priv));
	if (!dev)
		goto out;
	if (unit >= 0) {
		sprintf(dev->name, "eth%d", unit);
		netdev_boot_setup_check(dev);
	}
	SET_MODULE_OWNER(dev);

	dev->irq = IE_IRQ;
	dev->base_addr = ioaddr;
	err = sun3_82586_probe1(dev, ioaddr);
	if (err)
		goto out1;
	err = register_netdev(dev);
	if (err)
		goto out2;
	return dev;

out2:
	release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
out1:
	free_netdev(dev);
out:
	iounmap((void __iomem *)ioaddr);
	return ERR_PTR(err);
}
Пример #4
0
struct net_device * __init ni52_probe(int unit)
{
	struct net_device *dev = alloc_etherdev(sizeof(struct priv));
	static const int ports[] = {0x300, 0x280, 0x360, 0x320, 0x340, 0};
	const int *port;
	struct priv *p;
	int err = 0;

	if (!dev)
		return ERR_PTR(-ENOMEM);

	p = netdev_priv(dev);

	if (unit >= 0) {
		sprintf(dev->name, "eth%d", unit);
		netdev_boot_setup_check(dev);
		io = dev->base_addr;
		irq = dev->irq;
		memstart = dev->mem_start;
		memend = dev->mem_end;
	}

	if (io > 0x1ff)	{	/*                                    */
		err = ni52_probe1(dev, io);
	} else if (io > 0) {		/*                     */
		err = -ENXIO;
	} else {
		for (port = ports; *port && ni52_probe1(dev, *port) ; port++)
			;
		if (*port)
			goto got_it;
#ifdef FULL_IO_PROBE
		for (io = 0x200; io < 0x400 && ni52_probe1(dev, io); io += 8)
			;
		if (io < 0x400)
			goto got_it;
#endif
		err = -ENODEV;
	}
	if (err)
		goto out;
got_it:
	err = register_netdev(dev);
	if (err)
		goto out1;
	return dev;
out1:
	iounmap(p->mapped);
	release_region(dev->base_addr, NI52_TOTAL_SIZE);
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #5
0
/*
 *      Check for a network adaptor of this type, and return '0' iff one exists.
 *      If dev->base_addr == 0, probe all likely locations.
 *      If dev->base_addr in [1..0x1ff], always return failure.
 *        otherwise go with what we pass in.
 */
struct net_device * __init cops_probe(int unit)
{
	struct net_device *dev;
	unsigned *port;
	int base_addr;
	int err = 0;

	dev = alloc_ltalkdev(sizeof(struct cops_local));
	if (!dev)
		return ERR_PTR(-ENOMEM);

	if (unit >= 0) {
		sprintf(dev->name, "lt%d", unit);
		netdev_boot_setup_check(dev);
		irq = dev->irq;
		base_addr = dev->base_addr;
	} else {
		base_addr = dev->base_addr = io;
	}

	SET_MODULE_OWNER(dev);

	if (base_addr > 0x1ff) {    /* Check a single specified location. */
		err = cops_probe1(dev, base_addr);
	} else if (base_addr != 0) { /* Don't probe at all. */
		err = -ENXIO;
	} else {
		/* FIXME  Does this really work for cards which generate irq?
		 * It's definitely N.G. for polled Tangent. sh
		 * Dayna cards don't autoprobe well at all, but if your card is
		 * at IRQ 5 & IO 0x240 we find it every time. ;) JS
		 */
		for (port = ports; *port && cops_probe1(dev, *port) < 0; port++)
			;
		if (!*port)
			err = -ENODEV;
	}
	if (err)
		goto out;
	err = register_netdev(dev);
	if (err)
		goto out1;
	return dev;
out1:
	cleanup_card(dev);
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #6
0
/*
 *	To call this a probe is a bit misleading, however for real
 *	hardware it would have to check what was present.
 */
static int  __init ethertap_probe(int unit)
{
	struct net_device *dev;
	int err = -ENOMEM;

	dev = alloc_netdev(sizeof(struct net_local), "tap%d",
			   ether_setup);

	if (!dev)
		goto out;

	SET_MODULE_OWNER(dev);

	sprintf(dev->name, "tap%d", unit);
	dev->base_addr = unit + NETLINK_TAPBASE;

	netdev_boot_setup_check(dev);

	memcpy(dev->dev_addr, "\xFE\xFD\x00\x00\x00\x00", 6);
	if (dev->mem_start & 0xf)
		ethertap_debug = dev->mem_start & 0x7;

	/*
	 *	The tap specific entries in the device structure.
	 */

	dev->open = ethertap_open;
	dev->hard_start_xmit = ethertap_start_xmit;
	dev->stop = ethertap_close;
	dev->get_stats = ethertap_get_stats;
#ifdef CONFIG_ETHERTAP_MC
	dev->set_multicast_list = set_multicast_list;
#endif

	dev->tx_queue_len = 0;
	dev->flags|=IFF_NOARP;

	err = register_netdev(dev);
	if (err)
		goto out_free;

	tap_map[unit]=dev;
	return 0;
out_free:
	free_netdev(dev);
out:
	return err;
}
Пример #7
0
static __init int trif_probe(int unit)
{
	int err = -ENODEV;
#ifdef CONFIG_IBMTR
	struct net_device *dev = alloc_trdev(0);
	if (!dev)
		return -ENOMEM;

	sprintf(dev->name, "tr%d", unit);
	netdev_boot_setup_check(dev);
	err = ibmtr_probe_card(dev);
	if (err)
		free_netdev(dev);
#endif
	return err;
}
Пример #8
0
struct net_device * __init elplus_probe(int unit)
{
	struct net_device *dev = alloc_etherdev(sizeof(elp_device));
	int err;
	if (!dev)
		return ERR_PTR(-ENOMEM);

	sprintf(dev->name, "eth%d", unit);
	netdev_boot_setup_check(dev);

	err = elplus_setup(dev);
	if (err) {
		free_netdev(dev);
		return ERR_PTR(err);
	}
	return dev;
}
Пример #9
0
int __init xtsonic_probe(struct platform_device *pdev)
{
    struct net_device *dev;
    struct sonic_local *lp;
    struct resource *resmem, *resirq;
    int err = 0;

    DECLARE_MAC_BUF(mac);

    if ((resmem = platform_get_resource(pdev, IORESOURCE_MEM, 0)) == NULL)
        return -ENODEV;

    if ((resirq = platform_get_resource(pdev, IORESOURCE_IRQ, 0)) == NULL)
        return -ENODEV;

    if ((dev = alloc_etherdev(sizeof(struct sonic_local))) == NULL)
        return -ENOMEM;

    lp = netdev_priv(dev);
    lp->device = &pdev->dev;
    SET_NETDEV_DEV(dev, &pdev->dev);
    netdev_boot_setup_check(dev);

    dev->base_addr = resmem->start;
    dev->irq = resirq->start;

    if ((err = sonic_probe1(dev)))
        goto out;
    if ((err = register_netdev(dev)))
        goto out1;

    printk("%s: SONIC ethernet @%08lx, MAC %s, IRQ %d\n", dev->name,
           dev->base_addr, print_mac(mac, dev->dev_addr), dev->irq);

    return 0;

out1:
    release_region(dev->base_addr, SONIC_MEM_SIZE);
out:
    free_netdev(dev);

    return err;
}
Пример #10
0
struct net_device * __init elmc_probe(int unit)
{
	struct net_device *dev = alloc_etherdev(sizeof(struct priv));
	int err;

	if (!dev)
		return ERR_PTR(-ENOMEM);

	sprintf(dev->name, "eth%d", unit);
	netdev_boot_setup_check(dev);

	err = do_elmc_probe(dev);
	if (err)
		goto out;
	return dev;
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #11
0
struct net_device * __init ac3200_probe(int unit)
{
	struct net_device *dev = alloc_ei_netdev();
	int err;

	if (!dev)
		return ERR_PTR(-ENOMEM);

	sprintf(dev->name, "eth%d", unit);
	netdev_boot_setup_check(dev);

	err = do_ac3200_probe(dev);
	if (err)
		goto out;
	return dev;
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #12
0
struct net_device * __init el1_probe(int unit)
{
	struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
	static unsigned ports[] = { 0x280, 0x300, 0};
	unsigned *port;
	int err = 0;

	if (!dev)
		return ERR_PTR(-ENOMEM);

	if (unit >= 0) {
		sprintf(dev->name, "eth%d", unit);
		netdev_boot_setup_check(dev);
		io = dev->base_addr;
		irq = dev->irq;
		mem_start = dev->mem_start & 7;
	}

	SET_MODULE_OWNER(dev);

	if (io > 0x1ff) {	/* Check a single specified location. */
		err = el1_probe1(dev, io);
	} else if (io != 0) {
		err = -ENXIO;		/* Don't probe at all. */
	} else {
		for (port = ports; *port && el1_probe1(dev, *port); port++)
			;
		if (!*port)
			err = -ENODEV;
	}
	if (err)
		goto out;
	err = register_netdev(dev);
	if (err)
		goto out1;
	return dev;
out1:
	release_region(dev->base_addr, EL1_IO_EXTENT);
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #13
0
struct net_device * __init ultra32_probe(int unit)
{
	struct net_device *dev;
	int base;
	int irq;
	int err = -ENODEV;

	if (!EISA_bus)
		return ERR_PTR(-ENODEV);

	dev = alloc_ei_netdev();

	if (!dev)
		return ERR_PTR(-ENOMEM);

	if (unit >= 0) {
		sprintf(dev->name, "eth%d", unit);
		netdev_boot_setup_check(dev);
	}

	SET_MODULE_OWNER(dev);

	irq = dev->irq;

	/* EISA spec allows for up to 16 slots, but 8 is typical. */
	for (base = 0x1000 + ULTRA32_BASE; base < 0x9000; base += 0x1000) {
		if (ultra32_probe1(dev, base) == 0)
			break;
		dev->irq = irq;
	}
	if (base >= 0x9000)
		goto out;
	err = register_netdev(dev);
	if (err)
		goto out1;
	return dev;
out1:
	cleanup_card(dev);
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #14
0
/*
 * Probe for a SONIC ethernet controller on a Mips Jazz board.
 * Actually probing is superfluous but we're paranoid.
 */
static int __init jazz_sonic_probe(struct platform_device *pdev)
{
	struct net_device *dev;
	struct sonic_local *lp;
	struct resource *res;
	int err = 0;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res)
		return -ENODEV;

	dev = alloc_etherdev(sizeof(struct sonic_local));
	if (!dev)
		return -ENOMEM;

	lp = netdev_priv(dev);
	lp->device = &pdev->dev;
	SET_NETDEV_DEV(dev, &pdev->dev);
	platform_set_drvdata(pdev, dev);

	netdev_boot_setup_check(dev);

	dev->base_addr = res->start;
	dev->irq = platform_get_irq(pdev, 0);
	err = sonic_probe1(dev);
	if (err)
		goto out;
	err = register_netdev(dev);
	if (err)
		goto out1;

	printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);

	return 0;

out1:
	release_region(dev->base_addr, SONIC_MEM_SIZE);
out:
	free_netdev(dev);

	return err;
}
Пример #15
0
struct net_device * __init seeq8005_probe(int unit)
{
	struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
	unsigned *port;
	int err = 0;

	if (!dev)
		return ERR_PTR(-ENODEV);

	if (unit >= 0) {
		sprintf(dev->name, "eth%d", unit);
		netdev_boot_setup_check(dev);
		io = dev->base_addr;
		irq = dev->irq;
	}

	if (io > 0x1ff) {	/* Check a single specified location. */
		err = seeq8005_probe1(dev, io);
	} else if (io != 0) {	/* Don't probe at all. */
		err = -ENXIO;
	} else {
		for (port = seeq8005_portlist; *port; port++) {
			if (seeq8005_probe1(dev, *port) == 0)
				break;
		}
		if (!*port)
			err = -ENODEV;
	}
	if (err)
		goto out;
	err = register_netdev(dev);
	if (err)
		goto out1;
	return dev;
out1:
	release_region(dev->base_addr, SEEQ8005_IO_EXTENT);
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #16
0
struct net_device * __init proteon_probe(int unit)
{
	struct net_device *dev = alloc_trdev(sizeof(struct net_local));
	int err = 0;

	if (!dev)
		return ERR_PTR(-ENOMEM);

	if (unit >= 0) {
		sprintf(dev->name, "tr%d", unit);
		netdev_boot_setup_check(dev);
	}

	err = setup_card(dev);
	if (err)
		goto out;

	return dev;

out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #17
0
struct net_device * __init es_probe(int unit)
{
	struct net_device *dev = alloc_ei_netdev();
	int err;

	if (!dev)
		return ERR_PTR(-ENOMEM);

	sprintf(dev->name, "eth%d", unit);
	netdev_boot_setup_check(dev);

	err = do_es_probe(dev);
	if (err)
		goto out;
	err = register_netdev(dev);
	if (err)
		goto out1;
	return dev;
out1:
	cleanup_card(dev);
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #18
0
int __init proteon_probe(struct net_device *dev)
{
        static int versionprinted;
	struct net_local *tp;
	int i,j;
	struct proteon_card *card;

#ifndef MODULE
	netdev_boot_setup_check(dev);
	tr_setup(dev);
#endif

	SET_MODULE_OWNER(dev);
	if (!dev->base_addr)
	{
		for(i = 0; portlist[i]; i++)
		{
			if (!request_region(portlist[i], PROTEON_IO_EXTENT, cardname))
				continue;

			if(proteon_probe1(portlist[i]))
			{
				release_region(dev->base_addr, PROTEON_IO_EXTENT); 
				continue;
			}

			dev->base_addr = portlist[i];
			break;
		}
		if(!dev->base_addr)
			return -1;
	}
	else
	{
		if (!request_region(dev->base_addr, PROTEON_IO_EXTENT, cardname))
			return -1;

		if(proteon_probe1(dev->base_addr))
		{
			release_region(dev->base_addr, PROTEON_IO_EXTENT); 
			return -1;
  		}
	} 

	/* At this point we have found a valid card. */

	if (versionprinted++ == 0)
		printk(KERN_DEBUG "%s", version);

	if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL))
		goto out4;

	dev->base_addr &= ~3; 
		
	proteon_read_eeprom(dev);

	printk(KERN_DEBUG "%s:    Ring Station Address: ", dev->name);
	printk("%2.2x", dev->dev_addr[0]);
	for (j = 1; j < 6; j++)
		printk(":%2.2x", dev->dev_addr[j]);
	printk("\n");
		
	tp = (struct net_local *)dev->priv;
	tp->setnselout = proteon_setnselout_pins;
		
	tp->sifreadb = proteon_sifreadb;
	tp->sifreadw = proteon_sifreadw;
	tp->sifwriteb = proteon_sifwriteb;
	tp->sifwritew = proteon_sifwritew;
	
	memcpy(tp->ProductID, cardname, PROD_ID_SIZE + 1);

	tp->tmspriv = NULL;

	dev->open = proteon_open;
	dev->stop = proteon_close;

	if (dev->irq == 0)
	{
		for(j = 0; irqlist[j] != 0; j++)
		{
			dev->irq = irqlist[j];
			if (!request_irq(dev->irq, tms380tr_interrupt, 0, 
				cardname, dev))
				break;
                }
		
                if(irqlist[j] == 0)
                {
                        printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name);
			goto out3;
		}
	}
	else
	{
		for(j = 0; irqlist[j] != 0; j++)
			if (irqlist[j] == dev->irq)
				break;
		if (irqlist[j] == 0)
		{
			printk(KERN_INFO "%s: Illegal IRQ %d specified\n",
				dev->name, dev->irq);
			goto out3;
		}
		if (request_irq(dev->irq, tms380tr_interrupt, 0, 
			cardname, dev))
		{
                        printk(KERN_INFO "%s: Selected IRQ %d not available\n", 
				dev->name, dev->irq);
			goto out3;
		}
	}

	if (dev->dma == 0)
	{
		for(j = 0; dmalist[j] != 0; j++)
		{
			dev->dma = dmalist[j];
                        if (!request_dma(dev->dma, cardname))
				break;
		}

		if(dmalist[j] == 0)
		{
			printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name);
			goto out2;
		}
	}
	else
	{
		for(j = 0; dmalist[j] != 0; j++)
			if (dmalist[j] == dev->dma)
				break;
		if (dmalist[j] == 0)
		{
                        printk(KERN_INFO "%s: Illegal DMA %d specified\n", 
				dev->name, dev->dma);
			goto out2;
		}
		if (request_dma(dev->dma, cardname))
		{
                        printk(KERN_INFO "%s: Selected DMA %d not available\n", 
				dev->name, dev->dma);
			goto out2;
		}
	}

	printk(KERN_DEBUG "%s:    IO: %#4lx  IRQ: %d  DMA: %d\n",
	       dev->name, dev->base_addr, dev->irq, dev->dma);
		
	/* Enlist in the card list */
	card = kmalloc(sizeof(struct proteon_card), GFP_KERNEL);
	if (!card)
		goto out;
	card->next = proteon_card_list;
	proteon_card_list = card;
	card->dev = dev;
	return 0;
out:
	free_dma(dev->dma);
out2:
	free_irq(dev->irq, dev);
out3:
	tmsdev_term(dev);
out4:
	release_region(dev->base_addr, PROTEON_IO_EXTENT); 
	return -1;
}
Пример #19
0
/* Probe for the CS8900 card in slot E.  We won't bother looking
   anywhere else until we have a really good reason to do so. */
struct net_device * __init mac89x0_probe(int unit)
{
	struct net_device *dev;
	static int once_is_enough;
	struct net_local *lp;
	static unsigned version_printed;
	int i, slot;
	unsigned rev_type = 0;
	unsigned long ioaddr;
	unsigned short sig;
	int err = -ENODEV;

	if (!MACH_IS_MAC)
		return ERR_PTR(-ENODEV);

	dev = alloc_etherdev(sizeof(struct net_local));
	if (!dev)
		return ERR_PTR(-ENOMEM);

	if (unit >= 0) {
		sprintf(dev->name, "eth%d", unit);
		netdev_boot_setup_check(dev);
	}

	if (once_is_enough)
		goto out;
	once_is_enough = 1;

	/* We might have to parameterize this later */
	slot = 0xE;
	/* Get out now if there's a real NuBus card in slot E */
	if (nubus_find_slot(slot, NULL) != NULL)
		goto out;

	/* The pseudo-ISA bits always live at offset 0x300 (gee,
           wonder why...) */
	ioaddr = (unsigned long)
		nubus_slot_addr(slot) | (((slot&0xf) << 20) + DEFAULTIOBASE);
	{
		unsigned long flags;
		int card_present;

		local_irq_save(flags);
		card_present = (hwreg_present((void*) ioaddr+4) &&
				hwreg_present((void*) ioaddr + DATA_PORT));
		local_irq_restore(flags);

		if (!card_present)
			goto out;
	}

	nubus_writew(0, ioaddr + ADD_PORT);
	sig = nubus_readw(ioaddr + DATA_PORT);
	if (sig != swab16(CHIP_EISA_ID_SIG))
		goto out;

	/* Initialize the net_device structure. */
	lp = netdev_priv(dev);

	/* Fill in the 'dev' fields. */
	dev->base_addr = ioaddr;
	dev->mem_start = (unsigned long)
		nubus_slot_addr(slot) | (((slot&0xf) << 20) + MMIOBASE);
	dev->mem_end = dev->mem_start + 0x1000;

	/* Turn on shared memory */
	writereg_io(dev, PP_BusCTL, MEMORY_ON);

	/* get the chip type */
	rev_type = readreg(dev, PRODUCT_ID_ADD);
	lp->chip_type = rev_type &~ REVISON_BITS;
	lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';

	/* Check the chip type and revision in order to set the correct send command
	CS8920 revision C and CS8900 revision F can use the faster send. */
	lp->send_cmd = TX_AFTER_381;
	if (lp->chip_type == CS8900 && lp->chip_revision >= 'F')
		lp->send_cmd = TX_NOW;
	if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
		lp->send_cmd = TX_NOW;

	if (net_debug && version_printed++ == 0)
		printk(version);

	printk(KERN_INFO "%s: cs89%c0%s rev %c found at %#8lx",
	       dev->name,
	       lp->chip_type==CS8900?'0':'2',
	       lp->chip_type==CS8920M?"M":"",
	       lp->chip_revision,
	       dev->base_addr);

	/* Try to read the MAC address */
	if ((readreg(dev, PP_SelfST) & (EEPROM_PRESENT | EEPROM_OK)) == 0) {
		printk("\nmac89x0: No EEPROM, giving up now.\n");
		goto out1;
        } else {
                for (i = 0; i < ETH_ALEN; i += 2) {
			/* Big-endian (why??!) */
			unsigned short s = readreg(dev, PP_IA + i);
                        dev->dev_addr[i] = s >> 8;
                        dev->dev_addr[i+1] = s & 0xff;
                }
        }

	dev->irq = SLOT2IRQ(slot);

	/* print the IRQ and ethernet address. */

	printk(" IRQ %d ADDR %pM\n", dev->irq, dev->dev_addr);

	dev->netdev_ops		= &mac89x0_netdev_ops;

	err = register_netdev(dev);
	if (err)
		goto out1;
	return NULL;
out1:
	nubus_writew(0, dev->base_addr + ADD_PORT);
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
Пример #20
0
/* Check for a network adaptor of this type, and return '0' if one exists.
 */
struct net_device * __init bionet_probe(int unit)
{
    struct net_device *dev;
    unsigned char station_addr[6];
    static unsigned version_printed;
    static int no_more_found;	/* avoid "Probing for..." printed 4 times */
    int i;
    int err;

    if (!MACH_IS_ATARI || no_more_found)
        return ERR_PTR(-ENODEV);

    dev = alloc_etherdev(sizeof(struct net_local));
    if (!dev)
        return ERR_PTR(-ENOMEM);
    if (unit >= 0) {
        sprintf(dev->name, "eth%d", unit);
        netdev_boot_setup_check(dev);
    }
    SET_MODULE_OWNER(dev);

    printk("Probing for BioNet 100 Adapter...\n");

    stdma_lock(bionet_intr, NULL);
    i = get_status(station_addr);	/* Read the station address PROM.  */
    ENABLE_IRQ();
    stdma_release();

    /* Check the first three octets of the S.A. for the manufactor's code.
     */

    if( i < 0
            ||  station_addr[0] != 'B'
            ||  station_addr[1] != 'I'
            ||  station_addr[2] != 'O' ) {
        no_more_found = 1;
        printk( "No BioNet 100 found.\n" );
        free_netdev(dev);
        return ERR_PTR(-ENODEV);
    }

    if (bionet_debug > 0 && version_printed++ == 0)
        printk(version);

    printk("%s: %s found, eth-addr: %02x-%02x-%02x:%02x-%02x-%02x.\n",
           dev->name, "BioNet 100",
           station_addr[0], station_addr[1], station_addr[2],
           station_addr[3], station_addr[4], station_addr[5]);

    /* Initialize the device structure. */

    nic_packet = (struct nic_pkt_s *)acsi_buffer;
    phys_nic_packet = (unsigned char *)phys_acsi_buffer;
    if (bionet_debug > 0) {
        printk("nic_packet at 0x%p, phys at 0x%p\n",
               nic_packet, phys_nic_packet );
    }

    dev->open		= bionet_open;
    dev->stop		= bionet_close;
    dev->hard_start_xmit	= bionet_send_packet;
    dev->get_stats		= net_get_stats;

    /* Fill in the fields of the device structure with ethernet-generic
     * values. This should be in a common file instead of per-driver.
     */

    for (i = 0; i < ETH_ALEN; i++) {
#if 0
        dev->broadcast[i] = 0xff;
#endif
        dev->dev_addr[i]  = station_addr[i];
    }
    err = register_netdev(dev);
    if (!err)
        return dev;
    free_netdev(dev);
    return ERR_PTR(err);
}