pPage1->RequestedParameters = le32_to_cpu(val); 
pPage1->RequestedParameters = cpu_to_le32(val); 
mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage){	VirtDevice		*pTarget;	SCSIDevicePage0_t	*pPage0;	SCSIDevicePage1_t	*pPage1;	int			val = 0, data, configuration;	u8			width = 0;	u8			offset = 0;	u8			factor = 0;	u8			negoFlags = 0;	u8			cmd = dv->cmd;	u8			id = dv->id;	switch (cmd) {	case MPT_GET_NVRAM_VALS:		ddvprintk((MYIOC_s_NOTE_FMT "Getting NVRAM: ",							 hd->ioc->name));		/* Get the NVRAM values and save in tmax		 * If not an LVD bus, the adapter minSyncFactor has been		 * already throttled back.		 */		if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume) {			width = pTarget->maxWidth;			offset = pTarget->maxOffset;			factor = pTarget->minSyncFactor;			negoFlags = pTarget->negoFlags;		} else {			if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {				data = hd->ioc->spi_data.nvram[id];				width = data & MPT_NVRAM_WIDE_DISABLE ? 0 : 1;				if ((offset = hd->ioc->spi_data.maxSyncOffset) == 0)					factor = MPT_ASYNC;				else {					factor = (data & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT;					if ((factor == 0) || (factor == MPT_ASYNC)){						factor = MPT_ASYNC;						offset = 0;					}				}			} else {				width = MPT_NARROW;				offset = 0;				factor = MPT_ASYNC;			}			/* Set the negotiation flags */			negoFlags = hd->ioc->spi_data.noQas;			if (!width)				negoFlags |= MPT_TARGET_NO_NEGO_WIDE;			if (!offset)				negoFlags |= MPT_TARGET_NO_NEGO_SYNC;		}		/* limit by adapter capabilities */		width = min(width, hd->ioc->spi_data.maxBusWidth);		offset = min(offset, hd->ioc->spi_data.maxSyncOffset);		factor = max(factor, hd->ioc->spi_data.minSyncFactor);		/* Check Consistency */		if (offset && (factor < MPT_ULTRA2) && !width)			factor = MPT_ULTRA2;		dv->max.width = width;		dv->max.offset = offset;		dv->max.factor = factor;		dv->max.flags = negoFlags;		ddvprintk((" id=%d width=%d factor=%x offset=%x flags=%x\n",				id, width, factor, offset, negoFlags));		break;	case MPT_UPDATE_MAX:		ddvprintk((MYIOC_s_NOTE_FMT			"Updating with SDP0 Data: ", hd->ioc->name));		/* Update tmax values with those from Device Page 0.*/		pPage0 = (SCSIDevicePage0_t *) pPage;		if (pPage0) {			val = cpu_to_le32(pPage0->NegotiatedParameters);			dv->max.width = val & MPI_SCSIDEVPAGE0_NP_WIDE ? 1 : 0;			dv->max.offset = (val&MPI_SCSIDEVPAGE0_NP_NEG_SYNC_OFFSET_MASK) >> 16;			dv->max.factor = (val&MPI_SCSIDEVPAGE0_NP_NEG_SYNC_PERIOD_MASK) >> 8;		}		dv->now.width = dv->max.width;		dv->now.offset = dv->max.offset;		dv->now.factor = dv->max.factor;		ddvprintk(("id=%d width=%d factor=%x offset=%x flags=%x\n",				id, dv->now.width, dv->now.factor, dv->now.offset, dv->now.flags));		break;	case MPT_SET_MAX:		ddvprintk((MYIOC_s_NOTE_FMT "Setting Max: ",								hd->ioc->name));		/* Set current to the max values. Update the config page.*/		dv->now.width = dv->max.width;		dv->now.offset = dv->max.offset;		dv->now.factor = dv->max.factor;		dv->now.flags = dv->max.flags;		pPage1 = (SCSIDevicePage1_t *)pPage;		if (pPage1) {			mptscsih_setDevicePage1Flags (dv->now.width, dv->now.factor,				dv->now.offset, &val, &configuration, dv->now.flags);			dnegoprintk(("Setting Max: id=%d width=%d factor=%x offset=%x negoFlags=%x request=%x config=%x\n",				id, dv->now.width, dv->now.factor, dv->now.offset, dv->now.flags, val, configuration));			pPage1->RequestedParameters = le32_to_cpu(val);			pPage1->Reserved = 0;			pPage1->Configuration = le32_to_cpu(configuration);		}		ddvprintk(("id=%d width=%d factor=%x offset=%x flags=%x request=%x configuration=%x\n",				id, dv->now.width, dv->now.factor, dv->now.offset, dv->now.flags, val, configuration));		break;	case MPT_SET_MIN:		ddvprintk((MYIOC_s_NOTE_FMT "Setting Min: ",								hd->ioc->name));		/* Set page to asynchronous and narrow		 * Do not update now, breaks fallback routine. */		width = MPT_NARROW;		offset = 0;		factor = MPT_ASYNC;		negoFlags = dv->max.flags;		pPage1 = (SCSIDevicePage1_t *)pPage;		if (pPage1) {			mptscsih_setDevicePage1Flags (width, factor,				offset, &val, &configuration, negoFlags);			dnegoprintk(("Setting Min: id=%d width=%d factor=%x offset=%x negoFlags=%x request=%x config=%x\n",				id, width, factor, offset, negoFlags, val, configuration));			pPage1->RequestedParameters = le32_to_cpu(val);			pPage1->Reserved = 0;			pPage1->Configuration = le32_to_cpu(configuration);		}		ddvprintk(("id=%d width=%d factor=%x offset=%x request=%x config=%x negoFlags=%x\n",				id, width, factor, offset, val, configuration, negoFlags));		break;	case MPT_FALLBACK:		ddvprintk((MYIOC_s_NOTE_FMT			"Fallback: Start: offset %d, factor %x, width %d \n",				hd->ioc->name, dv->now.offset,				dv->now.factor, dv->now.width));		width = dv->now.width;		offset = dv->now.offset;		factor = dv->now.factor;		if ((offset) && (dv->max.width)) {			if (factor < MPT_ULTRA160)				factor = MPT_ULTRA160;			else if (factor < MPT_ULTRA2) {				factor = MPT_ULTRA2;				width = MPT_WIDE;			} else if ((factor == MPT_ULTRA2) && width) {				factor = MPT_ULTRA2;				width = MPT_NARROW;			} else if (factor < MPT_ULTRA) {				factor = MPT_ULTRA;				width = MPT_WIDE;			} else if ((factor == MPT_ULTRA) && width) {				width = MPT_NARROW;			} else if (factor < MPT_FAST) {				factor = MPT_FAST;				width = MPT_WIDE;			} else if ((factor == MPT_FAST) && width) {				factor = MPT_FAST;				width = MPT_NARROW;			} else if (factor < MPT_SCSI) {				factor = MPT_SCSI;				width = MPT_WIDE;			} else if ((factor == MPT_SCSI) && width) {				factor = MPT_SCSI;				width = MPT_NARROW;			} else {				factor = MPT_ASYNC;				offset = 0;			}		} else if (offset) {			width = MPT_NARROW;			if (factor < MPT_ULTRA)				factor = MPT_ULTRA;			else if (factor < MPT_FAST)				factor = MPT_FAST;			else if (factor < MPT_SCSI)				factor = MPT_SCSI;			else {				factor = MPT_ASYNC;				offset = 0;			}		} else {			width = MPT_NARROW;			factor = MPT_ASYNC;		}		dv->max.flags |= MPT_TARGET_NO_NEGO_QAS;		dv->max.flags &= ~MPT_TAPE_NEGO_IDP;		dv->now.width = width;		dv->now.offset = offset;		dv->now.factor = factor;		dv->now.flags = dv->max.flags;		pPage1 = (SCSIDevicePage1_t *)pPage;		if (pPage1) {			mptscsih_setDevicePage1Flags (width, factor, offset, &val,						&configuration, dv->now.flags);			dnegoprintk(("Finish: id=%d width=%d offset=%d factor=%x flags=%x request=%x config=%x\n",			     id, width, offset, factor, dv->now.flags, val, configuration));			pPage1->RequestedParameters = le32_to_cpu(val);			pPage1->Reserved = 0;			pPage1->Configuration = le32_to_cpu(configuration);		}		ddvprintk(("Finish: id=%d offset=%d factor=%x width=%d request=%x config=%x\n",			     id, dv->now.offset, dv->now.factor, dv->now.width, val, configuration));		break;	case MPT_SAVE:		ddvprintk((MYIOC_s_NOTE_FMT			"Saving to Target structure: ", hd->ioc->name));		ddvprintk(("id=%d width=%x factor=%x offset=%d flags=%x\n",			     id, dv->now.width, dv->now.factor, dv->now.offset, dv->now.flags));		/* Save these values to target structures		 * or overwrite nvram (phys disks only).		 */		if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume ) {			pTarget->maxWidth = dv->now.width;			pTarget->maxOffset = dv->now.offset;			pTarget->minSyncFactor = dv->now.factor;			pTarget->negoFlags = dv->now.flags;		} else {			/* Preserv all flags, use			 * read-modify-write algorithm			 */			if (hd->ioc->spi_data.nvram) {				data = hd->ioc->spi_data.nvram[id];				if (dv->now.width)					data &= ~MPT_NVRAM_WIDE_DISABLE;				else					data |= MPT_NVRAM_WIDE_DISABLE;				if (!dv->now.offset)					factor = MPT_ASYNC;				data &= ~MPT_NVRAM_SYNC_MASK;				data |= (dv->now.factor << MPT_NVRAM_SYNC_SHIFT) & MPT_NVRAM_SYNC_MASK;				hd->ioc->spi_data.nvram[id] = data;			}		}		break;	}}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/637fa99b86a00a0b5767a982b83a512ff48ad6d2/mptscsih.c/buggy/drivers/message/fusion/mptscsih.c