pcfg1Data->Configuration = le32_to_cpu(configuration); 
pcfg1Data->Configuration = cpu_to_le32(configuration); 
mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum){	MPT_ADAPTER		*ioc= hd->ioc;	VirtDevice		*pTarget;	SCSIDevicePage1_t	*pcfg1Data = NULL;	INTERNAL_CMD		 iocmd;	CONFIGPARMS		 cfg;	dma_addr_t		 cfg1_dma_addr = -1;	ConfigPageHeader_t	 header1;	int			 bus = 0;	int			 id = 0;	int			 lun;	int			 indexed_lun, lun_index;	int			 hostId = ioc->pfacts[portnum].PortSCSIID;	int			 max_id;	int			 requested, configuration, data;	int			 doConfig = 0;	u8			 flags, factor;	max_id = ioc->sh->max_id - 1;	/* Following parameters will not change	 * in this routine.	 */	iocmd.cmd = SYNCHRONIZE_CACHE;	iocmd.flags = 0;	iocmd.physDiskNum = -1;	iocmd.data = NULL;	iocmd.data_dma = -1;	iocmd.size = 0;	iocmd.rsvd = iocmd.rsvd2 = 0;	/* No SCSI hosts	 */	if (hd->Targets == NULL)		return 0;	/* Skip the host	 */	if (id == hostId)		id++;	/* Write SDP1 for all SCSI devices	 * Alloc memory and set up config buffer	 */	if (ioc->bus_type == SCSI) {		if (ioc->spi_data.sdp1length > 0) {			pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev,					 ioc->spi_data.sdp1length * 4, &cfg1_dma_addr);			if (pcfg1Data != NULL) {				doConfig = 1;				header1.PageVersion = ioc->spi_data.sdp1version;				header1.PageLength = ioc->spi_data.sdp1length;				header1.PageNumber = 1;				header1.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;				cfg.cfghdr.hdr = &header1;				cfg.physAddr = cfg1_dma_addr;				cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;				cfg.dir = 1;				cfg.timeout = 0;			}		}	}	/* loop through all devices on this port	 */	while (bus < MPT_MAX_BUS) {		iocmd.bus = bus;		iocmd.id = id;		pTarget = hd->Targets[(int)id];		if (doConfig) {			/* Set the negotiation flags */			if (pTarget && (pTarget = hd->Targets[id]) && !pTarget->raidVolume) {				flags = pTarget->negoFlags;			} else {				flags = hd->ioc->spi_data.noQas;				if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {					data = hd->ioc->spi_data.nvram[id];					if (data & MPT_NVRAM_WIDE_DISABLE)						flags |= MPT_TARGET_NO_NEGO_WIDE;					factor = (data & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT;					if ((factor == 0) || (factor == MPT_ASYNC))						flags |= MPT_TARGET_NO_NEGO_SYNC;				}			}			/* Force to async, narrow */			mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested,					&configuration, flags);			dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC "				"offset=0 negoFlags=%x request=%x config=%x\n",				id, flags, requested, configuration));			pcfg1Data->RequestedParameters = le32_to_cpu(requested);			pcfg1Data->Reserved = 0;			pcfg1Data->Configuration = le32_to_cpu(configuration);			cfg.pageAddr = (bus<<8) | id;			mpt_config(hd->ioc, &cfg);		}		/* If target Ptr NULL or if this target is NOT a disk, skip.		 */		if ((pTarget) && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)){			for (lun=0; lun <= MPT_LAST_LUN; lun++) {				/* If LUN present, issue the command				 */				lun_index = (lun >> 5);  /* 32 luns per lun_index */				indexed_lun = (lun % 32);				if (pTarget->luns[lun_index] & (1<<indexed_lun)) {					iocmd.lun = lun;					(void) mptscsih_do_cmd(hd, &iocmd);				}			}		}		/* get next relevant device */		id++;		if (id == hostId)			id++;		if (id > max_id) {			id = 0;			bus++;		}	}	if (pcfg1Data) {		pci_free_consistent(ioc->pcidev, header1.PageLength * 4, pcfg1Data, cfg1_dma_addr);	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/637fa99b86a00a0b5767a982b83a512ff48ad6d2/mptscsih.c/buggy/drivers/message/fusion/mptscsih.c