本文整理汇总了C++中put_mtd_device函数的典型用法代码示例。如果您正苦于以下问题:C++ put_mtd_device函数的具体用法?C++ put_mtd_device怎么用?C++ put_mtd_device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了put_mtd_device函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_mtd_device
/******************************************************************************
*
* axfs_get_sb_mtdnr
*
* Description:
* Populates a axfs_fill_super_info struct after sanity checking the
* mtd device of device number
*
* Parameters:
* (IN) mtdnr - the mtd device number
*
* Returns:
* pointer to a axfs_file_super_info or an error pointer
*
*****************************************************************************/
static struct axfs_fill_super_info *axfs_get_sb_mtdnr(int mtdnr)
{
struct axfs_fill_super_info *output;
struct mtd_info *mtd;
void *axfsimage;
size_t retlen;
int err;
mtd = get_mtd_device(NULL, mtdnr);
if (!mtd) {
printk(KERN_DEBUG
"axfs: MTD device #%u doesn't appear to exist\n", mtdnr);
err = -EINVAL;
goto out;
}
if (mtd->point) {
} else {
printk(KERN_DEBUG
"axfs: MTD device #%u doesn't support point()\n", mtdnr);
err = -EINVAL;
goto out;
}
if (mtd->unpoint) {
} else {
printk(KERN_DEBUG
"axfs: MTD device #%u doesn't support unpoint()\n",
mtdnr);
err = -EINVAL;
goto out;
}
if (!((mtd->point(mtd, 0, PAGE_SIZE, &retlen, &axfsimage, NULL)) == 0)) {
err = -EACCES;
goto out;
}
output = (struct axfs_fill_super_info *)vmalloc(sizeof(struct axfs_fill_super_info));
if(!output) {
err = - ENOMEM;
goto out;
}
output->onmedia_super_block = (struct axfs_super_onmedia *)vmalloc(sizeof(struct axfs_super_onmedia));
if(!output->onmedia_super_block) {
err = - ENOMEM;
goto out;
}
memcpy((void *)output->onmedia_super_block, axfsimage, sizeof(struct axfs_super_onmedia));
mtd->unpoint(mtd, 0, retlen);
output->physical_start_address = (unsigned long)mtd_get_partition_physaddr(mtd);
output->virtual_start_address = 0;
put_mtd_device(mtd);
return output;
out:
put_mtd_device(mtd);
return ERR_PTR(err);
}
示例2: mtd_open
static int mtd_open(struct inode *inode, struct file *file)
{
int minor = minor(inode->i_rdev);
int devnum = minor >> 1;
struct mtd_info *mtd;
DEBUG(MTD_DEBUG_LEVEL0, "MTD_open\n");
if (devnum >= MAX_MTD_DEVICES)
return -ENODEV;
/* You can't open the RO devices RW */
if ((file->f_mode & 2) && (minor & 1))
return -EACCES;
mtd = get_mtd_device(NULL, devnum);
if (!mtd)
return -ENODEV;
if (MTD_ABSENT == mtd->type) {
put_mtd_device(mtd);
return -ENODEV;
}
file->private_data = mtd;
/* You can't open it RW if it's not a writeable device */
if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
put_mtd_device(mtd);
return -EACCES;
}
return 0;
} /* mtd_open */
示例3: cfe_init
static int cfe_init(void)
{
size_t erasesize;
int i;
int ret = 0;
printk("!!! cfe_init !!!\n");
/* Find associated MTD device */
for (i = 0; i < MAX_MTD_DEVICES; i++) {
cfe_mtd = get_mtd_device(NULL, i);
if (cfe_mtd != NULL) {
printk("cfe_init: CFE MTD %x %s %x\n", i, cfe_mtd->name, cfe_mtd->size);
if (!strcmp(cfe_mtd->name, "pmon"))
break;
put_mtd_device(cfe_mtd);
}
}
if (i >= MAX_MTD_DEVICES)
{
printk("cfe_init: No CFE MTD\n");
cfe_mtd = NULL;
ret = -ENODEV;
}
if(cfe_mtd == NULL) goto fail;
/* sector blocks to be erased and backup */
erasesize = ROUNDUP(CFE_NVRAM_SPACE, cfe_mtd->erasesize);
printk("cfe_init: block size %d\n", erasesize);
cfe_buf = kmalloc(erasesize, GFP_KERNEL);
if(cfe_buf == NULL)
{
printk("cfe_init: No CFE Memory\n");
ret = -ENOMEM;
goto fail;
}
if((ret = get_embedded_block(cfe_mtd, cfe_buf, erasesize, &cfe_offset, &cfe_nvram_header, &cfe_embedded_size)))
goto fail;
printk("cfe_init: cfe_nvram_header(%08x)\n", (unsigned int) cfe_nvram_header);
bcm947xx_watchdog_disable();
return 0;
fail:
if (cfe_mtd != NULL)
{
put_mtd_device(cfe_mtd);
cfe_mtd=NULL;
}
if(cfe_buf != NULL)
{
kfree(cfe_buf);
cfe_buf=NULL;
}
return ret;
}
示例4: mtd_open
static int mtd_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
int devnum = minor >> 1;
int ret = 0;
struct mtd_info *mtd;
struct mtd_file_info *mfi;
DEBUG(MTD_DEBUG_LEVEL0, "MTD_open\n");
if (devnum >= MAX_MTD_DEVICES)
return -ENODEV;
/* You can't open the RO devices RW */
if ((file->f_mode & 2) && (minor & 1))
return -EACCES;
lock_kernel();
mtd = get_mtd_device(NULL, devnum);
if (IS_ERR(mtd)) {
ret = PTR_ERR(mtd);
goto out;
}
if (MTD_ABSENT == mtd->type) {
put_mtd_device(mtd);
ret = -ENODEV;
goto out;
}
/* You can't open it RW if it's not a writeable device */
if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
put_mtd_device(mtd);
ret = -EACCES;
goto out;
}
mfi = kzalloc(sizeof(*mfi), GFP_KERNEL);
if (!mfi) {
put_mtd_device(mtd);
ret = -ENOMEM;
goto out;
}
mfi->mtd = mtd;
file->private_data = mfi;
out:
unlock_kernel();
return ret;
} /* mtd_open */
示例5: flash_nand_oper_region_close
/*===========================================================================
FUNCTION FLASH_NAND_OPER_REGION_CLOSE
DESCRIPTION
close flash device and release flash handle
DEPENDENCIES
None.
RETURN VALUE
TRUE: valid
FALSE: invalid
SIDE EFFECTS
None.
===========================================================================*/
void flash_nand_oper_region_close(oper_region_type oper_region_idx)
{
(void) kfree(operation_region[oper_region_idx].buffer);
operation_region[oper_region_idx].buffer = NULL;
put_mtd_device(g_mtd);
return;
}
示例6: dev_nvram_exit
static void
dev_nvram_exit(void)
{
int order = 0;
struct page *page, *end;
if (nvram_class) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
class_device_destroy(nvram_class, MKDEV(nvram_major, 0));
#else /* 2.6.36 and up */
device_destroy(nvram_class, MKDEV(nvram_major, 0));
#endif
class_destroy(nvram_class);
}
if (nvram_major >= 0)
unregister_chrdev(nvram_major, "nvram");
if (nvram_mtd)
put_mtd_device(nvram_mtd);
while ((PAGE_SIZE << order) < MAX_NVRAM_SPACE)
order++;
end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
for (page = virt_to_page(nvram_buf); page <= end; page++)
ClearPageReserved(page);
_nvram_exit();
}
示例7: mtdblock_release
static release_t mtdblock_release(struct inode *inode, struct file *file)
{
int dev;
struct mtd_info *mtd;
DEBUG(1, "mtdblock_release\n");
if (inode == NULL)
release_return(-ENODEV);
dev = MINOR(inode->i_rdev);
mtd = __get_mtd_device(NULL, dev);
if (!mtd) {
printk(KERN_WARNING "MTD device is absent on mtd_release!\n");
BLK_DEC_USE_COUNT;
release_return(-ENODEV);
}
if (mtd->sync)
mtd->sync(mtd);
put_mtd_device(mtd);
DEBUG(1, "ok\n");
BLK_DEC_USE_COUNT;
release_return(0);
}
示例8: mtdblock_open
static int mtdblock_open(struct inode *inode, struct file *file)
{
struct mtd_info *mtd = NULL;
int dev;
DEBUG(1,"mtdblock_open\n");
if (inode == 0)
return -EINVAL;
dev = MINOR(inode->i_rdev);
mtd = get_mtd_device(NULL, dev);
if (!mtd)
return -EINVAL;
if (MTD_ABSENT == mtd->type) {
put_mtd_device(mtd);
return -EINVAL;
}
BLK_INC_USE_COUNT;
mtd_sizes[dev] = mtd->size>>9;
DEBUG(1, "ok\n");
return 0;
}
示例9: ubi_part
int ubi_part(char *part_name, const char *vid_header_offset)
{
struct mtd_info *mtd;
int err = 0;
ubi_detach();
mtd_probe_devices();
mtd = get_mtd_device_nm(part_name);
if (IS_ERR(mtd)) {
printf("Partition %s not found!\n", part_name);
return 1;
}
put_mtd_device(mtd);
err = ubi_dev_scan(mtd, vid_header_offset);
if (err) {
printf("UBI init error %d\n", err);
printf("Please check, if the correct MTD partition is used (size big enough?)\n");
return err;
}
ubi = ubi_devices[0];
return 0;
}
示例10: dev_nvram_exit
static void
dev_nvram_exit(void)
{
int order = 0;
struct page *page, *end;
if (nvram_class) {
class_device_destroy(nvram_class, MKDEV(nvram_major, 0));
class_destroy(nvram_class);
}
if (nvram_major >= 0)
unregister_chrdev(nvram_major, "nvram");
if (nvram_mtd)
put_mtd_device(nvram_mtd);
while ((PAGE_SIZE << order) < nvram_space)
order++;
end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1);
for (page = virt_to_page(nvram_buf); page <= end; page++)
ClearPageReserved(page);
_nvram_exit();
}
示例11: nv_emmc_close
s32 nv_emmc_close(FILE* fp)
{
struct nv_emmc_file_header_stru* fd = (struct nv_emmc_file_header_stru*)fp;
nv_file_debug(NV_FILE_CLOSE_API,0,0,0,0);
if((NULL == fd)||(fd->fp != fd))
{
nv_file_debug(NV_FILE_CLOSE_API,1,0,0,0);
return BSP_ERR_NV_INVALID_PARAM;
}
put_mtd_device(fd->mtd);
osl_sem_up(&fd->file_sem);
fd->fp = NULL;
fd->seek = 0;
fd->length = 0;
fd->off = 0;
fd->ops --;
fd->mtd = NULL;
if(fd->ops != 0)
{
nv_file_debug(NV_FILE_CLOSE_API,2,fd->ops,0,0);
return BSP_ERR_NV_CLOSE_FILE_FAIL;
}
return NV_OK;
}
示例12: sc_bakup
/*
* Function : sc_bakup
* Discription: c core nv init,this phase build upon the a core kernel init,
* this phase after icc init,this phase ensure to use all nv api normal
* start at this phase ,ops global ddr need spinlock
* Parameter : none
* Output : result
* History :
*/
s32 sc_bakup(s8 *pdata, u32 len)
{
s32 sc_fp = 0;
s32 wlen = 0;
u32 sc_mtd_len = 0;
struct mtd_info* mtd;
sc_fp = bsp_open((char *)SC_PACKET_TRANS_FILE,(RFILE_RDONLY),0660);
if(!sc_fp)
{
sc_error_printf("bsp_open error, chanid :0x%x sc_fp :0x%x\n",SC_ICC_CHAN_ID,sc_fp);
return BSP_ERR_SC_NO_FILE;
}
else
{
sc_debug_printf("bsp_open ok, file is 0x%x!\n",sc_fp);
}
wlen = bsp_read(sc_fp, pdata, len);
if(wlen != len)
{
sc_error_printf("bsp_read error, opt_len :0x%x sc_ram_len :0x%x\n", wlen, len);
bsp_close(sc_fp);
return BSP_ERR_SC_READ_FILE_FAIL;
}
else
{
sc_debug_printf("bsp_read ok, len is 0x%x!\n",(u32)(wlen));
}
bsp_close(sc_fp);
mtd = get_mtd_device_nm((char*)SC_BACKUP_SEC_NAME);
if (IS_ERR(mtd))
{
sc_error_printf("get mtd device err! %s\n",mtd);
return BSP_ERR_READ_MTD_FAIL;
}
sc_mtd_len = mtd->size;
sc_debug_printf("mtd len: 0x%x\n",sc_mtd_len);
put_mtd_device(mtd);
if((sc_mtd_len < SC_MTD_PTABLE_OFFSET) || (len >= SC_MTD_PTABLE_OFFSET))
{
sc_error_printf("mtd length err! sc_mtd_len: 0x%x, len: 0x%x\n",sc_mtd_len, len);
return BSP_ERR_READ_LGTH_FAIL;
}
wlen = bsp_nand_write((char*)SC_BACKUP_SEC_NAME, (sc_mtd_len - SC_MTD_PTABLE_OFFSET), pdata, len);
if(wlen != BSP_OK)
{
sc_error_printf("mtd length err! wlen 0x%x, len is 0x%x\n",wlen,len);
return BSP_ERR_SC_WRITE_FILE_FAIL;
}
sc_debug_printf("sc write to nand ok, len is 0x%x!\n",(u32)(wlen));
return SC_OK;
}
示例13: kmalloc
static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type,
int flags, const char *dev_name,
void *data, struct mtd_info *mtd)
{
struct super_block *sb;
struct jffs2_sb_info *c;
int ret;
c = kmalloc(sizeof(*c), GFP_KERNEL);
if (!c)
return ERR_PTR(-ENOMEM);
memset(c, 0, sizeof(*c));
c->mtd = mtd;
sb = sget(fs_type, jffs2_sb_compare, jffs2_sb_set, c);
if (IS_ERR(sb))
goto out_put;
if (sb->s_root) {
/* New mountpoint for JFFS2 which is already mounted */
D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): Device %d (\"%s\") is already mounted\n",
mtd->index, mtd->name));
goto out_put;
}
D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): New superblock for device %d (\"%s\")\n",
mtd->index, mtd->name));
/* Initialize JFFS2 superblock locks, the further initialization will be
* done later */
init_MUTEX(&c->alloc_sem);
init_MUTEX(&c->erase_free_sem);
init_waitqueue_head(&c->erase_wait);
init_waitqueue_head(&c->inocache_wq);
spin_lock_init(&c->erase_completion_lock);
spin_lock_init(&c->inocache_lock);
sb->s_op = &jffs2_super_operations;
sb->s_flags = flags | MS_NOATIME;
ret = jffs2_do_fill_super(sb, data, (flags&MS_VERBOSE)?1:0);
if (ret) {
/* Failure case... */
up_write(&sb->s_umount);
deactivate_super(sb);
return ERR_PTR(ret);
}
sb->s_flags |= MS_ACTIVE;
return sb;
out_put:
kfree(c);
put_mtd_device(mtd);
return sb;
}
示例14: nandflash_bitfliptest_init
static int __init nandflash_bitfliptest_init(void)
{
int err = 0;
uint64_t tmp = 0;
pr_info(KERN_INFO "\n");
pr_info(KERN_INFO "=================================================\n");
if (dev < 0) {
pr_info("Please specify a valid mtd-device via module parameter\n");
return -EINVAL;
}
pr_info("MTD device: %d\n", dev);
mtd = get_mtd_device(NULL, dev);
if (IS_ERR(mtd)) {
err = PTR_ERR(mtd);
pr_info("error: cannot get MTD device\n");
return err;
}
mtd_part = (struct mtd_part *)mtd;
if (mtd->type != MTD_NANDFLASH) {
pr_info("this test requires NAND flash\n");
goto out;
}
tmp = mtd->size;
do_div(tmp, mtd->erasesize);
ebcnt = tmp;
pgcnt = mtd->erasesize / mtd->writesize;
pgsize = mtd->writesize;
pr_info("MTD device size %llu, eraseblock size %u, "
"page size %u, count of eraseblocks %u, pages per "
"eraseblock %u, OOB size %u\n",
(unsigned long long)mtd->size, mtd->erasesize,
mtd->writesize, ebcnt, pgcnt, mtd->oobsize);
err = mtd_test_scan_bad_block();
if (err)
goto out;
err = mtd_test_bitfliptest();
if(err) {
pr_err("bitfliptest failed!\n");
goto out;
}
out:
pr_info(KERN_INFO "=================================================\n");
if(bbt != NULL)
vfree(bbt);
put_mtd_device(mtd);
return -1;
}
示例15: jffs2_kill_sb
static void jffs2_kill_sb(struct super_block *sb)
{
struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
if (!(sb->s_flags & MS_RDONLY))
jffs2_stop_garbage_collect_thread(c);
generic_shutdown_super(sb);
put_mtd_device(c->mtd);
kfree(c);
}