base = 0; 
base = NULL; 
static int cas_get_vpd_info(struct cas *cp, unsigned char *dev_addr,			    const int offset){	void __iomem *p = cp->regs + REG_EXPANSION_ROM_RUN_START;	void __iomem *base, *kstart;	int i, len;	int found = 0;#define VPD_FOUND_MAC        0x01#define VPD_FOUND_PHY        0x02	int phy_type = CAS_PHY_MII_MDIO0; /* default phy type */	int mac_off  = 0;	/* give us access to the PROM */	writel(BIM_LOCAL_DEV_PROM | BIM_LOCAL_DEV_PAD,	       cp->regs + REG_BIM_LOCAL_DEV_EN);	/* check for an expansion rom */	if (readb(p) != 0x55 || readb(p + 1) != 0xaa)		goto use_random_mac_addr;	/* search for beginning of vpd */	base = 0;	for (i = 2; i < EXPANSION_ROM_SIZE; i++) {		/* check for PCIR */		if ((readb(p + i + 0) == 0x50) &&		    (readb(p + i + 1) == 0x43) &&		    (readb(p + i + 2) == 0x49) &&		    (readb(p + i + 3) == 0x52)) {			base = p + (readb(p + i + 8) | 				    (readb(p + i + 9) << 8));			break;		}			}	if (!base || (readb(base) != 0x82))		goto use_random_mac_addr;		i = (readb(base + 1) | (readb(base + 2) << 8)) + 3;	while (i < EXPANSION_ROM_SIZE) {		if (readb(base + i) != 0x90) /* no vpd found */			goto use_random_mac_addr;		/* found a vpd field */		len = readb(base + i + 1) | (readb(base + i + 2) << 8);		/* extract keywords */		kstart = base + i + 3;		p = kstart;		while ((p - kstart) < len) {			int klen = readb(p + 2);			int j;			char type;			p += 3;						/* look for the following things:			 * -- correct length == 29			 * 3 (type) + 2 (size) + 			 * 18 (strlen("local-mac-address") + 1) + 			 * 6 (mac addr) 			 * -- VPD Instance 'I'			 * -- VPD Type Bytes 'B'			 * -- VPD data length == 6			 * -- property string == local-mac-address			 * 			 * -- correct length == 24			 * 3 (type) + 2 (size) + 			 * 12 (strlen("entropy-dev") + 1) + 			 * 7 (strlen("vms110") + 1)			 * -- VPD Instance 'I'			 * -- VPD Type String 'B'			 * -- VPD data length == 7			 * -- property string == entropy-dev			 *			 * -- correct length == 18			 * 3 (type) + 2 (size) + 			 * 9 (strlen("phy-type") + 1) + 			 * 4 (strlen("pcs") + 1)			 * -- VPD Instance 'I'			 * -- VPD Type String 'S'			 * -- VPD data length == 4			 * -- property string == phy-type			 * 			 * -- correct length == 23			 * 3 (type) + 2 (size) + 			 * 14 (strlen("phy-interface") + 1) + 			 * 4 (strlen("pcs") + 1)			 * -- VPD Instance 'I'			 * -- VPD Type String 'S'			 * -- VPD data length == 4			 * -- property string == phy-interface			 */			if (readb(p) != 'I')				goto next;			/* finally, check string and length */			type = readb(p + 3);			if (type == 'B') {				if ((klen == 29) && readb(p + 4) == 6 &&				    cas_vpd_match(p + 5, 						  "local-mac-address")) {					if (mac_off++ > offset) 						goto next;					/* set mac address */					for (j = 0; j < 6; j++) 						dev_addr[j] = 							readb(p + 23 + j);					goto found_mac;				}			}			if (type != 'S')				goto next;#ifdef USE_ENTROPY_DEV			if ((klen == 24) && 			    cas_vpd_match(p + 5, "entropy-dev") &&			    cas_vpd_match(p + 17, "vms110")) {				cp->cas_flags |= CAS_FLAG_ENTROPY_DEV;				goto next;			}#endif			if (found & VPD_FOUND_PHY)				goto next;			if ((klen == 18) && readb(p + 4) == 4 &&			    cas_vpd_match(p + 5, "phy-type")) {				if (cas_vpd_match(p + 14, "pcs")) {					phy_type = CAS_PHY_SERDES;					goto found_phy;				}			}						if ((klen == 23) && readb(p + 4) == 4 &&			    cas_vpd_match(p + 5, "phy-interface")) {				if (cas_vpd_match(p + 19, "pcs")) {					phy_type = CAS_PHY_SERDES;					goto found_phy;				}			}found_mac:			found |= VPD_FOUND_MAC;			goto next;found_phy:			found |= VPD_FOUND_PHY;next:			p += klen;		}		i += len + 3;	}use_random_mac_addr:	if (found & VPD_FOUND_MAC)		goto done;	/* Sun MAC prefix then 3 random bytes. */	printk(PFX "MAC address not found in ROM VPD\n");	dev_addr[0] = 0x08;	dev_addr[1] = 0x00;	dev_addr[2] = 0x20;	get_random_bytes(dev_addr + 3, 3);done:	writel(0, cp->regs + REG_BIM_LOCAL_DEV_EN);	return phy_type;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/a4199b0b9aa540a27935251de788cd0f5f5a87aa/cassini.c/buggy/drivers/net/cassini.c