当前位置: 首页>>代码示例>>C++>>正文


C++ dev_to_zram函数代码示例

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


在下文中一共展示了dev_to_zram函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mem_used_total_show

static ssize_t mem_used_total_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	u64 val = 0;
	struct zram *zram = dev_to_zram(dev);

	if (zram->init_done)
		val = zs_get_total_size_bytes(zram->mem_pool);

	return sprintf(buf, "%llu\n", val);
}
开发者ID:lchtlx,项目名称:zte_msm8x30_cm11,代码行数:11,代码来源:zram_sysfs.c

示例2: disksize_store

static ssize_t disksize_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	u64 disksize;
	struct zram_meta *meta;
	struct zram *zram = dev_to_zram(dev);

	/* Fix disksize */
	disksize = default_disksize_perc_ram * ((totalram_pages << PAGE_SHIFT) / 100);
	/* Expand its disksize if we have little system ram! */
	if (totalram_pages < SUPPOSED_TOTALRAM) {
		disksize += (disksize >> 1) ;
	}
开发者ID:Scorpio92,项目名称:mediatek,代码行数:13,代码来源:zram_sysfs.c

示例3: mem_used_total_show

static ssize_t mem_used_total_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	u64 val = 0;
	struct zram *zram = dev_to_zram(dev);
	struct zram_meta *meta = zram->meta;

	down_read(&zram->init_lock);
	if (zram->init_done)
		val = zs_get_total_pages(meta->mem_pool);
	up_read(&zram->init_lock);

	return sprintf(buf, "%llu\n", val << PAGE_SHIFT);
}
开发者ID:NhlalukoG,项目名称:android_kernel_samsung_goyave3g,代码行数:14,代码来源:zram_sysfs.c

示例4: reset_store

static ssize_t reset_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	int ret;
	unsigned short do_reset;
	struct zram *zram;
	struct block_device *bdev;

	zram = dev_to_zram(dev);
	bdev = bdget_disk(zram->disk, 0);

	if (!bdev)
		return -ENOMEM;

	/* Do not reset an active device! */
	if (bdev->bd_holders) {
		ret = -EBUSY;
		goto out;
	}

	ret = kstrtou16(buf, 10, &do_reset);
	if (ret)
		goto out;

	if (!do_reset) {
		ret = -EINVAL;
		goto out;
	}

	/* Make sure all pending I/O is finished */
	fsync_bdev(bdev);
	bdput(bdev);

	down_write(&zram->init_lock);
	if (zram->init_done)
		__zram_reset_device(zram);
	up_write(&zram->init_lock);

	return len;

out:
	bdput(bdev);
	return ret;
}
开发者ID:dario97818,项目名称:Imperium_Kernel_TW_5.0.1,代码行数:44,代码来源:zram_sysfs.c

示例5: disksize_store

static ssize_t disksize_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	int ret;
	struct zram *zram = dev_to_zram(dev);

	if (zram->init_done) {
		pr_info("Cannot change disksize for initialized device\n");
		return -EBUSY;
	}

	ret = strict_strtoull(buf, 10, &zram->disksize);
	if (ret)
		return ret;

	zram->disksize = PAGE_ALIGN(zram->disksize);
	set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);

	return len;
}
开发者ID:andi34,项目名称:kernel_samsung_espresso,代码行数:20,代码来源:zram_sysfs.c

示例6: disksize_store

static ssize_t disksize_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	u64 disksize;
	struct zram *zram = dev_to_zram(dev);

	disksize = memparse(buf, NULL);
	if (!disksize)
		return -EINVAL;

	down_write(&zram->init_lock);
	if (zram->init_done) {
		up_write(&zram->init_lock);
		pr_info("Cannot change disksize for initialized device\n");
		return -EBUSY;
	}

	zram->disksize = PAGE_ALIGN(disksize);
	set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
	zram_init_device(zram);
	up_write(&zram->init_lock);

	return len;
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:24,代码来源:zram_sysfs.c


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