/** * 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; }
static int bml_block_open(struct block_device *bdev, fmode_t mode) { u32 volume, minor; int ret; minor = MINOR(bdev->bd_dev); #else static int bml_block_open(struct inode *inode, struct file *file) { u32 volume, minor; int ret; minor = MINOR(inode->i_rdev); #endif volume = fsr_vol(minor); DEBUG(DL3,"TINY[I]: volume(%d), minor(%d)\n", volume, minor); if (volume >= FSR_MAX_VOLUMES) { ERRPRINTK("TINY: Out of volume range\n"); return -ENODEV; } ret = FSR_BML_Open(volume, FSR_BML_FLAG_NONE); if (ret != FSR_BML_SUCCESS) { ERRPRINTK("TINY: open error = 0x%x\n", ret); return -ENODEV; } DEBUG(DL3,"TINY[O]: volume(%d), minor(%d)\n", volume, minor); return 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 {
/** * fsr_init - [Init] initalize the fsr */ static int __init fsr_init(void) { int error; DECLARE_TIMER; /*initialize global array*/ START_TIMER(); DEBUG(DL3,"TINY[I]\n"); #if defined(FSR_OAM_ALL_DBGMSG) FSR_DBG_SetDbgZoneMask(FSR_DBZ_ALL_ENABLE); #endif FSR_OAM_MEMSET(vol_spec, 0x00, sizeof(FSRVolSpec) * FSR_MAX_VOLUMES); FSR_OAM_MEMSET(part_spec, 0x00, sizeof(FSRPartI) * FSR_MAX_VOLUMES); error = FSR_BML_Init(FSR_BML_FLAG_NONE); STOP_TIMER("BML_Init"); if (error != FSR_BML_SUCCESS && error != FSR_BML_ALREADY_INITIALIZED) { ERRPRINTK("Tiny BML_Init: error (%x)\n", error); ERRPRINTK("Check the PAM module\n"); return -ENXIO; } /* call init bml block device */ if(bml_block_init()) { ERRPRINTK("Tiny BML_Block init: error (%x)\n", error); return -ENXIO; } DEBUG(DL3,"TINY[O]\n"); return 0; }
/** * BML block module init * @return 0 on success */ int __init bml_block_init(void) { DEBUG(DL3,"TINY[I]\n"); if (bml_blkdev_init() == 0) { printk("FSR: Registered TinyFSR Driver.\n"); } else { ERRPRINTK("FSR: Couldn't register TinyFSR Driver.\n"); } DEBUG(DL3,"TINY[O]\n"); return 0; }