/* Index into the array of possible ethtool * ops to catch all 4 possibilities */ if((priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) == 0) dev_ethtool_ops += 1;  if((priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE) == 0) dev_ethtool_ops += 2;  dev->ethtool_ops = gfar_op_array[dev_ethtool_ops]; 
dev->ethtool_ops = &gfar_ethtool_ops;  if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { priv->rx_csum_enable = 1; dev->features |= NETIF_F_IP_CSUM; } else priv->rx_csum_enable = 0;  priv->vlgrp = NULL;  if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_VLAN) { dev->vlan_rx_register = gfar_vlan_rx_register; dev->vlan_rx_kill_vid = gfar_vlan_rx_kill_vid;  dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;  priv->vlan_enable = 1; }  if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_EXTENDED_HASH) { priv->extended_hash = 1; priv->hash_width = 9;  priv->hash_regs[0] = &priv->regs->igaddr0; priv->hash_regs[1] = &priv->regs->igaddr1; priv->hash_regs[2] = &priv->regs->igaddr2; priv->hash_regs[3] = &priv->regs->igaddr3; priv->hash_regs[4] = &priv->regs->igaddr4; priv->hash_regs[5] = &priv->regs->igaddr5; priv->hash_regs[6] = &priv->regs->igaddr6; priv->hash_regs[7] = &priv->regs->igaddr7; priv->hash_regs[8] = &priv->regs->gaddr0; priv->hash_regs[9] = &priv->regs->gaddr1; priv->hash_regs[10] = &priv->regs->gaddr2; priv->hash_regs[11] = &priv->regs->gaddr3; priv->hash_regs[12] = &priv->regs->gaddr4; priv->hash_regs[13] = &priv->regs->gaddr5; priv->hash_regs[14] = &priv->regs->gaddr6; priv->hash_regs[15] = &priv->regs->gaddr7;  } else { priv->extended_hash = 0; priv->hash_width = 8;  priv->hash_regs[0] = &priv->regs->gaddr0; priv->hash_regs[1] = &priv->regs->gaddr1; priv->hash_regs[2] = &priv->regs->gaddr2; priv->hash_regs[3] = &priv->regs->gaddr3; priv->hash_regs[4] = &priv->regs->gaddr4; priv->hash_regs[5] = &priv->regs->gaddr5; priv->hash_regs[6] = &priv->regs->gaddr6; priv->hash_regs[7] = &priv->regs->gaddr7; }  if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_PADDING) priv->padding = DEFAULT_PADDING; else priv->padding = 0;  dev->hard_header_len += priv->padding;  if (dev->features & NETIF_F_IP_CSUM) dev->hard_header_len += GMAC_FCB_LEN; 
static int gfar_probe(struct device *device){	u32 tempval;	struct net_device *dev = NULL;	struct gfar_private *priv = NULL;	struct platform_device *pdev = to_platform_device(device);	struct gianfar_platform_data *einfo;	struct resource *r;	int idx;	int err = 0;	int dev_ethtool_ops = 0;	einfo = (struct gianfar_platform_data *) pdev->dev.platform_data;	if (einfo == NULL) {		printk(KERN_ERR "gfar %d: Missing additional data!\n",		       pdev->id);		return -ENODEV;	}	/* Create an ethernet device instance */	dev = alloc_etherdev(sizeof (*priv));	if (dev == NULL)		return -ENOMEM;	priv = netdev_priv(dev);	/* Set the info in the priv to the current info */	priv->einfo = einfo;	/* fill out IRQ fields */	if (einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {		priv->interruptTransmit = platform_get_irq_byname(pdev, "tx");		priv->interruptReceive = platform_get_irq_byname(pdev, "rx");		priv->interruptError = platform_get_irq_byname(pdev, "error");	} else {		priv->interruptTransmit = platform_get_irq(pdev, 0);	}	/* get a pointer to the register memory */	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);	priv->regs = (struct gfar *)		ioremap(r->start, sizeof (struct gfar));	if (priv->regs == NULL) {		err = -ENOMEM;		goto regs_fail;	}	/* Set the PHY base address */	priv->phyregs = (struct gfar *)	    ioremap(einfo->phy_reg_addr, sizeof (struct gfar));	if (priv->phyregs == NULL) {		err = -ENOMEM;		goto phy_regs_fail;	}	spin_lock_init(&priv->lock);	dev_set_drvdata(device, dev);	/* Stop the DMA engine now, in case it was running before */	/* (The firmware could have used it, and left it running). */	/* To do this, we write Graceful Receive Stop and Graceful */	/* Transmit Stop, and then wait until the corresponding bits */	/* in IEVENT indicate the stops have completed. */	tempval = gfar_read(&priv->regs->dmactrl);	tempval &= ~(DMACTRL_GRS | DMACTRL_GTS);	gfar_write(&priv->regs->dmactrl, tempval);	tempval = gfar_read(&priv->regs->dmactrl);	tempval |= (DMACTRL_GRS | DMACTRL_GTS);	gfar_write(&priv->regs->dmactrl, tempval);	while (!(gfar_read(&priv->regs->ievent) & (IEVENT_GRSC | IEVENT_GTSC)))		cpu_relax();	/* Reset MAC layer */	gfar_write(&priv->regs->maccfg1, MACCFG1_SOFT_RESET);	tempval = (MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);	gfar_write(&priv->regs->maccfg1, tempval);	/* Initialize MACCFG2. */	gfar_write(&priv->regs->maccfg2, MACCFG2_INIT_SETTINGS);	/* Initialize ECNTRL */	gfar_write(&priv->regs->ecntrl, ECNTRL_INIT_SETTINGS);	/* Copy the station address into the dev structure, */	memcpy(dev->dev_addr, einfo->mac_addr, MAC_ADDR_LEN);	/* Set the dev->base_addr to the gfar reg region */	dev->base_addr = (unsigned long) (priv->regs);	SET_MODULE_OWNER(dev);	SET_NETDEV_DEV(dev, device);	/* Fill in the dev structure */	dev->open = gfar_enet_open;	dev->hard_start_xmit = gfar_start_xmit;	dev->tx_timeout = gfar_timeout;	dev->watchdog_timeo = TX_TIMEOUT;#ifdef CONFIG_GFAR_NAPI	dev->poll = gfar_poll;	dev->weight = GFAR_DEV_WEIGHT;#endif	dev->stop = gfar_close;	dev->get_stats = gfar_get_stats;	dev->change_mtu = gfar_change_mtu;	dev->mtu = 1500;	dev->set_multicast_list = gfar_set_multi;	/* Index into the array of possible ethtool	 * ops to catch all 4 possibilities */	if((priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) == 0)		dev_ethtool_ops += 1;	if((priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE) == 0)		dev_ethtool_ops += 2;	dev->ethtool_ops = gfar_op_array[dev_ethtool_ops];	priv->rx_buffer_size = DEFAULT_RX_BUFFER_SIZE;#ifdef CONFIG_GFAR_BUFSTASH	priv->rx_stash_size = STASH_LENGTH;#endif	priv->tx_ring_size = DEFAULT_TX_RING_SIZE;	priv->rx_ring_size = DEFAULT_RX_RING_SIZE;	priv->txcoalescing = DEFAULT_TX_COALESCE;	priv->txcount = DEFAULT_TXCOUNT;	priv->txtime = DEFAULT_TXTIME;	priv->rxcoalescing = DEFAULT_RX_COALESCE;	priv->rxcount = DEFAULT_RXCOUNT;	priv->rxtime = DEFAULT_RXTIME;	err = register_netdev(dev);	if (err) {		printk(KERN_ERR "%s: Cannot register net device, aborting.\n",				dev->name);		goto register_fail;	}	/* Print out the device info */	printk(KERN_INFO DEVICE_NAME, dev->name);	for (idx = 0; idx < 6; idx++)		printk("%2.2x%c", dev->dev_addr[idx], idx == 5 ? ' ' : ':');	printk("\n");	/* Even more device info helps when determining which kernel */	/* provided which set of benchmarks.  Since this is global for all */	/* devices, we only print it once */#ifdef CONFIG_GFAR_NAPI	printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name);#else	printk(KERN_INFO "%s: Running with NAPI disabled\n", dev->name);#endif	printk(KERN_INFO "%s: %d/%d RX/TX BD ring size\n",	       dev->name, priv->rx_ring_size, priv->tx_ring_size);	return 0;register_fail:	iounmap((void *) priv->phyregs);phy_regs_fail:	iounmap((void *) priv->regs);regs_fail:	free_netdev(dev);	return -ENOMEM;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/0bbaf069f053957e8d733784e18a2992afd1dd3c/gianfar.c/buggy/drivers/net/gianfar.c