Пример #1
0
static int __init setup_card(unsigned long io, unsigned irq, unsigned char dma)
{
	int res = -ENOMEM;
	struct proteon_card *this_card;
	struct net_device *dev = alloc_trdev(0);

	if (dev) {
		dev->base_addr = io;
		dev->irq       = irq;
		dev->dma       = dma;
		res = -ENODEV;
		if (proteon_probe(dev) == 0) {
			res = register_netdev(dev);
			if (!res)
				return 0;
			release_region(dev->base_addr, PROTEON_IO_EXTENT);
			free_irq(dev->irq, dev);
			free_dma(dev->dma);
			tmsdev_term(dev);
			this_card = proteon_card_list;
			proteon_card_list = this_card->next;
			kfree(this_card);
		}
		kfree(dev);
	}
	return res;
}
int init_module(void)
{
	struct net_device *dev;
	int i, num = 0, err = 0;

	for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
		dev = alloc_trdev(sizeof(struct net_local));
		if (!dev)
			continue;

		dev->base_addr = io[i];
		dev->irq = irq[i];
		dev->dma = dma[i];
		err = setup_card(dev);
		if (!err) {
			proteon_dev[i] = dev;
			++num;
		} else {
			free_netdev(dev);
		}
	}

	printk(KERN_NOTICE "proteon.c: %d cards found.\n", num);
	/* Probe for cards. */
	if (num == 0) {
		printk(KERN_NOTICE "proteon.c: No cards found.\n");
		return (-ENODEV);
	}
	return (0);
}
Пример #3
0
static int __init sk_isa_init(void)
{
	struct net_device *dev;
	struct platform_device *pdev;
	int i, num = 0, err = 0;

	sk_isa_netdev_ops = tms380tr_netdev_ops;
	sk_isa_netdev_ops.ndo_open = sk_isa_open;
	sk_isa_netdev_ops.ndo_stop = tms380tr_close;

	err = platform_driver_register(&sk_isa_driver);
	if (err)
		return err;

	for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
		dev = alloc_trdev(sizeof(struct net_local));
		if (!dev)
			continue;

		dev->base_addr = io[i];
		dev->irq = irq[i];
		dev->dma = dma[i];
		pdev = platform_device_register_simple("skisa",
			i, NULL, 0);
		if (IS_ERR(pdev)) {
			free_netdev(dev);
			continue;
		}
		err = setup_card(dev, &pdev->dev);
		if (!err) {
			sk_isa_dev[i] = pdev;
			platform_set_drvdata(sk_isa_dev[i], dev);
			++num;
		} else {
			platform_device_unregister(pdev);
			free_netdev(dev);
		}
	}

	printk(KERN_NOTICE "skisa.c: %d cards found.\n", num);
	/* Probe for cards. */
	if (num == 0) {
		printk(KERN_NOTICE "skisa.c: No cards found.\n");
		platform_driver_unregister(&sk_isa_driver);
		return -ENODEV;
	}
	return 0;
}
Пример #4
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;
}
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);
}
Пример #6
0
static int __devinit tms_pci_attach(struct pci_dev *pdev, const struct pci_device_id *ent)
{
    static int versionprinted;
    struct net_device *dev;
    struct net_local *tp;
    int ret;
    unsigned int pci_irq_line;
    unsigned long pci_ioaddr;
    struct card_info *cardinfo = &card_info_table[ent->driver_data];

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

    if (pci_enable_device(pdev))
        return -EIO;

    /* Remove I/O space marker in bit 0. */
    pci_irq_line = pdev->irq;
    pci_ioaddr = pci_resource_start (pdev, 0);

    /* At this point we have found a valid card. */
    dev = alloc_trdev(sizeof(struct net_local));
    if (!dev)
        return -ENOMEM;

    if (!request_region(pci_ioaddr, TMS_PCI_IO_EXTENT, dev->name)) {
        ret = -EBUSY;
        goto err_out_trdev;
    }

    dev->base_addr	= pci_ioaddr;
    dev->irq 	= pci_irq_line;
    dev->dma	= 0;

    printk("%s: %s\n", dev->name, cardinfo->name);
    printk("%s:    IO: %#4lx  IRQ: %d\n",
           dev->name, dev->base_addr, dev->irq);

    tms_pci_read_eeprom(dev);

    printk("%s:    Ring Station Address: %pM\n",
           dev->name, dev->dev_addr);

    ret = tmsdev_init(dev, &pdev->dev);
    if (ret) {
        printk("%s: unable to get memory for dev->priv.\n", dev->name);
        goto err_out_region;
    }

    tp = netdev_priv(dev);
    tp->setnselout = tms_pci_setnselout_pins;

    tp->sifreadb = tms_pci_sifreadb;
    tp->sifreadw = tms_pci_sifreadw;
    tp->sifwriteb = tms_pci_sifwriteb;
    tp->sifwritew = tms_pci_sifwritew;

    memcpy(tp->ProductID, cardinfo->name, PROD_ID_SIZE + 1);

    tp->tmspriv = cardinfo;

    dev->netdev_ops = &tms380tr_netdev_ops;

    ret = request_irq(pdev->irq, tms380tr_interrupt, IRQF_SHARED,
                      dev->name, dev);
    if (ret)
        goto err_out_tmsdev;

    pci_set_drvdata(pdev, dev);
    SET_NETDEV_DEV(dev, &pdev->dev);

    ret = register_netdev(dev);
    if (ret)
        goto err_out_irq;

    return 0;

err_out_irq:
    free_irq(pdev->irq, dev);
err_out_tmsdev:
    pci_set_drvdata(pdev, NULL);
    tmsdev_term(dev);
err_out_region:
    release_region(pci_ioaddr, TMS_PCI_IO_EXTENT);
err_out_trdev:
    free_netdev(dev);
    return ret;
}
Пример #7
0
#ifdef CONFIG_TR
if (is_trdev)
			dev_lec[i] = alloc_trdev(size);
		else
#endif
			dev_lec[i] = alloc_etherdev(size);
Пример #8
0
static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_id *ent)
{	
	static int versionprinted;
	struct net_device *dev;
	struct net_local *tp;
	int ret, pci_irq_line;
	unsigned long pci_ioaddr;
	
	if (versionprinted++ == 0)
		printk("%s", version);

	if (pci_enable_device(pdev))
		return -EIO;

	
	pci_irq_line = pdev->irq;
	pci_ioaddr = pci_resource_start (pdev, 0);
		
	
		
	dev = alloc_trdev(sizeof(struct net_local));
	if (!dev)
		return -ENOMEM;

	if (!request_region(pci_ioaddr, ABYSS_IO_EXTENT, dev->name)) {
		ret = -EBUSY;
		goto err_out_trdev;
	}
		
	ret = request_irq(pdev->irq, tms380tr_interrupt, IRQF_SHARED,
			  dev->name, dev);
	if (ret)
		goto err_out_region;
		
	dev->base_addr	= pci_ioaddr;
	dev->irq	= pci_irq_line;
		
	printk("%s: Madge Smart 16/4 PCI Mk2 (Abyss)\n", dev->name);
	printk("%s:    IO: %#4lx  IRQ: %d\n",
	       dev->name, pci_ioaddr, dev->irq);
	
	dev->base_addr += 0x10;
		
	ret = tmsdev_init(dev, &pdev->dev);
	if (ret) {
		printk("%s: unable to get memory for dev->priv.\n", 
		       dev->name);
		goto err_out_irq;
	}

	abyss_read_eeprom(dev);

	printk("%s:    Ring Station Address: %pM\n", dev->name, dev->dev_addr);

	tp = netdev_priv(dev);
	tp->setnselout = abyss_setnselout_pins;
	tp->sifreadb = abyss_sifreadb;
	tp->sifreadw = abyss_sifreadw;
	tp->sifwriteb = abyss_sifwriteb;
	tp->sifwritew = abyss_sifwritew;

	memcpy(tp->ProductID, "Madge PCI 16/4 Mk2", PROD_ID_SIZE + 1);
		
	dev->netdev_ops = &abyss_netdev_ops;

	pci_set_drvdata(pdev, dev);
	SET_NETDEV_DEV(dev, &pdev->dev);

	ret = register_netdev(dev);
	if (ret)
		goto err_out_tmsdev;
	return 0;

err_out_tmsdev:
	pci_set_drvdata(pdev, NULL);
	tmsdev_term(dev);
err_out_irq:
	free_irq(pdev->irq, dev);
err_out_region:
	release_region(pci_ioaddr, ABYSS_IO_EXTENT);
err_out_trdev:
	free_netdev(dev);
	return ret;
}
Пример #9
0
static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_id *ent)
{	
	static int versionprinted;
	struct net_device *dev;
	struct net_local *tp;
	int i, ret, pci_irq_line;
	unsigned long pci_ioaddr;
	
	if (versionprinted++ == 0)
		printk("%s", version);

	if (pci_enable_device(pdev))
		return -EIO;

	/* Remove I/O space marker in bit 0. */
	pci_irq_line = pdev->irq;
	pci_ioaddr = pci_resource_start (pdev, 0);
		
	/* At this point we have found a valid card. */
		
	dev = alloc_trdev(sizeof(struct net_local));
	if (!dev)
		return -ENOMEM;

	SET_MODULE_OWNER(dev);

	if (!request_region(pci_ioaddr, ABYSS_IO_EXTENT, dev->name)) {
		ret = -EBUSY;
		goto err_out_trdev;
	}
		
	ret = request_irq(pdev->irq, tms380tr_interrupt, IRQF_SHARED,
			  dev->name, dev);
	if (ret)
		goto err_out_region;
		
	dev->base_addr	= pci_ioaddr;
	dev->irq	= pci_irq_line;
		
	printk("%s: Madge Smart 16/4 PCI Mk2 (Abyss)\n", dev->name);
	printk("%s:    IO: %#4lx  IRQ: %d\n",
	       dev->name, pci_ioaddr, dev->irq);
	/*
	 * The TMS SIF registers lay 0x10 above the card base address.
	 */
	dev->base_addr += 0x10;
		
	ret = tmsdev_init(dev, &pdev->dev);
	if (ret) {
		printk("%s: unable to get memory for dev->priv.\n", 
		       dev->name);
		goto err_out_irq;
	}

	abyss_read_eeprom(dev);
		
	printk("%s:    Ring Station Address: ", dev->name);
	printk("%2.2x", dev->dev_addr[0]);
	for (i = 1; i < 6; i++)
		printk(":%2.2x", dev->dev_addr[i]);
	printk("\n");

	tp = netdev_priv(dev);
	tp->setnselout = abyss_setnselout_pins;
	tp->sifreadb = abyss_sifreadb;
	tp->sifreadw = abyss_sifreadw;
	tp->sifwriteb = abyss_sifwriteb;
	tp->sifwritew = abyss_sifwritew;

	memcpy(tp->ProductID, "Madge PCI 16/4 Mk2", PROD_ID_SIZE + 1);
		
	dev->open = abyss_open;
	dev->stop = abyss_close;

	pci_set_drvdata(pdev, dev);
	SET_NETDEV_DEV(dev, &pdev->dev);

	ret = register_netdev(dev);
	if (ret)
		goto err_out_tmsdev;
	return 0;

err_out_tmsdev:
	pci_set_drvdata(pdev, NULL);
	tmsdev_term(dev);
err_out_irq:
	free_irq(pdev->irq, dev);
err_out_region:
	release_region(pci_ioaddr, ABYSS_IO_EXTENT);
err_out_trdev:
	free_netdev(dev);
	return ret;
}