Example #1
0
/*
 * The init function, invoked by register_netdev()
 */
static int __s3c4510b_init(struct net_device *dev)
{
	ether_setup(dev);

	/* assign net_device methods */
	dev->open = __s3c4510b_open;
	dev->stop = __s3c4510b_stop;
//	dev->ioctl = __s3c4510b_ioctl;
	dev->get_stats = __s3c4510b_get_stats;
//	dev->tx_timeout = __s3c4510b_tx_timeout;
	dev->hard_start_xmit = __s3c4510b_start_xmit;

	dev->irq = INT_BDMARX;
	dev->tx_queue_len = ETH_NTxFrames;
	dev->dma = 0;
	dev->watchdog_timeo = HZ;

	/* set MAC address */
	dev->dev_addr[0] = 0x00;
	dev->dev_addr[1] = 0x40;
	dev->dev_addr[2] = 0x95;
	dev->dev_addr[3] = 0x36;
	dev->dev_addr[4] = 0x35;
	dev->dev_addr[5] = 0x33;

	SET_MODULE_OWNER(dev);

	dev->priv = kmalloc(sizeof(struct eth_priv), GFP_KERNEL);
	if( dev->priv == NULL)
		return -ENOMEM;
	memset(dev->priv, 0, sizeof(struct eth_priv));
	spin_lock_init(&((struct eth_priv *) dev->priv)->lock);
	return 0;
}
Example #2
0
static int __init lcm_init_module(void)
#endif
{
    int result;

    DPRINT("LCM: init module for %s driver\n", LCM_MODULE_VERSION);
    /* Register driver with OS. Pass lcm_major device number of devices
     * this drive manages. If lcm_major is 0, a major num will dynamically
     * be assigned to driver and returned in result. Register struct
     * of callback functions too.
     */

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
    SET_MODULE_OWNER(&lcm_fops);
#endif

    /*if major number is 0(dynamically assign), return the requested major#
     *if major > 0(predefined), return 0 when success*/
    result = register_chrdev(lcm_major, LCM_DEVICE_NAME, &lcm_fops);
    if (result < 0)
    {
        printk(KERN_ERR "LCM: Unable to get major device %d for LCM device\n",
                lcm_major);

        return (-EBUSY);
    }
    lcm_major = (lcm_major != 0) ? lcm_major : result;

    lcm_opened = 0;

    lcm_init_lcd();     // init lcd at module load time

    return (0);
}
Example #3
0
File: pipe.c Project: crond/dd
int scull_p_init(void)
{
    int i;

    SET_MODULE_OWNER(&scull_pipe_fops);
    scull_p_devices = kmalloc(scull_p_nr_devs * sizeof(Scull_Pipe),
                              GFP_KERNEL);
    if (scull_p_devices == NULL)
        return -ENOMEM;
    memset(scull_p_devices, 0, scull_p_nr_devs * sizeof(Scull_Pipe));
    for (i = 0; i < scull_p_nr_devs; i++) {
        init_waitqueue_head(&(scull_p_devices[i].inq));
        init_waitqueue_head(&(scull_p_devices[i].outq));
        sema_init(&scull_p_devices[i].sem, 1);
#ifdef CONFIG_DEVFS_FS
        sprintf(pipename, "pipe%i", i);
        scull_p_devices[i].handle =
            devfs_register(scull_devfs_dir, pipename,
                           DEVFS_FL_AUTO_DEVNUM,
                           0, 0, S_IFCHR | S_IRUGO | S_IWUGO,
                           &scull_pipe_fops,
                           scull_p_devices + i);
        if (!scull_p_devices[i].handle) {
            /* ignore errors, at worse we have less devices */
            printk(KERN_WARNING
                   "scull: can't register pipe device nr. %i\n", i);
        }
#endif
    }
#ifdef SCULL_DEBUG
    create_proc_read_entry("scullpipe", 0, NULL, scull_read_p_mem, NULL);
#endif
    return 0;
}
Example #4
0
static int __init do_ac3200_probe(struct net_device *dev)
{
	unsigned short ioaddr = dev->base_addr;
	int irq = dev->irq;
	int mem_start = dev->mem_start;

	SET_MODULE_OWNER(dev);

	if (ioaddr > 0x1ff)		/* Check a single specified location. */
		return ac_probe1(ioaddr, dev);
	else if (ioaddr > 0)		/* Don't probe at all. */
		return -ENXIO;

	if ( ! EISA_bus)
		return -ENXIO;

	for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
		if (ac_probe1(ioaddr, dev) == 0)
			return 0;
		dev->irq = irq;
		dev->mem_start = mem_start;
	}

	return -ENODEV;
}
Example #5
0
int __init eth16i_probe(struct net_device *dev)
{
	int i;
	int ioaddr;
	int base_addr = dev->base_addr;
    
	SET_MODULE_OWNER(dev);

	if(eth16i_debug > 4) 
		printk(KERN_DEBUG "Probing started for %s\n", cardname);

	if(base_addr > 0x1ff)           /* Check only single location */
		return eth16i_probe1(dev, base_addr);
	else if(base_addr != 0)         /* Don't probe at all */
		return -ENXIO;

	/* Seek card from the ISA io address space */
	for(i = 0; (ioaddr = eth16i_portlist[i]) ; i++)
		if(eth16i_probe1(dev, ioaddr) == 0)
			return 0;

	/* Seek card from the EISA io address space */
	for(i = 0; (ioaddr = eth32i_portlist[i]) ; i++)
		if(eth16i_probe1(dev, ioaddr) == 0)
			return 0;

	return -ENODEV;
}
Example #6
0
/* This routine probes for a memory-mapped 3c503 board by looking for
   the "location register" at the end of the jumpered boot PROM space.
   This works even if a PROM isn't there.

   If the ethercard isn't found there is an optional probe for
   ethercard jumpered to programmed-I/O mode.
   */
static int __init do_el2_probe(struct net_device *dev)
{
    int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
    int base_addr = dev->base_addr;
    int irq = dev->irq;

    SET_MODULE_OWNER(dev);

    if (base_addr > 0x1ff)	/* Check a single specified location. */
        return el2_probe1(dev, base_addr);
    else if (base_addr != 0)		/* Don't probe at all. */
        return -ENXIO;

    for (addr = addrs; *addr; addr++) {
        void __iomem *p = ioremap(*addr, 1);
        unsigned base_bits;
        int i;

        if (!p)
            continue;
        base_bits = readb(p);
        iounmap(p);
        i = ffs(base_bits) - 1;
        if (i == -1 || base_bits != (1 << i))
            continue;
        if (el2_probe1(dev, netcard_portlist[i]) == 0)
            return 0;
        dev->irq = irq;
    }
#if ! defined(no_probe_nonshared_memory)
    return el2_pio_probe(dev);
#else
    return -ENODEV;
#endif
}
static int __init do_es_probe(struct net_device *dev)
{
	unsigned short ioaddr = dev->base_addr;
	int irq = dev->irq;
	int mem_start = dev->mem_start;

	SET_MODULE_OWNER(dev);

	if (ioaddr > 0x1ff)		/* Check a single specified location. */
		return es_probe1(dev, ioaddr);
	else if (ioaddr > 0)		/* Don't probe at all. */
		return -ENXIO;

	if (!EISA_bus) {
#if ES_DEBUG & ES_D_PROBE
		printk("es3210.c: Not EISA bus. Not probing high ports.\n");
#endif
		return -ENXIO;
	}

	/* EISA spec allows for up to 16 slots, but 8 is typical. */
	for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
		if (es_probe1(dev, ioaddr) == 0)
			return 0;
		dev->irq = irq;
		dev->mem_start = mem_start;
	}

	return -ENODEV;
}
Example #8
0
//Genia's add:
int init_module(int max_games) {
	maxGames = max_games;
	games = kmalloc(sizeof(Game) * max_games, GFP_KERNEL);
	for(int i=0,i<max_games;i++
			) {
				games[i].board=kmalloc(sizeof(int) * N*N, GFP_KERNEL);
				Init(&(games[i].board));
				games[i].currentPlayer=WHITE;
				games[i].openCount=0;
				games[i].isFinished=false;
				games[i].isRealesed=false;
				games[i].winner=NOT_FINISHED;
				sema_init(&(games[i].countLock), 0);
				sema_init(&(games[i].openLock), 0);
				sema_init(&(games[i].readWriteLock), 0);
				sema_init(&(games[i].whiteLock), 0);
				sema_init(&(games[i].blackLock), 0);
				sema_init(&(games[i].isFinishedLock), 0);
				sema_init(&(games[i].isReleasedLock), 0);
				sema_init(&(games[i].winnerLock), 0);
			}

			major = register_chrdev(0, "snake", &fops);
			MODULE_PARM(maxGames, "i");
			MODULE_PARM(games, "i");
			MODULE_PARM(major, "i");
			SET_MODULE_OWNER(&fops);
			return 0;
		}
Example #9
0
PNET_DEV RtmpPhyNetDevInit(
	IN RTMP_ADAPTER *pAd,
	IN RTMP_OS_NETDEV_OP_HOOK *pNetDevHook)
{
	struct net_device	*net_dev = NULL;
//	NDIS_STATUS		Status;

	net_dev = RtmpOSNetDevCreate(pAd, INT_MAIN, 0, sizeof(PRTMP_ADAPTER), INF_MAIN_DEV_NAME);
	if (net_dev == NULL)
	{
		printk("RtmpPhyNetDevInit(): creation failed for main physical net device!\n");
		return NULL;
	}

	NdisZeroMemory((unsigned char *)pNetDevHook, sizeof(RTMP_OS_NETDEV_OP_HOOK));
	pNetDevHook->netdev_ops = &rt3090_netdev_ops;
	pNetDevHook->priv_flags = INT_MAIN;
	pNetDevHook->needProtcted = FALSE;

	RTMP_OS_NETDEV_SET_PRIV(net_dev, pAd);
	//net_dev->priv = (PVOID)pAd;
	pAd->net_dev = net_dev;



#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
	SET_MODULE_OWNER(net_dev);
#endif

	netif_stop_queue(net_dev);

	return net_dev;

}
int __init sun3_82586_probe(struct net_device *dev)
{
 	unsigned long ioaddr;
	static int found = 0;
	
	/* 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(-ENODEV);
	}

	if(found)
		return -ENODEV;
	
	ioaddr = (unsigned long)ioremap(IE_OBIO, PAGE_SIZE);
	found = 1;
	
	SET_MODULE_OWNER(dev);

	dev->irq = IE_IRQ;
	dev->base_addr = ioaddr;
	if(sun3_82586_probe1(dev, ioaddr) == 0)
		return 0;

	return -ENODEV;
}
Example #11
0
static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int create)
{
	u32 remote = parms->iph.daddr;
	u32 local = parms->iph.saddr;
	struct ip_tunnel *t, **tp, *nt;
	struct net_device *dev;
	unsigned h = 0;
	int prio = 0;
	char name[IFNAMSIZ];

	if (remote) {
		prio |= 2;
		h ^= HASH(remote);
	}
	if (local) {
		prio |= 1;
		h ^= HASH(local);
	}
	for (tp = &tunnels[prio][h]; (t = *tp) != NULL; tp = &t->next) {
		if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr)
			return t;
	}
	if (!create)
		return NULL;

	if (parms->name[0])
		strlcpy(name, parms->name, IFNAMSIZ);
	else {
		int i;
		for (i=1; i<100; i++) {
			sprintf(name, "tunl%d", i);
			if (__dev_get_by_name(name) == NULL)
				break;
		}
		if (i==100)
			goto failed;
	}

	dev = alloc_netdev(sizeof(*t), name, ipip_tunnel_setup);
	if (dev == NULL)
		return NULL;

	nt = dev->priv;
	SET_MODULE_OWNER(dev);
	dev->init = ipip_tunnel_init;
	nt->parms = *parms;

	if (register_netdevice(dev) < 0) {
		free_netdev(dev);
		goto failed;
	}

	dev_hold(dev);
	ipip_tunnel_link(nt);
	/* Do not decrement MOD_USE_COUNT here. */
	return nt;

failed:
	return NULL;
}
Example #12
0
int __init ne3210_probe(struct net_device *dev)
{
	unsigned short ioaddr = dev->base_addr;

	SET_MODULE_OWNER(dev);

	if (ioaddr > 0x1ff)		/* Check a single specified location. */
		return ne3210_probe1(dev, ioaddr);
	else if (ioaddr > 0)		/* Don't probe at all. */
		return -ENXIO;

	if (!EISA_bus) {
#if NE3210_DEBUG & NE3210_D_PROBE
		printk("ne3210-debug: Not an EISA bus. Not probing high ports.\n");
#endif
		return -ENXIO;
	}

	/* EISA spec allows for up to 16 slots, but 8 is typical. */
	for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000)
		if (ne3210_probe1(dev, ioaddr) == 0)
			return 0;

	return -ENODEV;
}
Example #13
0
/***
 *  loopback_init
 */
static int __init loopback_init(void)
{
    int err;
    struct rtnet_device *rtdev;

    rt_printk("initializing loopback...\n");

    if ((rtdev = rt_alloc_etherdev(0)) == NULL)
        return -ENODEV;

    rt_rtdev_connect(rtdev, &RTDEV_manager);
    SET_MODULE_OWNER(rtdev);

    strcpy(rtdev->name, "rtlo");

    rtdev->open = &rt_loopback_open;
    rtdev->stop = &rt_loopback_close;
    rtdev->hard_header = rt_eth_header;
    rtdev->hard_start_xmit = &rt_loopback_xmit;

    if ((err = rt_register_rtnetdev(rtdev)) != 0)
    {
        rtdev_free(rtdev);
        return err;
    }

    rt_loopback_dev = rtdev;

    return 0;
}
Example #14
0
/* This routine probes for a memory-mapped 3c503 board by looking for
   the "location register" at the end of the jumpered boot PROM space.
   This works even if a PROM isn't there.

   If the ethercard isn't found there is an optional probe for
   ethercard jumpered to programmed-I/O mode.
   */
int __init 
el2_probe(struct net_device *dev)
{
    int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
    int base_addr = dev->base_addr;

    SET_MODULE_OWNER(dev);
    
    if (base_addr > 0x1ff)	/* Check a single specified location. */
	return el2_probe1(dev, base_addr);
    else if (base_addr != 0)		/* Don't probe at all. */
	return -ENXIO;

    for (addr = addrs; *addr; addr++) {
	int i;
	unsigned int base_bits = isa_readb(*addr);
	/* Find first set bit. */
	for(i = 7; i >= 0; i--, base_bits >>= 1)
	    if (base_bits & 0x1)
		break;
	if (base_bits != 1)
	    continue;
	if (el2_probe1(dev, netcard_portlist[i]) == 0)
	    return 0;
    }
#if ! defined(no_probe_nonshared_memory)
    return el2_pio_probe(dev);
#else
    return -ENODEV;
#endif
}
Example #15
0
/*
 * Function irlan_eth_setup (dev)
 *
 *    The network device initialization function.
 *
 */
static void irlan_eth_setup(struct net_device *dev)
{
	dev->open               = irlan_eth_open;
	dev->stop               = irlan_eth_close;
	dev->hard_start_xmit    = irlan_eth_xmit; 
	dev->get_stats	        = irlan_eth_get_stats;
	dev->set_multicast_list = irlan_eth_set_multicast_list;
	dev->destructor		= free_netdev;

	SET_MODULE_OWNER(dev);

	ether_setup(dev);
	
	/* 
	 * Lets do all queueing in IrTTP instead of this device driver.
	 * Queueing here as well can introduce some strange latency
	 * problems, which we will avoid by setting the queue size to 0.
	 */
	/*
	 * The bugs in IrTTP and IrLAN that created this latency issue
	 * have now been fixed, and we can propagate flow control properly
	 * to the network layer. However, this requires a minimal queue of
	 * packets for the device.
	 * Without flow control, the Tx Queue is 14 (ttp) + 0 (dev) = 14
	 * With flow control, the Tx Queue is 7 (ttp) + 4 (dev) = 11
	 * See irlan_eth_flow_indication()...
	 * Note : this number was randomly selected and would need to
	 * be adjusted.
	 * Jean II */
	dev->tx_queue_len = 4;
}
static struct fritz_adapter * __devinit 
new_adapter(struct pci_dev *pdev)
{
	struct fritz_adapter *adapter;
	struct hisax_b_if *b_if[2];
	int i;

	adapter = kmalloc(sizeof(struct fritz_adapter), GFP_KERNEL);
	if (!adapter)
		return NULL;

	memset(adapter, 0, sizeof(struct fritz_adapter));

	SET_MODULE_OWNER(&adapter->isac.hisax_d_if);
	adapter->isac.hisax_d_if.ifc.priv = &adapter->isac;
	adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1;
	
	for (i = 0; i < 2; i++) {
		adapter->bcs[i].adapter = adapter;
		adapter->bcs[i].channel = i;
		adapter->bcs[i].b_if.ifc.priv = &adapter->bcs[i];
		adapter->bcs[i].b_if.ifc.l2l1 = fritz_b_l2l1;
	}

	pci_set_drvdata(pdev, adapter);

	for (i = 0; i < 2; i++)
		b_if[i] = &adapter->bcs[i].b_if;

	hisax_register(&adapter->isac.hisax_d_if, b_if, "fcpcipnp", protocol);

	return adapter;
}
Example #17
0
static void *rtl8150_probe(struct usb_device *udev, unsigned int ifnum,
			   const struct usb_device_id *id)
{
	rtl8150_t *dev;
	struct net_device *netdev;

	udev->config[0].bConfigurationValue = 1;
	if (usb_set_configuration(udev, udev->config[0].bConfigurationValue)) {
		err("usb_set_configuration() failed");
		return NULL;
	}
	dev = kmalloc(sizeof(rtl8150_t), GFP_KERNEL);
	if (!dev) {
		err("Out of memory");
		goto exit;
	} else
		memset(dev, 0, sizeof(rtl8150_t));

	netdev = init_etherdev(NULL, 0);
	if (!netdev) {
		kfree(dev);
		err("Oh boy, out of memory again?!?");
		dev = NULL;
		goto exit;
	}

	init_MUTEX(&dev->sem);
	dev->udev = udev;
	dev->netdev = netdev;
	SET_MODULE_OWNER(netdev);
	netdev->priv = dev;
	netdev->open = rtl8150_open;
	netdev->stop = rtl8150_close;
	netdev->do_ioctl = rtl8150_ioctl;
	netdev->watchdog_timeo = RTL8150_TX_TIMEOUT;
	netdev->tx_timeout = rtl8150_tx_timeout;
	netdev->hard_start_xmit = rtl8150_start_xmit;
	netdev->set_multicast_list = rtl8150_set_multicast;
	netdev->set_mac_address = rtl8150_set_mac_address;
	netdev->get_stats = rtl8150_netdev_stats;
	netdev->mtu = RTL8150_MTU;
	dev->intr_interval = 100;	/* 100ms */

	if (rtl8150_reset(dev) || !alloc_all_urbs(dev)) {
		err("couldn't reset the device");
		free_all_urbs(dev);
		unregister_netdev(dev->netdev);
		kfree(netdev);
		kfree(dev);
		dev = NULL;
		goto exit;
	}

	set_ethernet_addr(dev);
	/* let's not be very nasty :-) */
	info("%s: rtl8150 is detected", netdev->name);
exit:
	return dev;
}
Example #18
0
/** 
 * \fn     wlanDrvIf_SetupNetif
 * \brief  Setup driver network interface
 *
 * Called in driver creation process.
 * Setup driver network interface.
 *
 * \note
 * \param  drv - The driver object handle
 * \return 0 - OK, else - failure
 * \sa
 */
static int wlanDrvIf_SetupNetif (TWlanDrvIfObj *drv)
{
    struct net_device *dev;
    int res;

    /* Allocate network interface structure for the driver */
    dev = alloc_etherdev (0);
    if (dev == NULL)
    {
        ti_dprintf (TIWLAN_LOG_ERROR, "alloc_etherdev() failed\n");
        return -ENOMEM;
    }

    /* Setup the network interface */
    ether_setup (dev);

   NETDEV_SET_PRIVATE(dev,drv);
   drv->netdev = dev;
   strcpy (dev->name, TIWLAN_DRV_IF_NAME);
   netif_carrier_off (dev);
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
	dev->validate_addr = NULL;
#endif
    /* the following is required on at least BSP 23.8 and higher.
        Without it, the Open function of the driver will not be called
        when trying to 'ifconfig up' the interface */
    dev->open = wlanDrvIf_Open;
    dev->stop = wlanDrvIf_Release;
   dev->hard_start_xmit = wlanDrvIf_Xmit;
    dev->get_stats = wlanDrvIf_NetGetStat;
    dev->do_ioctl = NULL;
#else
   dev->netdev_ops = &tiwlan_ops_pri;
#endif
	dev->tx_queue_len = 100;

    /* Initialize Wireless Extensions interface (WEXT) */
    wlanDrvWext_Init (dev);

    res = register_netdev (dev);
    if (res != 0)
    {
        ti_dprintf (TIWLAN_LOG_ERROR, "register_netdev() failed : %d\n", res);
        kfree (dev);
        return res;
    }

   /* Setup power-management callbacks */
   hPlatform_SetupPm(SuspendCb, ResumeCb, pDrvStaticHandle);

    /*
    On the latest Kernel there is no more support for the below macro.
    */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
    SET_MODULE_OWNER (dev);
#endif
    return 0;
}
struct net_device *rtw_init_netdev(void)	
{
	_adapter *padapter;
	struct net_device *pnetdev;

	RT_TRACE(_module_os_intfs_c_,_drv_info_,("+init_net_dev\n"));

	//pnetdev = alloc_netdev(sizeof(_adapter), "wlan%d", ether_setup);
	pnetdev = alloc_etherdev(sizeof(_adapter));	
	if (!pnetdev)
	   return NULL;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
	SET_MODULE_OWNER(pnetdev);
#endif
	
	padapter = netdev_priv(pnetdev);
	_rtw_memset(padapter, 0,sizeof(_adapter));
	padapter->pnetdev = pnetdev;	
	
	//pnetdev->init = NULL;
#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29))

	printk("register rtl8192_netdev_ops to netdev_ops\n");
	pnetdev->netdev_ops = &rtw_netdev_ops;

#else
	pnetdev->open = netdev_open;
	pnetdev->stop = netdev_close;	
	
	pnetdev->hard_start_xmit = rtw_xmit_entry;

	pnetdev->set_mac_address = rtw_net_set_mac_address;
	pnetdev->get_stats = rtw_net_get_stats;

	pnetdev->do_ioctl = rtw_ioctl;

#endif


#ifdef CONFIG_RTL8712_TCP_CSUM_OFFLOAD_TX
	pnetdev->features |= NETIF_F_IP_CSUM;
#endif	
	//pnetdev->tx_timeout = NULL;
	pnetdev->watchdog_timeo = HZ; /* 1 second timeout */	
	
	pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def;  
	
#ifdef WIRELESS_SPY
	//priv->wireless_data.spy_data = &priv->spy_data;
	//pnetdev->wireless_data = &priv->wireless_data;
#endif

	//step 2.
   	loadparam(padapter, pnetdev);

	return pnetdev;

}
Example #20
0
static int __init eql_init(struct net_device *dev)
{
	static unsigned version_printed;
	/* static unsigned num_masters     = 0; */
	equalizer_t *eql = 0;

	SET_MODULE_OWNER(dev);

	if ( version_printed++ == 0 && eql_debug > 0)
		printk(version);
	/*
	 *	Initialize the device structure. 
	 */
	dev->priv = kmalloc (sizeof (equalizer_t), GFP_KERNEL);
	if (dev->priv == NULL)
		return -ENOMEM;
	memset (dev->priv, 0, sizeof (equalizer_t));
	eql = (equalizer_t *) dev->priv;

	eql->stats = kmalloc (sizeof (struct net_device_stats), GFP_KERNEL);
	if (eql->stats == NULL) 
	{
		kfree(dev->priv);
		dev->priv = NULL;
		return -ENOMEM;
	}
	memset (eql->stats, 0, sizeof (struct net_device_stats));

	init_timer (&eql->timer);
	eql->timer.data     	= (unsigned long) dev->priv;
	eql->timer.expires  	= jiffies+EQL_DEFAULT_RESCHED_IVAL;
	eql->timer.function 	= &eql_timer;
	eql->timer_on       	= 0;

	dev->open		= eql_open;
	dev->stop		= eql_close;
	dev->do_ioctl		= eql_ioctl;
	dev->hard_start_xmit	= eql_slave_xmit;
	dev->get_stats		= eql_get_stats;
  
  	/*
  	 *	Fill in the fields of the device structure with 
	 *	eql-generic values. 
	 */

	/*
	 *	Now we undo some of the things that eth_setup does
	 * 	that we don't like 
	 */
	 
	dev->mtu        	= EQL_DEFAULT_MTU;	/* set to 576 in eql.h */
	dev->flags      	= IFF_MASTER;

	dev->type       	= ARPHRD_SLIP;
	dev->tx_queue_len 	= 5;		/* Hands them off fast */

	return 0;
}
PNET_DEV RtmpPhyNetDevInit(
	IN RTMP_ADAPTER *pAd,
	IN RTMP_OS_NETDEV_OP_HOOK *pNetDevHook)
{
	struct net_device	*net_dev = NULL;
//	NDIS_STATUS		Status;
	
	net_dev = RtmpOSNetDevCreate(pAd, INT_MAIN, 0, sizeof(PRTMP_ADAPTER), INF_MAIN_DEV_NAME);
	if (net_dev == NULL)
	{
		printk("RtmpPhyNetDevInit(): creation failed for main physical net device!\n");
		return NULL;
	}

	NdisZeroMemory((unsigned char *)pNetDevHook, sizeof(RTMP_OS_NETDEV_OP_HOOK));
	pNetDevHook->open = MainVirtualIF_open;
	pNetDevHook->stop = MainVirtualIF_close;
	pNetDevHook->xmit = rt28xx_send_packets;
#ifdef IKANOS_VX_1X0
	pNetDevHook->xmit = IKANOS_DataFramesTx;
#endif // IKANOS_VX_1X0 //
	pNetDevHook->ioctl = rt28xx_ioctl;
	pNetDevHook->priv_flags = INT_MAIN;
	pNetDevHook->get_stats = RT28xx_get_ether_stats;

	pNetDevHook->needProtcted = FALSE;

#if (WIRELESS_EXT < 21) && (WIRELESS_EXT >= 12)
	pNetDevHook->get_wstats = rt28xx_get_wireless_stats;
#endif


#ifdef CONFIG_APSTA_MIXED_SUPPORT
#if WIRELESS_EXT >= 12
	if (pAd->OpMode == OPMODE_AP)
	{
		pNetDevHook->iw_handler = &rt28xx_ap_iw_handler_def;
	}
#endif //WIRELESS_EXT >= 12
#endif // CONFIG_APSTA_MIXED_SUPPORT //

	RTMP_OS_NETDEV_SET_PRIV(net_dev, pAd);
	pAd->net_dev = net_dev;
	
#ifdef CONFIG_AP_SUPPORT
	pAd->ApCfg.MBSSID[MAIN_MBSSID].MSSIDDev = net_dev;
#endif // CONFIG_AP_SUPPORT //


#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
	SET_MODULE_OWNER(net_dev);
#endif 

	netif_stop_queue(net_dev);

	return net_dev;
	
}
Example #22
0
static int fmvj18x_attach(struct pcmcia_device *p_dev)
{
    local_info_t *lp;
    dev_link_t *link;
    struct net_device *dev;

    DEBUG(0, "fmvj18x_attach()\n");

    /* Make up a FMVJ18x specific data structure */
    dev = alloc_etherdev(sizeof(local_info_t));
    if (!dev)
	return -ENOMEM;
    lp = netdev_priv(dev);
    link = &lp->link;
    link->priv = dev;

    /* The io structure describes IO port mapping */
    link->io.NumPorts1 = 32;
    link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
    link->io.IOAddrLines = 5;

    /* Interrupt setup */
    link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
    link->irq.IRQInfo1 = IRQ_LEVEL_ID;
    link->irq.Handler = &fjn_interrupt;
    link->irq.Instance = dev;

    /* General socket configuration */
    link->conf.Attributes = CONF_ENABLE_IRQ;
    link->conf.Vcc = 50;
    link->conf.IntType = INT_MEMORY_AND_IO;

    /* The FMVJ18x specific entries in the device structure. */
    SET_MODULE_OWNER(dev);
    dev->hard_start_xmit = &fjn_start_xmit;
    dev->set_config = &fjn_config;
    dev->get_stats = &fjn_get_stats;
    dev->set_multicast_list = &set_rx_mode;
    dev->open = &fjn_open;
    dev->stop = &fjn_close;
#ifdef HAVE_TX_TIMEOUT
    dev->tx_timeout = fjn_tx_timeout;
    dev->watchdog_timeo = TX_TIMEOUT;
#endif
    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);

    link->handle = p_dev;
    p_dev->instance = link;

    link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
    fmvj18x_config(link);

    return 0;
} /* fmvj18x_attach */
Example #23
0
static int nmclan_attach(struct pcmcia_device *p_dev)
{
    mace_private *lp;
    dev_link_t *link;
    struct net_device *dev;

    DEBUG(0, "nmclan_attach()\n");
    DEBUG(1, "%s\n", rcsid);

    /* Create new ethernet device */
    dev = alloc_etherdev(sizeof(mace_private));
    if (!dev)
	    return -ENOMEM;
    lp = netdev_priv(dev);
    link = &lp->link;
    link->priv = dev;
    
    spin_lock_init(&lp->bank_lock);
    link->io.NumPorts1 = 32;
    link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
    link->io.IOAddrLines = 5;
    link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
    link->irq.IRQInfo1 = IRQ_LEVEL_ID;
    link->irq.Handler = &mace_interrupt;
    link->irq.Instance = dev;
    link->conf.Attributes = CONF_ENABLE_IRQ;
    link->conf.Vcc = 50;
    link->conf.IntType = INT_MEMORY_AND_IO;
    link->conf.ConfigIndex = 1;
    link->conf.Present = PRESENT_OPTION;

    lp->tx_free_frames=AM2150_MAX_TX_FRAMES;

    SET_MODULE_OWNER(dev);
    dev->hard_start_xmit = &mace_start_xmit;
    dev->set_config = &mace_config;
    dev->get_stats = &mace_get_stats;
    dev->set_multicast_list = &set_multicast_list;
    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
    dev->open = &mace_open;
    dev->stop = &mace_close;
#ifdef HAVE_TX_TIMEOUT
    dev->tx_timeout = mace_tx_timeout;
    dev->watchdog_timeo = TX_TIMEOUT;
#endif

    link->handle = p_dev;
    p_dev->instance = link;

    link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
    nmclan_config(link);

    return 0;
} /* nmclan_attach */
Example #24
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);
}
Example #25
0
/**********************************************
 * probe the ni5210-card
 */
struct net_device * __init ni52_probe(int unit)
{
	struct net_device *dev = alloc_etherdev(sizeof(struct priv));
	static int ports[] = {0x300, 0x280, 0x360 , 0x320 , 0x340, 0};
	int *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;
		memstart = dev->mem_start;
		memend = dev->mem_end;
	}

	SET_MODULE_OWNER(dev);

	if (io > 0x1ff)	{	/* Check a single specified location. */
		err = ni52_probe1(dev, io);
	} else if (io > 0) {		/* Don't probe at all. */
		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:
	release_region(dev->base_addr, NI52_TOTAL_SIZE);
out:
	free_netdev(dev);
	return ERR_PTR(err);
}
/*
 * This is the real probe routine. 
 */
static int isl3893_probe1(struct net_device *dev, int ioaddr)
{
	static unsigned version_printed = 0;
	u_char ether_address[] = "\x00\x10\x91\x00\xed\xcb";
	int i;

	/* Allocate a new 'dev' if needed. */
	if (dev == NULL) {
		/*
		 * Don't allocate the private data here, it is done later
		 * This makes it easier to free the memory when this driver
		 * is used as a module.
		 */
		dev = init_etherdev(0, 0);
		if (dev == NULL)
			return -ENOMEM;
	}

	if (net_debug  &&  version_printed++ == 0)
		printk(KERN_DEBUG "%s", version);

	printk(KERN_INFO "%s: %s found, ", dev->name, cardname );

	/* Fill in the 'dev' fields. */
	if (dev->base_addr == 0)
		dev->base_addr = ioaddr;

	/* Retrieve and print the ethernet address. */
	for (i = 0; i < 6; i++)
		printk(" %2.2x", dev->dev_addr[i] = ether_address[i] );

	/* Initialize the device structure. */
	if (dev->priv == NULL) {
		dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
		if (dev->priv == NULL)
			return -ENOMEM;
	}
	memset(dev->priv, 0, sizeof(struct net_local));

	dev->open		= net_open;
	dev->stop		= net_close;
	dev->get_stats		= net_get_stats;
	dev->hard_start_xmit 	= net_send_packet;

	ether_setup(dev);

	SET_MODULE_OWNER(dev);

	return 0;
}
Example #27
0
File: faulty.c Project: crond/dd
int faulty_init(void)
{
    int result;

    /*
     * Register your major, and accept a dynamic number
     */
    SET_MODULE_OWNER(&faulty_fops);
    result = register_chrdev(faulty_major, "faulty", &faulty_fops);
    if (result < 0) return result;
    if (faulty_major == 0) faulty_major = result; /* dynamic */

    return 0;
}
Example #28
0
static int __init ipip_init(void)
{
	SET_MODULE_OWNER(&ipip_type);
	if (xfrm_register_type(&ipip_type, AF_INET) < 0) {
		printk(KERN_INFO "ipip init: can't add xfrm type\n");
		return -EAGAIN;
	}
	if (inet_add_protocol(&ipip_protocol, IPPROTO_IPIP) < 0) {
		printk(KERN_INFO "ipip init: can't add protocol\n");
		xfrm_unregister_type(&ipip_type, AF_INET);
		return -EAGAIN;
	}
	return 0;
}
Example #29
0
/* Initialize the rest of the device. */
int __init do_mambonet_probe(struct net_device *dev)
{
	struct netdev_private *priv;
	int devno = nextdevno++;
	int irq;

	printk("eth%d: bogus network driver initialization\n", devno);

	irq = mambonet_probedev(devno, dev->dev_addr);

	if (irq < 0) {
		printk("No IRQ retreived\n");
		return (-ENODEV);
	}

	printk("%s: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", dev->name,
	       dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
	       dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);

	SET_MODULE_OWNER(dev);

	dev->irq = irq;
	dev->mtu = MAMBO_MTU;
	dev->open = mambonet_open;
	dev->poll = mambonet_poll;
	dev->weight = 16;
	dev->stop = mambonet_close;
	dev->hard_start_xmit = mambonet_start_xmit;
	dev->get_stats = mambonet_get_stats;
	dev->set_mac_address = mambonet_set_mac_address;
	dev->do_ioctl = mambonet_ioctl;

	dev->priv = kmalloc(sizeof(struct netdev_private), GFP_KERNEL);
	if (dev->priv == NULL)
		return -ENOMEM;
	memset(dev->priv, 0, sizeof(struct netdev_private));

	priv = dev->priv;
	priv->devno = devno;
	priv->closing = 0;
	dev->get_stats = get_stats;

	if (dev->irq == 0) {
		INIT_BOTTOM_HALF(&priv->poll_task, (void *)mambonet_timer,
				 (void *)dev);
	}

	return (0);
};
Example #30
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);
}