/**
 * fsr_update_vol_spec - update volume & partition instance from the device
 * @param volume        : a volume number
 */
int fsr_update_vol_spec(u32 volume)
{
	int error;
	FSRVolSpec *vs;
	FSRPartI *pi;
	
	DEBUG(DL3,"TINY[I]: volume(%d)\n", volume);

	vs = fsr_get_vol_spec(volume);
	pi = fsr_get_part_spec(volume);
	
	memset(vs, 0x00, sizeof(FSRVolSpec));
	memset(pi, 0x00, sizeof(FSRPartI));
	
	error = FSR_BML_GetVolSpec(volume, vs, FSR_BML_FLAG_NONE);
	/* I/O error */
	if (error != FSR_BML_SUCCESS)
	{
		ERRPRINTK("FSR_BML_GetVolSpec func fail\n");
		return -1;
	}
	error = FSR_BML_GetFullPartI(volume, pi);
	/* I/O error */
	if (error != FSR_BML_SUCCESS)
	{
		ERRPRINTK("FSR_BML_GetFullPartI func fail\n");
		return -1;
	}
	
	DEBUG(DL3,"TINY[O]: volume(%d)\n", volume);

	return 0;
}
Exemple #2
0
static int bml_transfer(u32 volume, u32 partno, const struct request *req)
#endif
{
	unsigned long sector, nsect;
	char *buf;
	FSRVolSpec *vs;
	FSRPartI *ps;
	u32 nPgsPerUnit = 0, n1stVpn = 0, spp_shift, spp_mask;
	int ret;
	
	DEBUG(DL3,"TINY[I]: volume(%d), partno(%d)\n", volume, partno);

	if (!blk_fs_request(req))
	{
		return 0;
	}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
	sector = blk_rq_pos(req);
	nsect = data_len >> 9;
#else
	sector = req->sector;
	nsect = req->current_nr_sectors;
#endif
	buf = req->buffer;
	
	vs = fsr_get_vol_spec(volume);
	ps = fsr_get_part_spec(volume);
	spp_shift = ffs(vs->nSctsPerPg) - 1;
	spp_mask = vs->nSctsPerPg - 1;
	
	if(!fsr_is_whole_dev(partno))
	{
		if (FSR_BML_GetVirUnitInfo(volume, 
			fsr_part_start(ps, partno), &n1stVpn, &nPgsPerUnit) 
				!= FSR_BML_SUCCESS)
		{
			ERRPRINTK("FSR_BML_GetVirUnitInfo FAIL\n");
			return -EIO;
		}
	}

	switch (rq_data_dir(req)) 
	{
		case READ:
			/*
			 * If sector and nsect are aligned with vs->nSctsPerPg,
			 * you have to use a FSR_BML_Read() function using page unit,
			 * If not, use a FSR_BML_ReadScts() function using sector unit.
			 */
			if ((!(sector & spp_mask) && !(nsect & spp_mask))) 
			{
				ret = FSR_BML_Read(volume, n1stVpn + (sector >> spp_shift),
						nsect >> spp_shift, buf, NULL, FSR_BML_FLAG_ECC_ON);
			} 
			else 
			{