• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ put_mtd_device函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中put_mtd_device函数的典型用法代码示例。如果您正苦于以下问题:C++ put_mtd_device函数的具体用法?C++ put_mtd_device怎么用?C++ put_mtd_device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了put_mtd_device函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:kmaddock,项目名称:axfs,代码行数:75,代码来源:axfs_super.c


示例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 */
开发者ID:jameshilliard,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:35,代码来源:mtdchar.c


示例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;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:59,代码来源:nvram_linux.c


示例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 */
开发者ID:deepikateriar,项目名称:Onlive-Source-Backup,代码行数:51,代码来源:mtdchar.c


示例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;
}
开发者ID:samm-git,项目名称:e3372h-vendor-src,代码行数:24,代码来源:flash_huawei_dload.c


示例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();
}
开发者ID:jhu-chang,项目名称:r6300v2,代码行数:29,代码来源:nvram_linux.c


示例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);
}  
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-ef_fw-20-19-8,代码行数:29,代码来源:mtdblock_ro.c


示例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;
}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-ef_fw-20-19-8,代码行数:29,代码来源:mtdblock_ro.c


示例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;
}
开发者ID:Noltari,项目名称:u-boot,代码行数:26,代码来源:ubi.c


示例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();
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:25,代码来源:nvram_linux.c


示例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;
}
开发者ID:debbiche,项目名称:android_kernel_huawei_p8,代码行数:31,代码来源:nv_emmc.c


示例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;
}
开发者ID:magnusjjj,项目名称:android_kernel_huawei_rle,代码行数:68,代码来源:sc_balong.c


示例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;
}
开发者ID:mahyarmd,项目名称:unifi-gpl,代码行数:59,代码来源:super.c


示例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;
}
开发者ID:ShinySide,项目名称:SM-G361H,代码行数:58,代码来源:nandflash_bitfliptest.c


示例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);
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:9,代码来源:super.c


示例16: int

/*
 * get a superblock on an MTD-backed filesystem
 */
static struct dentry *mount_mtd_aux(struct file_system_type *fs_type, int flags,
			  const char *dev_name, void *data,
			  struct mtd_info *mtd,
			  int (*fill_super)(struct super_block *, void *, int))
{
	struct super_block *sb;
	int ret;

	sb = sget(fs_type, get_sb_mtd_compare, get_sb_mtd_set, mtd);
	if (IS_ERR(sb))
		goto out_error;

	if (sb->s_root)
		goto already_mounted;

	/* fresh new superblock */
	DEBUG(1, "MTDSB: New superblock for device %d (\"%s\")\n",
	      mtd->index, mtd->name);

	sb->s_flags = flags;

	ret = fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
	if (ret < 0) {
		deactivate_locked_super(sb);
		return ERR_PTR(ret);
	}

	/* go */
	sb->s_flags |= MS_ACTIVE;
	return dget(sb->s_root);

	/* new mountpoint for an already mounted superblock */
already_mounted:
	DEBUG(1, "MTDSB: Device %d (\"%s\") is already mounted\n",
	      mtd->index, mtd->name);
	put_mtd_device(mtd);
	return dget(sb->s_root);

out_error:
	put_mtd_device(mtd);
	return ERR_CAST(sb);
}
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:45,代码来源:mtdsuper.c


示例17: mt76_get_of_eeprom

static int
mt76_get_of_eeprom(struct mt76_dev *dev, int len)
{
#ifdef CONFIG_OF
	struct device_node *np = dev->dev->of_node;
	struct mtd_info *mtd;
	const __be32 *list;
	const char *part;
	phandle phandle;
	int offset = 0;
	int size;
	size_t retlen;
	int ret;

	if (!np)
		return -ENOENT;

	list = of_get_property(np, "mediatek,mtd-eeprom", &size);
	if (!list)
		return -ENOENT;

	phandle = be32_to_cpup(list++);
	if (!phandle)
		return -ENOENT;

	np = of_find_node_by_phandle(phandle);
	if (!np)
		return -EINVAL;

	part = of_get_property(np, "label", NULL);
	if (!part)
		part = np->name;

	mtd = get_mtd_device_nm(part);
	if (IS_ERR(mtd))
		return PTR_ERR(mtd);

	if (size <= sizeof(*list))
		return -EINVAL;

	offset = be32_to_cpup(list);
	ret = mtd_read(mtd, offset, len, &retlen, dev->eeprom.data);
	put_mtd_device(mtd);
	if (ret)
		return ret;

	if (retlen < len)
		return -EINVAL;

	return 0;
#else
	return -ENOENT;
#endif
}
开发者ID:jsj-reseiwe,项目名称:mt76,代码行数:54,代码来源:eeprom.c


示例18: mtd_Flash_Release

/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function:     mtd_Flash_Release
* Inputs:       none
* Outputs:      PASS=0 (notice 0=ok here)
* Description:          Releases the flash.
*
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
int mtd_Flash_Release(void)
{
	nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n",
		       __FILE__, __LINE__, __func__);
	if (!spectra_mtd)
		return PASS;

	put_mtd_device(spectra_mtd);
	spectra_mtd = NULL;

	return PASS;
}
开发者ID:454053205,项目名称:linux,代码行数:19,代码来源:lld_mtd.c


示例19: rt2800lib_read_eeprom_mtd

static int rt2800lib_read_eeprom_mtd(struct rt2x00_dev *rt2x00dev)
{
	int ret = -EINVAL;
#ifdef CONFIG_OF
	static struct firmware mtd_fw;
	struct device_node *np = rt2x00dev->dev->of_node, *mtd_np = NULL;
	size_t retlen, len = rt2x00dev->ops->eeprom_size;
	int size, offset = 0;
	struct mtd_info *mtd;
	const char *part;
	const __be32 *list;
	phandle phandle;

	list = of_get_property(np, "ralink,mtd-eeprom", &size);
	if (!list) {
		dev_err(rt2x00dev->dev, "failed to load eeprom property\n");
		return -ENOENT;
	}

	phandle = be32_to_cpup(list++);
	if (phandle)
		mtd_np = of_find_node_by_phandle(phandle);
	if (!mtd_np) {
		dev_err(rt2x00dev->dev, "failed to load mtd phandle\n");
		return -EINVAL;
	}

	part = of_get_property(mtd_np, "label", NULL);
	if (!part)
		part = mtd_np->name;

	mtd = get_mtd_device_nm(part);
	if (IS_ERR(mtd)) {
		dev_err(rt2x00dev->dev, "failed to get mtd device \"%s\"\n", part);
		return PTR_ERR(mtd);
	}

	if (size > sizeof(*list))
		offset = be32_to_cpup(list);

	ret = mtd_read(mtd, offset, len, &retlen, (u_char *) rt2x00dev->eeprom);
	put_mtd_device(mtd);

	if (!ret) {
		rt2x00dev->eeprom_file = &mtd_fw;
		mtd_fw.size = len;
		mtd_fw.data = (const u8 *) rt2x00dev->eeprom;
	}
#endif

	return ret;
}
开发者ID:OSPro,项目名称:wpj344_compatwireless,代码行数:52,代码来源:rt2x00eeprom.c


示例20: printk

/*===========================================================================
 
FUNCTION  FLASH_NAND_OPER_REGION_INIT
 
DESCRIPTION
    Initilize user partition info,and get the handle of nand flash
RETURN VALUE
    TRUE if Op Succeed
    FALSE if Op Failure
 
SIDE EFFECTS
  None
 
===========================================================================*/
oper_region_struct_t *flash_nand_oper_region_init(  oper_region_type  oper_region_idx)
{
    uint8                idx              = (uint8)oper_region_idx;
    char                 *parent_name_ptr = NULL;
    unsigned int               offset           = 0;
    
    /* 范围保护 */
    if (idx >= REGION_MAX)
    {
        printk(KERN_ERR "Parm error: idx = %d max_ids = %d\n",idx,REGION_MAX);
        return NULL;
    }
 
    /*lint -e662*/
    parent_name_ptr = (char *)child_region[idx].parent_name;
    printk(KERN_DEBUG "parent_name_ptr =%s \n",parent_name_ptr);
    /*lint +e662*/
    /*lint -e661*/
    offset          = child_region[idx].offset;
    /*lint +e661*/

    /* get mtd device */
    g_mtd = get_mtd_device_nm(parent_name_ptr);
    if (NULL == g_mtd)
    {
        printk(KERN_ERR "get_mtd_device_nm error\n");
        return NULL;
    }

    printk(" info :mtd->erasesize = %d ,mtd->writesize = %d \n",
           g_mtd->erasesize,g_mtd->writesize);
    
    /* get the flash address */
    operation_region[idx].block_size = g_mtd->erasesize;
    operation_region[idx].page_size = g_mtd->writesize;
    operation_region[idx].start_addr = (offset * operation_region[idx].block_size);
    operation_region[idx].buffer = himalloc(operation_region[idx].page_size); 

    printk(KERN_DEBUG "operation_region[%d] = %u \n", idx, (unsigned int)operation_region[idx].start_addr);
    
    if (NULL == operation_region[idx].buffer)
    {
        put_mtd_device(g_mtd);
        return NULL;
    }

    /* 初始化读写flash时使用的缓冲区 */
    memset((void *)operation_region[idx].buffer, NAND_FILL_CHAR_APP,
           operation_region[idx].page_size);
    
    return &operation_region[idx];
}
开发者ID:samm-git,项目名称:e3372h-vendor-src,代码行数:66,代码来源:flash_huawei_dload.c



注:本文中的put_mtd_device函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ put_nsproxy函数代码示例发布时间:2022-05-30
下一篇:
C++ put_module函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap