当前位置: 首页>>代码示例>>C++>>正文


C++ register_netdev函数代码示例

本文整理汇总了C++中register_netdev函数的典型用法代码示例。如果您正苦于以下问题:C++ register_netdev函数的具体用法?C++ register_netdev怎么用?C++ register_netdev使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了register_netdev函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ariadne_init_one

static int __devinit ariadne_init_one(struct zorro_dev *z,
				      const struct zorro_device_id *ent)
{
    unsigned long board = z->resource.start;
    unsigned long base_addr = board+ARIADNE_LANCE;
    unsigned long mem_start = board+ARIADNE_RAM;
    struct resource *r1, *r2;
    struct net_device *dev;
    struct ariadne_private *priv;
    int err;

    r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960");
    if (!r1)
	return -EBUSY;
    r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM");
    if (!r2) {
	release_resource(r1);
	return -EBUSY;
    }

    dev = alloc_etherdev(sizeof(struct ariadne_private));
    if (dev == NULL) {
	release_resource(r1);
	release_resource(r2);
	return -ENOMEM;
    }

    priv = netdev_priv(dev);

    r1->name = dev->name;
    r2->name = dev->name;

    dev->dev_addr[0] = 0x00;
    dev->dev_addr[1] = 0x60;
    dev->dev_addr[2] = 0x30;
    dev->dev_addr[3] = (z->rom.er_SerialNumber>>16) & 0xff;
    dev->dev_addr[4] = (z->rom.er_SerialNumber>>8) & 0xff;
    dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff;
    dev->base_addr = ZTWO_VADDR(base_addr);
    dev->mem_start = ZTWO_VADDR(mem_start);
    dev->mem_end = dev->mem_start+ARIADNE_RAM_SIZE;

    dev->open = &ariadne_open;
    dev->stop = &ariadne_close;
    dev->hard_start_xmit = &ariadne_start_xmit;
    dev->tx_timeout = &ariadne_tx_timeout;
    dev->watchdog_timeo = 5*HZ;
    dev->get_stats = &ariadne_get_stats;
    dev->set_multicast_list = &set_multicast_list;

    err = register_netdev(dev);
    if (err) {
	release_resource(r1);
	release_resource(r2);
	free_netdev(dev);
	return err;
    }
    zorro_set_drvdata(z, dev);

    printk(KERN_INFO "%s: Ariadne at 0x%08lx, Ethernet Address %pM\n",
           dev->name, board, dev->dev_addr);

    return 0;
}
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:64,代码来源:ariadne.c

示例2: w83977af_open

/*
 * Function w83977af_open (iobase, irq)
 *
 *    Open driver instance
 *
 */
static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
			 unsigned int dma)
{
	struct net_device *dev;
        struct w83977af_ir *self;
	int err;

	IRDA_DEBUG(0, "%s()\n", __func__ );

	/* Lock the port that we need */
	if (!request_region(iobase, CHIP_IO_EXTENT, driver_name)) {
		IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
		      __func__ , iobase);
		return -ENODEV;
	}

	if (w83977af_probe(iobase, irq, dma) == -1) {
		err = -1;
		goto err_out;
	}
	/*
	 *  Allocate new instance of the driver
	 */
	dev = alloc_irdadev(sizeof(struct w83977af_ir));
	if (dev == NULL) {
		printk( KERN_ERR "IrDA: Can't allocate memory for "
			"IrDA control block!\n");
		err = -ENOMEM;
		goto err_out;
	}

	self = netdev_priv(dev);
	spin_lock_init(&self->lock);
   

	/* Initialize IO */
	self->io.fir_base   = iobase;
        self->io.irq       = irq;
        self->io.fir_ext   = CHIP_IO_EXTENT;
        self->io.dma       = dma;
        self->io.fifo_size = 32;

	/* Initialize QoS for this device */
	irda_init_max_qos_capabilies(&self->qos);
	
	/* The only value we must override it the baudrate */

	/* FIXME: The HP HDLS-1100 does not support 1152000! */
	self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
		IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);

	/* The HP HDLS-1100 needs 1 ms according to the specs */
	self->qos.min_turn_time.bits = qos_mtt_bits;
	irda_qos_bits_to_value(&self->qos);
	
	/* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */
	self->rx_buff.truesize = 14384; 
	self->tx_buff.truesize = 4000;
	
	/* Allocate memory if needed */
	self->rx_buff.head =
		dma_alloc_coherent(NULL, self->rx_buff.truesize,
				   &self->rx_buff_dma, GFP_KERNEL);
	if (self->rx_buff.head == NULL) {
		err = -ENOMEM;
		goto err_out1;
	}

	memset(self->rx_buff.head, 0, self->rx_buff.truesize);
	
	self->tx_buff.head =
		dma_alloc_coherent(NULL, self->tx_buff.truesize,
				   &self->tx_buff_dma, GFP_KERNEL);
	if (self->tx_buff.head == NULL) {
		err = -ENOMEM;
		goto err_out2;
	}
	memset(self->tx_buff.head, 0, self->tx_buff.truesize);

	self->rx_buff.in_frame = FALSE;
	self->rx_buff.state = OUTSIDE_FRAME;
	self->tx_buff.data = self->tx_buff.head;
	self->rx_buff.data = self->rx_buff.head;
	self->netdev = dev;

	dev->netdev_ops	= &w83977_netdev_ops;

	err = register_netdev(dev);
	if (err) {
		IRDA_ERROR("%s(), register_netdevice() failed!\n", __func__);
		goto err_out3;
	}
	IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);

//.........这里部分代码省略.........
开发者ID:33d,项目名称:linux-2.6.21-hh20,代码行数:101,代码来源:w83977af_ir.c

示例3: islpci_setup

struct net_device *
islpci_setup(struct pci_dev *pdev)
{
	islpci_private *priv;
	struct net_device *ndev = alloc_etherdev(sizeof (islpci_private));

	if (!ndev)
		return ndev;

	pci_set_drvdata(pdev, ndev);
#if defined(SET_NETDEV_DEV)
	SET_NETDEV_DEV(ndev, &pdev->dev);
#endif

	/* setup the structure members */
	ndev->base_addr = pci_resource_start(pdev, 0);
	ndev->irq = pdev->irq;

	/* initialize the function pointers */
	ndev->open = &islpci_open;
	ndev->stop = &islpci_close;
	ndev->get_stats = &islpci_statistics;
	ndev->do_ioctl = &prism54_ioctl;
	ndev->wireless_handlers =
	    (struct iw_handler_def *) &prism54_handler_def;
	ndev->ethtool_ops = &islpci_ethtool_ops;

	ndev->hard_start_xmit = &islpci_eth_transmit;
	/* ndev->set_multicast_list = &islpci_set_multicast_list; */
	ndev->addr_len = ETH_ALEN;
	ndev->set_mac_address = &prism54_set_mac_address;
	/* Get a non-zero dummy MAC address for nameif. Jean II */
	memcpy(ndev->dev_addr, dummy_mac, 6);

#ifdef HAVE_TX_TIMEOUT
	ndev->watchdog_timeo = ISLPCI_TX_TIMEOUT;
	ndev->tx_timeout = &islpci_eth_tx_timeout;
#endif

	/* allocate a private device structure to the network device  */
	priv = netdev_priv(ndev);
	priv->ndev = ndev;
	priv->pdev = pdev;
	priv->monitor_type = ARPHRD_IEEE80211;
	priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ?
		priv->monitor_type : ARPHRD_ETHER;

	/* Add pointers to enable iwspy support. */
	priv->wireless_data.spy_data = &priv->spy_data;
	ndev->wireless_data = &priv->wireless_data;

	/* save the start and end address of the PCI memory area */
	ndev->mem_start = (unsigned long) priv->device_base;
	ndev->mem_end = ndev->mem_start + ISL38XX_PCI_MEM_SIZE;

#if VERBOSE > SHOW_ERROR_MESSAGES
	DEBUG(SHOW_TRACING, "PCI Memory remapped to 0x%p\n", priv->device_base);
#endif

	init_waitqueue_head(&priv->reset_done);

	/* init the queue read locks, process wait counter */
	mutex_init(&priv->mgmt_lock);
	priv->mgmt_received = NULL;
	init_waitqueue_head(&priv->mgmt_wqueue);
	mutex_init(&priv->stats_lock);
	spin_lock_init(&priv->slock);

	/* init state machine with off#1 state */
	priv->state = PRV_STATE_OFF;
	priv->state_off = 1;

	/* initialize workqueue's */
	INIT_WORK(&priv->stats_work, prism54_update_stats);
	priv->stats_timestamp = 0;

	INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake);
	priv->reset_task_pending = 0;

	/* allocate various memory areas */
	if (islpci_alloc_memory(priv))
		goto do_free_netdev;

	/* select the firmware file depending on the device id */
	switch (pdev->device) {
	case 0x3877:
		strcpy(priv->firmware, ISL3877_IMAGE_FILE);
		break;

	case 0x3886:
		strcpy(priv->firmware, ISL3886_IMAGE_FILE);
		break;

	default:
		strcpy(priv->firmware, ISL3890_IMAGE_FILE);
		break;
	}

	if (register_netdev(ndev)) {
		DEBUG(SHOW_ERROR_MESSAGES,
//.........这里部分代码省略.........
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:101,代码来源:islpci_dev.c

示例4: memset

/* Find a free X.25 channel, and link in this `tty' line. */
static inline struct x25_asy *x25_asy_alloc(void)
{
	x25_asy_ctrl_t *slp = NULL;
	int i;

	if (x25_asy_ctrls == NULL)
		return NULL;	/* Master array missing ! */

	for (i = 0; i < x25_asy_maxdev; i++) 
	{
		slp = x25_asy_ctrls[i];
		/* Not allocated ? */
		if (slp == NULL)
			break;
		/* Not in use ? */
		if (!test_and_set_bit(SLF_INUSE, &slp->ctrl.flags))
			break;
	}
	/* SLP is set.. */

	/* Sorry, too many, all slots in use */
	if (i >= x25_asy_maxdev)
		return NULL;

	/* If no channels are available, allocate one */
	if (!slp &&
	    (x25_asy_ctrls[i] = (x25_asy_ctrl_t *)kmalloc(sizeof(x25_asy_ctrl_t),
						    GFP_KERNEL)) != NULL) {
		slp = x25_asy_ctrls[i];
		memset(slp, 0, sizeof(x25_asy_ctrl_t));

		/* Initialize channel control data */
		set_bit(SLF_INUSE, &slp->ctrl.flags);
		slp->ctrl.tty         = NULL;
		sprintf(slp->dev.name, "x25asy%d", i);
		slp->dev.base_addr    = i;
		slp->dev.priv         = (void*)&(slp->ctrl);
		slp->dev.next         = NULL;
		slp->dev.init         = x25_asy_init;
	}
	if (slp != NULL) 
	{

		/* register device so that it can be ifconfig'ed       */
		/* x25_asy_init() will be called as a side-effect      */
		/* SIDE-EFFECT WARNING: x25_asy_init() CLEARS slp->ctrl ! */

		if (register_netdev(&(slp->dev)) == 0) 
		{
			/* (Re-)Set the INUSE bit.   Very Important! */
			set_bit(SLF_INUSE, &slp->ctrl.flags);
			slp->ctrl.dev = &(slp->dev);
			slp->dev.priv = (void*)&(slp->ctrl);
			return (&(slp->ctrl));
		}
		else
		{
			clear_bit(SLF_INUSE,&(slp->ctrl.flags));
			printk("x25_asy_alloc() - register_netdev() failure.\n");
		}
	}
	return NULL;
}
开发者ID:GunioRobot,项目名称:MI424WR_GEN2_Rev_E-F,代码行数:64,代码来源:x25_asy.c

示例5: usbnet_probe


//.........这里部分代码省略.........
	skb_queue_head_init (&dev->txq);
	skb_queue_head_init (&dev->done);
	skb_queue_head_init(&dev->rxq_pause);
	dev->bh.func = usbnet_bh;
	dev->bh.data = (unsigned long) dev;
	INIT_WORK (&dev->kevent, kevent);
	dev->delay.function = usbnet_bh;
	dev->delay.data = (unsigned long) dev;
	init_timer (&dev->delay);
	mutex_init (&dev->phy_mutex);

	dev->net = net;
	strcpy (net->name, "usb%d");
	memcpy (net->dev_addr, node_id, sizeof node_id);

	/* rx and tx sides can use different message sizes;
	 * bind() should set rx_urb_size in that case.
	 */
	dev->hard_mtu = net->mtu + net->hard_header_len;
#if 0
// dma_supported() is deeply broken on almost all architectures
	// possible with some EHCI controllers
	if (dma_supported (&udev->dev, DMA_BIT_MASK(64)))
		net->features |= NETIF_F_HIGHDMA;
#endif

	net->netdev_ops = &usbnet_netdev_ops;
	net->watchdog_timeo = TX_TIMEOUT_JIFFIES;
	net->ethtool_ops = &usbnet_ethtool_ops;

	// allow device-specific bind/init procedures
	// NOTE net->name still not usable ...
	if (info->bind) {
		status = info->bind (dev, udev);
		if (status < 0)
			goto out1;

		// heuristic:  "usb%d" for links we know are two-host,
		// else "eth%d" when there's reasonable doubt.  userspace
		// can rename the link if it knows better.
		if ((dev->driver_info->flags & FLAG_ETHER) != 0
				&& (net->dev_addr [0] & 0x02) == 0)
			strcpy (net->name, "eth%d");
		/* WLAN devices should always be named "wlan%d" */
		if ((dev->driver_info->flags & FLAG_WLAN) != 0)
			strcpy(net->name, "wlan%d");

		/* maybe the remote can't receive an Ethernet MTU */
		if (net->mtu > (dev->hard_mtu - net->hard_header_len))
			net->mtu = dev->hard_mtu - net->hard_header_len;
	} else if (!info->in || !info->out)
		status = usbnet_get_endpoints (dev, udev);
	else {
		dev->in = usb_rcvbulkpipe (xdev, info->in);
		dev->out = usb_sndbulkpipe (xdev, info->out);
		if (!(info->flags & FLAG_NO_SETINT))
			status = usb_set_interface (xdev,
				interface->desc.bInterfaceNumber,
				interface->desc.bAlternateSetting);
		else
			status = 0;

	}
	if (status >= 0 && dev->status)
		status = init_status (dev, udev);
	if (status < 0)
		goto out3;

	if (!dev->rx_urb_size)
		dev->rx_urb_size = dev->hard_mtu;
	dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);

	SET_NETDEV_DEV(net, &udev->dev);
	status = register_netdev (net);
	if (status)
		goto out3;
	if (netif_msg_probe (dev))
		devinfo (dev, "register '%s' at usb-%s-%s, %s, %pM",
			udev->dev.driver->name,
			xdev->bus->bus_name, xdev->devpath,
			dev->driver_info->description,
			net->dev_addr);

	// ok, it's ready to go.
	usb_set_intfdata (udev, dev);

	// start as if the link is up
	netif_device_attach (net);

	return 0;

out3:
	if (info->unbind)
		info->unbind (dev, udev);
out1:
	free_netdev(net);
out:
	usb_put_dev(xdev);
	return status;
}
开发者ID:DeltaResero,项目名称:GC-Wii-Linux-Kernel-2.6.32.y,代码行数:101,代码来源:usbnet.c

示例6: abyss_attach

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;
    DECLARE_MAC_BUF(mac);
    
    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, 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: %s\n",
           dev->name, print_mac(mac, 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->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;
}
开发者ID:274914765,项目名称:C,代码行数:89,代码来源:abyss.c

示例7: com90xx_found

/* Set up the struct net_device associated with this card.  Called after
 * probing succeeds.
 */
static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *p)
{
	struct net_device *dev = NULL;
	struct arcnet_local *lp;
	u_long first_mirror, last_mirror;
	int mirror_size;

	/* allocate struct net_device */
	dev = alloc_arcdev(device);
	if (!dev) {
		BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n");
		iounmap(p);
		release_mem_region(shmem, MIRROR_SIZE);
		return -ENOMEM;
	}
	lp = netdev_priv(dev);
	/* find the real shared memory start/end points, including mirrors */

	/* guess the actual size of one "memory mirror" - the number of
	 * bytes between copies of the shared memory.  On most cards, it's
	 * 2k (or there are no mirrors at all) but on some, it's 4k.
	 */
	mirror_size = MIRROR_SIZE;
	if (readb(p) == TESTvalue &&
	    check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
	    check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
		mirror_size = 2 * MIRROR_SIZE;

	first_mirror = shmem - mirror_size;
	while (check_mirror(first_mirror, mirror_size) == 1)
		first_mirror -= mirror_size;
	first_mirror += mirror_size;

	last_mirror = shmem + mirror_size;
	while (check_mirror(last_mirror, mirror_size) == 1)
		last_mirror += mirror_size;
	last_mirror -= mirror_size;

	dev->mem_start = first_mirror;
	dev->mem_end = last_mirror + MIRROR_SIZE - 1;

	iounmap(p);
	release_mem_region(shmem, MIRROR_SIZE);

	if (!request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)"))
		goto err_free_dev;

	/* reserve the irq */
	if (request_irq(airq, arcnet_interrupt, 0, "arcnet (90xx)", dev)) {
		BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", airq);
		goto err_release_mem;
	}
	dev->irq = airq;

	/* Initialize the rest of the device structure. */
	lp->card_name = "COM90xx";
	lp->hw.command = com90xx_command;
	lp->hw.status = com90xx_status;
	lp->hw.intmask = com90xx_setmask;
	lp->hw.reset = com90xx_reset;
	lp->hw.owner = THIS_MODULE;
	lp->hw.copy_to_card = com90xx_copy_to_card;
	lp->hw.copy_from_card = com90xx_copy_from_card;
	lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1);
	if (!lp->mem_start) {
		BUGMSG(D_NORMAL, "Can't remap device memory!\n");
		goto err_free_irq;
	}

	/* get and check the station ID from offset 1 in shmem */
	dev->dev_addr[0] = readb(lp->mem_start + 1);

	dev->base_addr = ioaddr;

	BUGMSG(D_NORMAL, "COM90xx station %02Xh found at %03lXh, IRQ %d, "
	       "ShMem %lXh (%ld*%xh).\n",
	       dev->dev_addr[0],
	       dev->base_addr, dev->irq, dev->mem_start,
	 (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size);

	if (register_netdev(dev))
		goto err_unmap;

	cards[numcards++] = dev;
	return 0;

err_unmap:
	iounmap(lp->mem_start);
err_free_irq:
	free_irq(dev->irq, dev);
err_release_mem:
	release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
err_free_dev:
	free_netdev(dev);
	return -EIO;
}
开发者ID:adis1313,项目名称:android_kernel_samsung_msm8974,代码行数:99,代码来源:com90xx.c

示例8: usbpn_probe

int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
	static const char ifname[] = "usbpn%d";
	const struct usb_cdc_union_desc *union_header = NULL;
	const struct usb_host_interface *data_desc;
	struct usb_interface *data_intf;
	struct usb_device *usbdev = interface_to_usbdev(intf);
	struct net_device *dev;
	struct usbpn_dev *pnd;
	u8 *data;
	int phonet = 0;
	int len, err;

	data = intf->altsetting->extra;
	len = intf->altsetting->extralen;
	while (len >= 3) {
		u8 dlen = data[0];
		if (dlen < 3)
			return -EINVAL;

		/* bDescriptorType */
		if (data[1] == USB_DT_CS_INTERFACE) {
			/* bDescriptorSubType */
			switch (data[2]) {
			case USB_CDC_UNION_TYPE:
				if (union_header || dlen < 5)
					break;
				union_header =
					(struct usb_cdc_union_desc *)data;
				break;
			case 0xAB:
				phonet = 1;
				break;
			}
		}
		data += dlen;
		len -= dlen;
	}

	if (!union_header || !phonet)
		return -EINVAL;

	data_intf = usb_ifnum_to_if(usbdev, union_header->bSlaveInterface0);
	if (data_intf == NULL)
		return -ENODEV;
	/* Data interface has one inactive and one active setting */
	if (data_intf->num_altsetting != 2)
		return -EINVAL;
	if (data_intf->altsetting[0].desc.bNumEndpoints == 0 &&
	    data_intf->altsetting[1].desc.bNumEndpoints == 2)
		data_desc = data_intf->altsetting + 1;
	else
	if (data_intf->altsetting[0].desc.bNumEndpoints == 2 &&
	    data_intf->altsetting[1].desc.bNumEndpoints == 0)
		data_desc = data_intf->altsetting;
	else
		return -EINVAL;

	dev = alloc_netdev(sizeof(*pnd) + sizeof(pnd->urbs[0]) * rxq_size,
				ifname, usbpn_setup);
	if (!dev)
		return -ENOMEM;

	pnd = netdev_priv(dev);
	SET_NETDEV_DEV(dev, &intf->dev);
	netif_stop_queue(dev);

	pnd->dev = dev;
	pnd->usb = usb_get_dev(usbdev);
	pnd->intf = intf;
	pnd->data_intf = data_intf;
	spin_lock_init(&pnd->tx_lock);
	spin_lock_init(&pnd->rx_lock);
	/* Endpoints */
	if (usb_pipein(data_desc->endpoint[0].desc.bEndpointAddress)) {
		pnd->rx_pipe = usb_rcvbulkpipe(usbdev,
			data_desc->endpoint[0].desc.bEndpointAddress);
		pnd->tx_pipe = usb_sndbulkpipe(usbdev,
			data_desc->endpoint[1].desc.bEndpointAddress);
	} else {
		pnd->rx_pipe = usb_rcvbulkpipe(usbdev,
			data_desc->endpoint[1].desc.bEndpointAddress);
		pnd->tx_pipe = usb_sndbulkpipe(usbdev,
			data_desc->endpoint[0].desc.bEndpointAddress);
	}
	pnd->active_setting = data_desc - data_intf->altsetting;

	err = usb_driver_claim_interface(&usbpn_driver, data_intf, pnd);
	if (err)
		goto out;

	/* Force inactive mode until the network device is brought UP */
	usb_set_interface(usbdev, union_header->bSlaveInterface0,
				!pnd->active_setting);
	usb_set_intfdata(intf, pnd);

	err = register_netdev(dev);
	if (err) {
		usb_driver_release_interface(&usbpn_driver, data_intf);
		goto out;
//.........这里部分代码省略.........
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:101,代码来源:cdc-phonet.c

示例9: hpp_probe1


//.........这里部分代码省略.........
	if (inw(ioaddr + HP_ID) != 0x4850
		|| (inw(ioaddr + HP_PAGING) & 0xfff0) != 0x5300) {
		retval = -ENODEV;
		goto out;
	}

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

	printk("%s: %s at %#3x, ", dev->name, name, ioaddr);

	/* Retrieve and checksum the station address. */
	outw(MAC_Page, ioaddr + HP_PAGING);

	for(i = 0; i < ETHER_ADDR_LEN; i++) {
		unsigned char inval = inb(ioaddr + 8 + i);
		dev->dev_addr[i] = inval;
		checksum += inval;
	}
	checksum += inb(ioaddr + 14);

	printk("%pM", dev->dev_addr);

	if (checksum != 0xff) {
		printk(" bad checksum %2.2x.\n", checksum);
		retval = -ENODEV;
		goto out;
	} else {
		/* Point at the Software Configuration Flags. */
		outw(ID_Page, ioaddr + HP_PAGING);
		printk(" ID %4.4x", inw(ioaddr + 12));
	}

	/* Read the IRQ line. */
	outw(HW_Page, ioaddr + HP_PAGING);
	{
		int irq = inb(ioaddr + 13) & 0x0f;
		int option = inw(ioaddr + HPP_OPTION);

		dev->irq = irq;
		if (option & MemEnable) {
			mem_start = inw(ioaddr + 9) << 8;
			printk(", IRQ %d, memory address %#x.\n", irq, mem_start);
		} else {
			mem_start = 0;
			printk(", IRQ %d, programmed-I/O mode.\n", irq);
		}
	}

	/* Set the wrap registers for string I/O reads.   */
	outw((HP_START_PG + TX_PAGES/2) | ((HP_STOP_PG - 1) << 8), ioaddr + 14);

	/* Set the base address to point to the NIC, not the "real" base! */
	dev->base_addr = ioaddr + NIC_OFFSET;

	dev->netdev_ops = &hpp_netdev_ops;

	ei_status.name = name;
	ei_status.word16 = 0;		/* Agggghhhhh! Debug time: 2 days! */
	ei_status.tx_start_page = HP_START_PG;
	ei_status.rx_start_page = HP_START_PG + TX_PAGES/2;
	ei_status.stop_page = HP_STOP_PG;

	ei_status.reset_8390 = &hpp_reset_8390;
	ei_status.block_input = &hpp_io_block_input;
	ei_status.block_output = &hpp_io_block_output;
	ei_status.get_8390_hdr = &hpp_io_get_8390_hdr;

	/* Check if the memory_enable flag is set in the option register. */
	if (mem_start) {
		ei_status.block_input = &hpp_mem_block_input;
		ei_status.block_output = &hpp_mem_block_output;
		ei_status.get_8390_hdr = &hpp_mem_get_8390_hdr;
		dev->mem_start = mem_start;
		ei_status.mem = ioremap(mem_start,
					(HP_STOP_PG - HP_START_PG)*256);
		if (!ei_status.mem) {
			retval = -ENOMEM;
			goto out;
		}
		ei_status.rmem_start = dev->mem_start + TX_PAGES/2*256;
		dev->mem_end = ei_status.rmem_end
			= dev->mem_start + (HP_STOP_PG - HP_START_PG)*256;
	}

	outw(Perf_Page, ioaddr + HP_PAGING);
	NS8390p_init(dev, 0);
	/* Leave the 8390 and HP chip reset. */
	outw(inw(ioaddr + HPP_OPTION) & ~EnableIRQ, ioaddr + HPP_OPTION);

	retval = register_netdev(dev);
	if (retval)
		goto out1;
	return 0;
out1:
	iounmap(ei_status.mem);
out:
	release_region(ioaddr, HP_IO_EXTENT);
	return retval;
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:101,代码来源:hp-plus.c

示例10: rmnet_init

static int __init rmnet_init(void)
{
	int ret;
	struct device *d;
	struct net_device *dev;
	struct rmnet_private *p;
	unsigned n;

#ifdef CONFIG_MSM_RMNET_DEBUG
	timeout_us = 0;
#ifdef CONFIG_HAS_EARLYSUSPEND
	timeout_suspend_us = 0;
#endif
#endif

#ifdef CONFIG_MSM_RMNET_DEBUG
	rmnet_wq = create_workqueue("rmnet");
#endif

	for (n = 0; n < 3; n++) {
		dev = alloc_netdev(sizeof(struct rmnet_private),
				   "rmnet%d", rmnet_setup);

		if (!dev)
			return -ENOMEM;

		d = &(dev->dev);
		p = netdev_priv(dev);
		p->skb = 0;
		p->chname = ch_name[n];
		wake_lock_init(&p->wake_lock, WAKE_LOCK_SUSPEND, ch_name[n]);
#ifdef CONFIG_MSM_RMNET_DEBUG
		p->timeout_us = timeout_us;
		p->awake_time_ms = p->wakeups_xmit = p->wakeups_rcv = 0;
		p->active_countdown = p->restart_count = 0;
		INIT_DELAYED_WORK_DEFERRABLE(&p->work, do_check_active);
#endif

		ret = register_netdev(dev);
		if (ret) {
			free_netdev(dev);
			return ret;
		}

#ifdef CONFIG_MSM_RMNET_DEBUG
		if (device_create_file(d, &dev_attr_timeout))
			continue;
		if (device_create_file(d, &dev_attr_wakeups_xmit))
			continue;
		if (device_create_file(d, &dev_attr_wakeups_rcv))
			continue;
		if (device_create_file(d, &dev_attr_awake_time_ms))
			continue;
#ifdef CONFIG_HAS_EARLYSUSPEND
		if (device_create_file(d, &dev_attr_timeout_suspend))
			continue;

		/* Only care about rmnet0 for suspend/resume tiemout hooks. */
		if (n == 0)
			rmnet0 = d;
#endif
#endif
	}
	return 0;
}
开发者ID:rex12345,项目名称:kernel-2.6.29-M860,代码行数:65,代码来源:msm_rmnet.c

示例11: ac_probe1


//.........这里部分代码省略.........
           inb(ioaddr + AC_ID_PORT + 0), inb(ioaddr + AC_ID_PORT + 1),
           inb(ioaddr + AC_ID_PORT + 2), inb(ioaddr + AC_ID_PORT + 3));
#endif

    for (i = 0; i < 6; i++)
        dev->dev_addr[i] = inb(ioaddr + AC_SA_PROM + i);

    printk(KERN_DEBUG "AC3200 in EISA slot %d, node %pM",
           ioaddr/0x1000, dev->dev_addr);
#if 0

    if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0
            || inb(ioaddr + AC_SA_PROM + 1) != AC_ADDR1
            || inb(ioaddr + AC_SA_PROM + 2) != AC_ADDR2 ) {
        printk(", not found (invalid prefix).\n");
        retval = -ENODEV;
        goto out;
    }
#endif


    if (dev->irq == 0) {
        dev->irq = config2irq(inb(ioaddr + AC_CONFIG));
        printk(", using");
    } else {
        dev->irq = irq_canonicalize(dev->irq);
        printk(", assigning");
    }

    retval = request_irq(dev->irq, ei_interrupt, 0, DRV_NAME, dev);
    if (retval) {
        printk (" nothing! Unable to get IRQ %d.\n", dev->irq);
        goto out;
    }

    printk(" IRQ %d, %s port\n", dev->irq, port_name[dev->if_port]);

    dev->base_addr = ioaddr;

#ifdef notyet
    if (dev->mem_start)	{
        for (i = 0; i < 7; i++)
            if (addrmap[i] == dev->mem_start)
                break;
        if (i >= 7)
            i = 0;
        outb((inb(ioaddr + AC_CONFIG) & ~7) | i, ioaddr + AC_CONFIG);
    }
#endif

    dev->if_port = inb(ioaddr + AC_CONFIG) >> 6;
    dev->mem_start = config2mem(inb(ioaddr + AC_CONFIG));

    printk("%s: AC3200 at %#3x with %dkB memory at physical address %#lx.\n",
           dev->name, ioaddr, AC_STOP_PG/4, dev->mem_start);

    ei_status.mem = ioremap(dev->mem_start, AC_STOP_PG*0x100);
    if (!ei_status.mem) {
        printk(KERN_ERR "ac3200.c: Unable to remap card memory above 1MB !!\n");
        printk(KERN_ERR "ac3200.c: Try using EISA SCU to set memory below 1MB.\n");
        printk(KERN_ERR "ac3200.c: Driver NOT installed.\n");
        retval = -EINVAL;
        goto out1;
    }
    printk("ac3200.c: remapped %dkB card memory to virtual address %p\n",
           AC_STOP_PG/4, ei_status.mem);

    dev->mem_start = (unsigned long)ei_status.mem;
    dev->mem_end = dev->mem_start + (AC_STOP_PG - AC_START_PG)*256;

    ei_status.name = "AC3200";
    ei_status.tx_start_page = AC_START_PG;
    ei_status.rx_start_page = AC_START_PG + TX_PAGES;
    ei_status.stop_page = AC_STOP_PG;
    ei_status.word16 = 1;

    if (ei_debug > 0)
        printk(version);

    ei_status.reset_8390 = &ac_reset_8390;
    ei_status.block_input = &ac_block_input;
    ei_status.block_output = &ac_block_output;
    ei_status.get_8390_hdr = &ac_get_8390_hdr;

    dev->netdev_ops = &ac_netdev_ops;
    NS8390_init(dev, 0);

    retval = register_netdev(dev);
    if (retval)
        goto out2;
    return 0;
out2:
    if (ei_status.reg0)
        iounmap(ei_status.mem);
out1:
    free_irq(dev->irq, dev);
out:
    release_region(ioaddr, AC_IO_EXTENT);
    return retval;
}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:101,代码来源:ac3200.c

示例12: yatse_probe

static int yatse_probe(struct platform_device *pdev){
	struct net_device *ndev;
	struct yatse_private *priv;
	int ret;
	int i;

	printk(KERN_INFO "yatse_probe() start\n");

	ndev = alloc_etherdev(sizeof(*priv));
	if(!ndev){
		printk(KERN_ERR "%s:%d: alloc_etherdev() failed\n", __FILE__, __LINE__);
		return -ENODEV;
	}
	priv = netdev_priv(ndev);
	priv->ndev = ndev;
	SET_NETDEV_DEV(ndev, &pdev->dev);
	platform_set_drvdata(pdev, ndev);

	spin_lock_init(&priv->mac_lock);
	spin_lock_init(&priv->dma.rx_lock);
	spin_lock_init(&priv->dma.tx_lock);

	priv->config = (struct yatse_config *)pdev->dev.platform_data;
	priv->phy_irq = PHY_POLL;
	priv->mtu = priv->config->max_mtu;
	for(i = 0;i < 6;i++) ndev->dev_addr[i] = priv->config->ethaddr[i];

	if(!(priv->mac = (yatse_mac_regs *)yatse_iomap(pdev, YATSE_RESOURCE_MAC, 0))) return -ENODEV;
	if(!(priv->dma.csr = yatse_iomap(pdev, YATSE_RESOURCE_DMA_CSR, 0))) return -ENODEV;

	priv->dma.rx_ring_length = readl(&priv->dma.csr->rx);
	priv->dma.rx_ring_mask = priv->dma.rx_ring_length - 1;
	if((priv->dma.rx_ring_length <= 0) || (priv->dma.rx_ring_length & priv->dma.rx_ring_mask)){
		printk(KERN_ERR "yatse_probe: bogus HW RX ring size %08x\n", priv->dma.rx_ring_length);
		return -EIO;
	}
	priv->dma.tx_ring_length = readl(&priv->dma.csr->tx);
	priv->dma.tx_ring_mask = priv->dma.tx_ring_length - 1;
	if((priv->dma.tx_ring_length <= 0) || (priv->dma.tx_ring_length & priv->dma.tx_ring_mask)){
		printk(KERN_ERR "yatse_probe: bogus HW TX ring size %08x\n", priv->dma.tx_ring_length);
		return -EIO;
	}

	if(!(priv->dma.rx = yatse_iomap(pdev, YATSE_RESOURCE_RX_RING, priv->dma.rx_ring_length * sizeof(yatse_dma_desc)))) return -ENODEV;
	if(!(priv->dma.tx = yatse_iomap(pdev, YATSE_RESOURCE_TX_RING, priv->dma.tx_ring_length * sizeof(yatse_dma_desc)))) return -ENODEV;


	priv->dma.rx_irq = yatse_get_irq(pdev, YATSE_RESOURCE_RX_IRQ);
	if(priv->dma.rx_irq == -1) return -ENODEV;
	ret = request_irq(priv->dma.rx_irq, (void *)yatse_rx_isr, 0, "yatse-RX", ndev);
	if(ret){
		printk(KERN_ERR "%s:%d: request_irq() failed\n", __FILE__, __LINE__);
		return -EAGAIN;
	}

	priv->dma.tx_irq = yatse_get_irq(pdev, YATSE_RESOURCE_TX_IRQ);
	if(priv->dma.tx_irq == -1) return -ENODEV;
	ret = request_irq(priv->dma.tx_irq, (void *)yatse_tx_isr, 0, "yatse-TX", ndev);
	if(ret){
		printk(KERN_ERR "%s:%d: request_irq() failed\n", __FILE__, __LINE__);
		return -EAGAIN;
	}

	priv->phy_irq = yatse_get_irq(pdev, YATSE_RESOURCE_PHY_IRQ);

	printk(KERN_INFO "yatse: device probed; mac=%p, phy_irq=%d, dma.csr=%p, dma.rx=%p, dma.tx=%p, dma.rx_irq=%d, dma.tx_irq=%d, mtu=%d, rx_ring_length=%d, tx_ring_length=%d, fifo=%d\n", priv->mac, priv->phy_irq, priv->dma.csr, priv->dma.rx, priv->dma.tx, priv->dma.rx_irq, priv->dma.tx_irq, priv->mtu, priv->dma.rx_ring_length, priv->dma.tx_ring_length, priv->config->fifo_depth);

	ret = yatse_mdio_register(priv);
	if(ret){
		printk(KERN_ERR "%s:%d: yatse_mdio_register() failed\n", __FILE__, __LINE__);
		return -ENODEV;
	}

	ndev->netdev_ops = &yatse_netdev_ops;
	ndev->watchdog_timeo = msecs_to_jiffies(5000);
	netif_napi_add(ndev, &priv->napi, yatse_rx_poll, 64);

	ret = register_netdev(ndev);
	if(ret){
		printk(KERN_ERR "%s:%d: register_netdev() failed\n", __FILE__, __LINE__);
		return -ENODEV;
	}

	printk(KERN_INFO "yatse_probe() end\n");
	return 0;
}
开发者ID:hoangt,项目名称:multicoreFPGA-z4800,代码行数:86,代码来源:yatse_drv.c

示例13: elplus_setup


//.........这里部分代码省略.........
	if (dev->irq) {		/* Is there a preset IRQ? */
		int rpt = probe_irq_off(cookie);
		if (dev->irq != rpt) {
			pr_warning("%s: warning, irq %d configured but %d detected\n", dev->name, dev->irq, rpt);
		}
		/* if dev->irq == probe_irq_off(cookie), all is well */
	} else		       /* No preset IRQ; just use what we can detect */
		dev->irq = probe_irq_off(cookie);
	switch (dev->irq) {    /* Legal, sane? */
	case 0:
		pr_err("%s: IRQ probe failed: check 3c505 jumpers.\n",
		       dev->name);
		goto out;
	case 1:
	case 6:
	case 8:
	case 13:
		pr_err("%s: Impossible IRQ %d reported by probe_irq_off().\n",
		       dev->name, dev->irq);
		       goto out;
	}
	/*
	 *  Now we have the IRQ number so we can disable the interrupts from
	 *  the board until the board is opened.
	 */
	outb_control(adapter->hcr_val & ~CMDE, dev);

	/*
	 * copy Ethernet address into structure
	 */
	for (i = 0; i < 6; i++)
		dev->dev_addr[i] = adapter->rx_pcb.data.eth_addr[i];

	/* find a DMA channel */
	if (!dev->dma) {
		if (dev->mem_start) {
			dev->dma = dev->mem_start & 7;
		}
		else {
			pr_warning("%s: warning, DMA channel not specified, using default\n", dev->name);
			dev->dma = ELP_DMA;
		}
	}

	/*
	 * print remainder of startup message
	 */
	pr_info("%s: 3c505 at %#lx, irq %d, dma %d, addr %pM, ",
		dev->name, dev->base_addr, dev->irq, dev->dma, dev->dev_addr);
	/*
	 * read more information from the adapter
	 */

	adapter->tx_pcb.command = CMD_ADAPTER_INFO;
	adapter->tx_pcb.length = 0;
	if (!send_pcb(dev, &adapter->tx_pcb) ||
	    !receive_pcb(dev, &adapter->rx_pcb) ||
	    (adapter->rx_pcb.command != CMD_ADAPTER_INFO_RESPONSE) ||
	    (adapter->rx_pcb.length != 10)) {
		pr_cont("not responding to second PCB\n");
	}
	pr_cont("rev %d.%d, %dk\n", adapter->rx_pcb.data.info.major_vers,
		adapter->rx_pcb.data.info.minor_vers, adapter->rx_pcb.data.info.RAM_sz);

	/*
	 * reconfigure the adapter memory to better suit our purposes
	 */
	adapter->tx_pcb.command = CMD_CONFIGURE_ADAPTER_MEMORY;
	adapter->tx_pcb.length = 12;
	adapter->tx_pcb.data.memconf.cmd_q = 8;
	adapter->tx_pcb.data.memconf.rcv_q = 8;
	adapter->tx_pcb.data.memconf.mcast = 10;
	adapter->tx_pcb.data.memconf.frame = 10;
	adapter->tx_pcb.data.memconf.rcv_b = 10;
	adapter->tx_pcb.data.memconf.progs = 0;
	if (!send_pcb(dev, &adapter->tx_pcb) ||
	    !receive_pcb(dev, &adapter->rx_pcb) ||
	    (adapter->rx_pcb.command != CMD_CONFIGURE_ADAPTER_RESPONSE) ||
	    (adapter->rx_pcb.length != 2)) {
		pr_err("%s: could not configure adapter memory\n", dev->name);
	}
	if (adapter->rx_pcb.data.configure) {
		pr_err("%s: adapter configuration failed\n", dev->name);
	}

	dev->netdev_ops = &elp_netdev_ops;
	dev->watchdog_timeo = 10*HZ;
	dev->ethtool_ops = &netdev_ethtool_ops;		/* local */

	dev->mem_start = dev->mem_end = 0;

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

	return 0;
out:
	release_region(dev->base_addr, ELP_IO_EXTENT);
	return err;
}
开发者ID:GerardGarcia,项目名称:linux,代码行数:101,代码来源:3c505.c

示例14: gether_setup

/**
 * gether_setup - initialize one ethernet-over-usb link
 * @g: gadget to associated with these links
 * @ethaddr: NULL, or a buffer in which the ethernet address of the
 *	host side of the link is recorded
 * Context: may sleep
 *
 * This sets up the single network link that may be exported by a
 * gadget driver using this framework.  The link layer addresses are
 * set up using module parameters.
 *
 * Returns negative errno, or zero on success
 */
int __init gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
{
	struct eth_dev		*dev;
	struct net_device	*net;
	int			status;

	if (the_dev)
		return -EBUSY;

	net = alloc_etherdev(sizeof *dev);
	if (!net)
		return -ENOMEM;

	dev = netdev_priv(net);
	spin_lock_init(&dev->lock);
	spin_lock_init(&dev->req_lock);
	INIT_WORK(&dev->work, eth_work);
	INIT_LIST_HEAD(&dev->tx_reqs);
	INIT_LIST_HEAD(&dev->rx_reqs);

	skb_queue_head_init(&dev->rx_frames);

	/* network device setup */
	dev->net = net;
	strcpy(net->name, "usb%d");

	if (get_ether_addr(dev_addr, net->dev_addr))
		dev_warn(&g->dev,
			"using random %s ethernet address\n", "self");
	if (get_ether_addr(host_addr, dev->host_mac))
		dev_warn(&g->dev,
			"using random %s ethernet address\n", "host");

	if (ethaddr)
		memcpy(ethaddr, dev->host_mac, ETH_ALEN);

	net->netdev_ops = &eth_netdev_ops;

	SET_ETHTOOL_OPS(net, &ops);

	/* two kinds of host-initiated state changes:
	 *  - iff DATA transfer is active, carrier is "on"
	 *  - tx queueing enabled if open *and* carrier is "on"
	 */
	netif_stop_queue(net);
	netif_carrier_off(net);

	dev->gadget = g;
	SET_NETDEV_DEV(net, &g->dev);

	status = register_netdev(net);
	if (status < 0) {
		dev_dbg(&g->dev, "register_netdev failed, %d\n", status);
		free_netdev(net);
	} else {
		INFO(dev, "MAC %pM\n", net->dev_addr);
		INFO(dev, "HOST MAC %pM\n", dev->host_mac);

		the_dev = dev;
	}

	return status;
}
开发者ID:Aircell,项目名称:asp-kernel,代码行数:76,代码来源:u_ether.c

示例15: bionet_probe

/* 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);
	}

	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);
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:80,代码来源:atari_bionet.c


注:本文中的register_netdev函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。