 /* bjd: it seems that if we do this, we can end up * detecting 16bit flashes as an 8bit device, even though * there aren't. */ if (finfo->dev_id > 0xff) { DEBUG( MTD_DEBUG_LEVEL3, "%s(): ID is not 8bit\n", __func__); goto match_done; } 
static inline int jedec_match( __u32 base,			       struct map_info *map,			       struct cfi_private *cfi,			       const struct amd_flash_info *finfo ){	int rc = 0;           /* failure until all tests pass */	u32 mfr, id;	__u8 uaddr;	/*	 * The IDs must match.  For X16 and X32 devices operating in	 * a lower width ( X8 or X16 ), the device ID's are usually just	 * the lower byte(s) of the larger device ID for wider mode.  If	 * a part is found that doesn't fit this assumption (device id for	 * smaller width mode is completely unrealated to full-width mode)	 * then the jedec_table[] will have to be augmented with the IDs	 * for different widths.	 */	switch (cfi->device_type) {	case CFI_DEVICETYPE_X8:		mfr = (__u8)finfo->mfr_id;		id = (__u8)finfo->dev_id;		break;	case CFI_DEVICETYPE_X16:		mfr = (__u16)finfo->mfr_id;		id = (__u16)finfo->dev_id;		break;	case CFI_DEVICETYPE_X32:		mfr = (__u16)finfo->mfr_id;		id = (__u32)finfo->dev_id;		break;	default:		printk(KERN_WARNING		       "MTD %s(): Unsupported device type %d\n",		       __func__, cfi->device_type);		goto match_done;	}	if ( cfi->mfr != mfr || cfi->id != id ) {		goto match_done;	}	/* the part size must fit in the memory window */	DEBUG( MTD_DEBUG_LEVEL3,	       "MTD %s(): Check fit 0x%.8x + 0x%.8x = 0x%.8x\n",	       __func__, base, 1 << finfo->DevSize, base + (1 << finfo->DevSize) );	if ( base + cfi_interleave(cfi) * ( 1 << finfo->DevSize ) > map->size ) {		DEBUG( MTD_DEBUG_LEVEL3,		       "MTD %s(): 0x%.4x 0x%.4x %dKiB doesn't fit\n",		       __func__, finfo->mfr_id, finfo->dev_id,		       1 << finfo->DevSize );		goto match_done;	}	uaddr = finfo_uaddr(finfo, cfi->device_type);	if ( uaddr == MTD_UADDR_NOT_SUPPORTED ) {		goto match_done;	}	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): check unlock addrs 0x%.4x 0x%.4x\n",	       __func__, cfi->addr_unlock1, cfi->addr_unlock2 );	if ( MTD_UADDR_UNNECESSARY != uaddr && MTD_UADDR_DONT_CARE != uaddr	     && ( unlock_addrs[uaddr].addr1 != cfi->addr_unlock1 ||		  unlock_addrs[uaddr].addr2 != cfi->addr_unlock2 ) ) {		DEBUG( MTD_DEBUG_LEVEL3,			"MTD %s(): 0x%.4x 0x%.4x did not match\n",			__func__,			unlock_addrs[uaddr].addr1,			unlock_addrs[uaddr].addr2);		goto match_done;	}	/*	 * Make sure the ID's dissappear when the device is taken out of	 * ID mode.  The only time this should fail when it should succeed	 * is when the ID's are written as data to the same	 * addresses.  For this rare and unfortunate case the chip	 * cannot be probed correctly.	 * FIXME - write a driver that takes all of the chip info as	 * module parameters, doesn't probe but forces a load.	 */	DEBUG( MTD_DEBUG_LEVEL3,	       "MTD %s(): check ID's disappear when not in ID mode\n",	       __func__ );	jedec_reset( base, map, cfi );	mfr = jedec_read_mfr( map, base, cfi );	id = jedec_read_id( map, base, cfi );	if ( mfr == cfi->mfr && id == cfi->id ) {		DEBUG( MTD_DEBUG_LEVEL3,		       "MTD %s(): ID 0x%.2x:0x%.2x did not change after reset:\n"		       "You might need to manually specify JEDEC parameters.\n",			__func__, cfi->mfr, cfi->id );		goto match_done;	}	/* all tests passed - mark  as success */	rc = 1;	/*	 * Put the device back in ID mode - only need to do this if we	 * were truly frobbing a real device.	 */	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): return to ID mode\n", __func__ );	if(cfi->addr_unlock1) {		cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);		cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, cfi->device_type, NULL);	}	cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);	/* FIXME - should have a delay before continuing */ match_done:		return rc;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/011b2a36278cca110c70506ad85b042c2faabac2/jedec_probe.c/buggy/drivers/mtd/chips/jedec_probe.c