コード例 #1
0
int
san_dev_attach(void *hw, u_int8_t *devname, int namelen)
{
	sdla_t			*card;
	wanpipe_common_t	*common = NULL;
	int			err = 0;

	card=malloc(sizeof(sdla_t), M_DEVBUF, M_NOWAIT);
	if (!card) {
		log(LOG_INFO, "%s: Failed allocate new card!\n",
				san_drvname);
		return (EINVAL);
	}
	bzero(card, sizeof(sdla_t));
	card->magic = WANPIPE_MAGIC;
	wanpipe_generic_name(card, card->devname, sizeof(card->devname));
	strlcpy(devname, card->devname, namelen);
	card->hw = hw;
	LIST_INIT(&card->dev_head);

	sdla_getcfg(card->hw, SDLA_CARDTYPE, &card->type);
	if (sdla_is_te1(card->hw))
		sdla_te_defcfg(&card->fe_te.te_cfg);

	err = sdla_setup(card->hw);
	if (err) {
		log(LOG_INFO, "%s: Hardware setup Failed %d\n",
			card->devname,err);
		return (EINVAL);
	}
	err = sdla_intr_establish(card->hw, sdla_isr, (void*)card);
	if (err) {
		log(LOG_INFO, "%s: Failed set interrupt handler!\n",
					card->devname);
		sdla_down(card->hw);
		return (EINVAL);
	}

	switch (card->type) {
	case SDLA_AFT:
#if defined(DEBUG_INIT)
		log(LOG_INFO, "%s: Starting AFT Hardware Init.\n",
				card->devname);
#endif
		common = wan_xilinx_init(card);
		break;
	}
	if (common == NULL) {
		release_hw(card);
		card->configured = 0;
		return (EINVAL);
	}
	LIST_INSERT_HEAD(&card->dev_head, common, next);

	/* Reserve I/O region and schedule background task */
	card->critical	= 0;
	card->state	= WAN_DISCONNECTED;
	card->ioctl	= wan_ioctl;
	return (0);
}
コード例 #2
0
ファイル: dev.c プロジェクト: 0xffea/gnumach
int net_dev_init(void)
{
	struct device *dev, **dp;

	/*
	 *	Initialise the packet receive queue.
	 */

#ifndef MACH
	skb_queue_head_init(&backlog);
#endif
	
	/*
	 *	The bridge has to be up before the devices
	 */

#ifdef CONFIG_BRIDGE	 
	br_init();
#endif	
	
	/*
	 * This is Very Ugly(tm).
	 *
	 * Some devices want to be initialized early..
	 */
#if defined(CONFIG_PI)
	pi_init();
#endif	
#if defined(CONFIG_PT)
	pt_init();
#endif
#if defined(CONFIG_DLCI)
	dlci_setup();
#endif
#if defined(CONFIG_SDLA)
	sdla_setup();
#endif
	/*
	 *	SLHC if present needs attaching so other people see it
	 *	even if not opened.
	 */
#if (defined(CONFIG_SLIP) && defined(CONFIG_SLIP_COMPRESSED)) \
	 || defined(CONFIG_PPP) \
    || (defined(CONFIG_ISDN) && defined(CONFIG_ISDN_PPP))
	slhc_install();
#endif	

	/*
	 *	Add the devices.
	 *	If the call to dev->init fails, the dev is removed
	 *	from the chain disconnecting the device until the
	 *	next reboot.
	 */

	dp = &dev_base;
	while ((dev = *dp) != NULL)
	{
		int i;
		for (i = 0; i < DEV_NUMBUFFS; i++)  {
			skb_queue_head_init(dev->buffs + i);
		}

		if (dev->init && dev->init(dev)) 
		{
			/*
			 *	It failed to come up. Unhook it.
			 */
			*dp = dev->next;
		} 
		else
		{
			dp = &dev->next;
		}
	}

#ifdef CONFIG_PROC_FS
	proc_net_register(&(struct proc_dir_entry) {
		PROC_NET_DEV, 3, "dev",
		S_IFREG | S_IRUGO, 1, 0, 0,
		0, &proc_net_inode_operations,
		dev_get_info
	});