本文整理汇总了C++中set_capacity函数的典型用法代码示例。如果您正苦于以下问题:C++ set_capacity函数的具体用法?C++ set_capacity怎么用?C++ set_capacity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_capacity函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sd_revalidate_disk
/*
* Checks if media is still valid.
*/
static int sd_revalidate_disk(struct gendisk *disk)
{
struct sd_host *host = disk->private_data;
int retval = 0;
/* report missing medium for zombies */
if (!host) {
retval = -ENOMEDIUM;
goto out;
}
/* the block layer likes to call us multiple times... */
if (!sd_media_changed(host->disk))
goto out;
/* get the card into a known status */
retval = sd_welcome_card(host);
if (retval < 0 || sd_card_is_bad(host)) {
retval = -ENOMEDIUM;
goto out;
}
/* inform the block layer about various sizes */
blk_queue_logical_block_size(host->queue, 1 << KERNEL_SECTOR_SHIFT);
set_capacity(host->disk, host->card.csd.capacity /*<< (host->card.csd.read_blkbits - KERNEL_SECTOR_SHIFT)*/);
clear_bit(__SD_MEDIA_CHANGED, &host->flags);
out:
return retval;
}
开发者ID:mozgwar,项目名称:GC-Wii-Linux-Kernel-3.12.y,代码行数:34,代码来源:gcn-sd.c
示例2: fd_create_cache
FAST_DRAW_CACHE* fd_create_cache(size_t initial_size, bool use_indices)
{
FAST_DRAW_CACHE* cache = calloc(1, sizeof(FAST_DRAW_CACHE));
cache->use_indices = use_indices;
set_capacity(cache, initial_size);
return cache;
}
开发者ID:SiegeLord,项目名称:FastDraw,代码行数:7,代码来源:fast_draw.c
示例3: set_capacity
void AP_BattMonitor_Bebop::init(void)
{
set_capacity(BATTERY_CAPACITY);
_battery_voltage_max = bat_lut[BATTERY_PERCENT_LUT_SIZE - 1].voltage;
_prev_vbat_raw = bat_lut[BATTERY_PERCENT_LUT_SIZE - 1].voltage;
_prev_vbat = bat_lut[BATTERY_PERCENT_LUT_SIZE - 1].voltage;
}
开发者ID:ranqingfa,项目名称:ardupilot,代码行数:7,代码来源:AP_BattMonitor_Bebop.cpp
示例4: ramblock_init
static int ramblock_init(void)
{
major = register_blkdev(0, "ramblock");
/* 1.分配一个gendisk结构体 */
/* 这里的16表示分区的个数 15个分区 */
ramblock_gendisk = alloc_disk(16);
/* 2. 设置 */
ramblock_gendisk->major = major;
ramblock_gendisk->first_minor = 0;
sprintf(ramblock_gendisk->disk_name, "ramblock");
ramblock_gendisk->fops = &ramblock_fops;
/* 2.1 分配/设置队列:提供读写能力 */
ramblock_request_queue = blk_init_queue(do_ramblock_request, &ramblock_lock);
ramblock_gendisk->queue = ramblock_request_queue;
/* 2.2 设置其它属性:比如容量 */
set_capacity(ramblock_gendisk, RAMBLOCK_SIZE / 512);
/* 3. 硬件相关操作 */
if (NULL == (ramblock_buf = kzalloc(RAMBLOCK_SIZE, GFP_KERNEL)))
return -ENOMEM;
/* 4. 注册 */
add_disk(ramblock_gendisk);
return 0;
}
开发者ID:54shady,项目名称:mini2440_drv,代码行数:30,代码来源:ramblock.c
示例5: dasd_scan_partitions
/*
* Trigger a partition detection.
*/
int
dasd_scan_partitions(struct dasd_device * device)
{
struct block_device *bdev;
/* Make the disk known. */
set_capacity(device->gdp, device->blocks << device->s2b_shift);
bdev = bdget_disk(device->gdp, 0);
if (!bdev || blkdev_get(bdev, FMODE_READ, 1) < 0)
return -ENODEV;
/*
* See fs/partition/check.c:register_disk,rescan_partitions
* Can't call rescan_partitions directly. Use ioctl.
*/
ioctl_by_bdev(bdev, BLKRRPART, 0);
/*
* Since the matching blkdev_put call to the blkdev_get in
* this function is not called before dasd_destroy_partitions
* the offline open_count limit needs to be increased from
* 0 to 1. This is done by setting device->bdev (see
* dasd_generic_set_offline). As long as the partition
* detection is running no offline should be allowed. That
* is why the assignment to device->bdev is done AFTER
* the BLKRRPART ioctl.
*/
device->bdev = bdev;
return 0;
}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:31,代码来源:dasd_genhd.c
示例6: dasd_destroy_partitions
/*
* Remove all inodes in the system for a device, delete the
* partitions and make device unusable by setting its size to zero.
*/
void dasd_destroy_partitions(struct dasd_block *block)
{
/* The two structs have 168/176 byte on 31/64 bit. */
struct blkpg_partition bpart;
struct blkpg_ioctl_arg barg;
struct block_device *bdev;
/*
* Get the bdev pointer from the device structure and clear
* device->bdev to lower the offline open_count limit again.
*/
bdev = block->bdev;
block->bdev = NULL;
/*
* See fs/partition/check.c:delete_partition
* Can't call delete_partitions directly. Use ioctl.
* The ioctl also does locking and invalidation.
*/
memset(&bpart, 0, sizeof(struct blkpg_partition));
memset(&barg, 0, sizeof(struct blkpg_ioctl_arg));
barg.data = (void __force __user *) &bpart;
barg.op = BLKPG_DEL_PARTITION;
for (bpart.pno = block->gdp->minors - 1; bpart.pno > 0; bpart.pno--)
ioctl_by_bdev(bdev, BLKPG, (unsigned long) &barg);
invalidate_partition(block->gdp, 0);
/* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */
blkdev_put(bdev, FMODE_READ);
set_capacity(block->gdp, 0);
}
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:35,代码来源:dasd_genhd.c
示例7: ramhd_init
static int __init ramhd_init(void)
{
int i;
ramhd_space_init();
alloc_ramdev();
ramhd_major = register_blkdev(0, RAMHD_NAME);
for (i=0; i<RAMHD_MAX_DEVICE; i++)
{
rdev[i]->data = sdisk[i];
rdev[i]->queue = blk_alloc_queue(GFP_KERNEL);
blk_queue_make_request(rdev[i]->queue, ramhd_make_request);
rdev[i]->gd = alloc_disk(RAMHD_MAX_PARTITIONS);
rdev[i]->gd->major = ramhd_major;
rdev[i]->gd->first_minor = i*RAMHD_MAX_PARTITIONS;
rdev[i]->gd->fops = &ramhd_fops;
rdev[i]->gd->queue = rdev[i]->queue;
rdev[i]->gd->private_data = rdev[i];
sprintf(rdev[i]->gd->disk_name, "ramhd%c", 'a'+i);
rdev[i]->gd->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
set_capacity(rdev[i]->gd, RAMHD_SECTOR_TOTAL);
add_disk(rdev[i]->gd);
}
return 0;
}
开发者ID:TUSSON,项目名称:Coding,代码行数:27,代码来源:ramhd_mkreq.c
示例8: cf_create_disk
static int cf_create_disk(struct cf_device *cf)
{
struct gendisk *disk;
DPRINTK(DEBUG_CF_GENDISK, "%s: cf %p\n", __FUNCTION__, cf);
disk = alloc_disk(1 << 4);
if (!disk) {
DPRINTK(DEBUG_CF_TRACE, "%s:%d\n", __FUNCTION__, __LINE__);
blk_cleanup_queue(cf->queue);
cf->queue = NULL;
return -ENOMEM;
}
cf->gd = disk;
disk->major = cf_major;
disk->first_minor = 0;
disk->fops = &cf_fops;
disk->queue = cf->queue;
disk->private_data = cf;
snprintf(disk->disk_name, 32, "cf%c", cf->id + 'a');
disk->private_data = cf;
set_capacity(disk, ata_id_u32(cf->cf_id, ATA_ID_LBA_CAPACITY));
printk(KERN_INFO "%s: %u MiB\n", disk->disk_name, ata_id_u32(cf->cf_id, ATA_ID_LBA_CAPACITY) >> (20-9));
add_disk(disk);
return 0;
}
开发者ID:Aircell,项目名称:asp-kernel,代码行数:31,代码来源:dm3730logic-cf.c
示例9: orb_check
// read - read latest voltage and current
void AP_BattMonitor_SMBus_PX4::read()
{
bool updated = false;
struct battery_status_s batt_status;
// check if new info has arrived from the orb
orb_check(_batt_sub, &updated);
// retrieve latest info
if (updated) {
if (OK == orb_copy(ORB_ID(battery_status), _batt_sub, &batt_status)) {
_state.voltage = batt_status.voltage_v;
_state.current_amps = batt_status.current_a;
_state.last_time_micros = hal.scheduler->micros();
_state.current_total_mah = batt_status.discharged_mah;
_state.healthy = true;
// read capacity
if ((_batt_fd >= 0) && !_capacity_updated) {
uint16_t tmp;
if (ioctl(_batt_fd, BATT_SMBUS_GET_CAPACITY, (unsigned long)&tmp) == OK) {
_capacity_updated = true;
set_capacity(tmp);
}
}
}
} else if (_state.healthy) {
// timeout after 5 seconds
if ((hal.scheduler->micros() - _state.last_time_micros) > AP_BATTMONITOR_SMBUS_TIMEOUT_MICROS) {
_state.healthy = false;
}
}
}
开发者ID:1000000007,项目名称:ardupilot,代码行数:34,代码来源:AP_BattMonitor_SMBus_PX4.cpp
示例10: setup_device
static int setup_device(osprd_info_t *d, int which)
{
memset(d, 0, sizeof(osprd_info_t));
/* Get memory to store the actual block data. */
if (!(d->data = vmalloc(nsectors * SECTOR_SIZE)))
return -1;
memset(d->data, 0, nsectors * SECTOR_SIZE);
/* Set up the I/O queue. */
spin_lock_init(&d->qlock);
if (!(d->queue = blk_init_queue(osprd_process_request_queue, &d->qlock)))
return -1;
blk_queue_hardsect_size(d->queue, SECTOR_SIZE);
d->queue->queuedata = d;
/* The gendisk structure. */
if (!(d->gd = alloc_disk(1)))
return -1;
d->gd->major = OSPRD_MAJOR;
d->gd->first_minor = which;
d->gd->fops = &osprd_ops;
d->gd->queue = d->queue;
d->gd->private_data = d;
snprintf(d->gd->disk_name, 32, "osprd%c", which + 'a');
set_capacity(d->gd, nsectors);
add_disk(d->gd);
/* Call the setup function. */
osprd_setup(d);
return 0;
}
开发者ID:metropolisDT,项目名称:CS111,代码行数:33,代码来源:osprd.c
示例11: mbd_init_disk
static int mbd_init_disk(int devno)
{
struct gendisk *disk = mbd_dev[devno].disk;
unsigned int sz;
if (!__onsim())
return -1;
/* check disk configured */
if (!MamboBogusDiskInfo(BD_INFO_STATUS, devno)) {
printk(KERN_ERR
"Attempting to open bogus disk before initializaiton\n");
return 0;
}
mbd_dev[devno].initialized++;
sz = MamboBogusDiskInfo(BD_INFO_DEVSZ, devno);
if (sz == -1)
return 0;
printk("Initializing disk %d with devsz %u\n", devno, sz);
set_capacity(disk, sz << 1);
return 1;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:28,代码来源:mambo_bd.c
示例12: ramblock_init
static int ramblock_init(void)
{
/* 1. 分配一个gendisk结构体 */
ramblock_disk = alloc_disk(16); /* 次设备号个数: 分区个数+1 */
/* 2. 设置 */
/* 2.1 分配/设置队列: 提供读写能力 */
ramblock_queue = blk_init_queue(do_ramblock_request, &ramblock_lock);
ramblock_disk->queue = ramblock_queue;
/* 2.2 设置其他属性: 比如容量 */
major = register_blkdev(0, "ramblock"); /* cat /proc/devices */
ramblock_disk->major = major;
ramblock_disk->first_minor = 0;
sprintf(ramblock_disk->disk_name, "ramblock");
ramblock_disk->fops = &ramblock_fops;
set_capacity(ramblock_disk, RAMBLOCK_SIZE / 512);
/* 3. 硬件相关操作 */
ramblock_buf = kzalloc(RAMBLOCK_SIZE, GFP_KERNEL);
/* 4. 注册 */
add_disk(ramblock_disk);
return 0;
}
开发者ID:commshare,项目名称:ARMDriver,代码行数:26,代码来源:ramblock.c
示例13: find_first_zero_bit
static struct card_blk_data *card_blk_alloc(struct memory_card *card)
{
struct card_blk_data *card_data;
int devidx, ret;
devidx = find_first_zero_bit(dev_use, CARD_NUM_MINORS);
if(card->card_type == CARD_INAND)
devidx = CARD_INAND_START_MINOR>>CARD_SHIFT;
if (devidx >= CARD_NUM_MINORS)
return ERR_PTR(-ENOSPC);
__set_bit(devidx, dev_use);
card_data = kmalloc(sizeof(struct card_blk_data), GFP_KERNEL);
if (!card_data) {
ret = -ENOMEM;
return ERR_PTR(ret);
}
memset(card_data, 0, sizeof(struct card_blk_data));
card_data->block_bits = 9;
card_data->disk = alloc_disk(1 << CARD_SHIFT);
if (card_data->disk == NULL) {
ret = -ENOMEM;
kfree(card_data);
return ERR_PTR(ret);
}
spin_lock_init(&card_data->lock);
card_data->usage = 1;
ret = card_init_queue(&card_data->queue, card, &card_data->lock);
if (ret) {
put_disk(card_data->disk);
return ERR_PTR(ret);
}
card_data->queue.prep_fn = card_blk_prep_rq;
card_data->queue.issue_fn = card_blk_issue_rq;
card_data->queue.data = card_data;
card_data->disk->major = major;
card_data->disk->minors = 1 << CARD_SHIFT;
card_data->disk->first_minor = devidx << CARD_SHIFT;
card_data->disk->fops = &card_ops;
card_data->disk->private_data = card_data;
card_data->disk->queue = card_data->queue.queue;
card_data->disk->driverfs_dev = &card->dev;
sprintf(card_data->disk->disk_name, "cardblk%s", card->name);
blk_queue_logical_block_size(card_data->queue.queue, 1 << card_data->block_bits);
set_capacity(card_data->disk, card->capacity);
return card_data;
}
开发者ID:rofehr,项目名称:aml-original-linux-kernel,代码行数:60,代码来源:card_block.c
示例14: ramblock_init
static int __init ramblock_init(void)
{
/* 1. Allocate gendisk struct */
ramblock_disk = alloc_disk(16);
/* 2. Configure */
/* 2.1 Allocate/Configure a queue which supporting read/write capabilities */
if (!(ramblock_queue = blk_init_queue(do_ramblock_request, &ramblock_lock)))
return -ENOMEM;
ramblock_disk->queue = ramblock_queue;
/* 2.2 Configure other properties: such as volume, etc */
major = register_blkdev(0, "ramblock");
ramblock_disk->major = major;
ramblock_disk->first_minor = 0;
sprintf(ramblock_disk->disk_name, "ramblock");
ramblock_disk->fops = &ramblock_fops;
set_capacity(ramblock_disk, RAMBLOCK_SIZE / 512); /* 512 bytes per sector */
/* 3. Register */
add_disk(ramblock_disk);
return 0;
}
开发者ID:uwyyk,项目名称:LINUX_DRIVERS,代码行数:27,代码来源:ramblock.c
示例15: ndas_init
static int __init ndas_init(void)
{
int retval = 0;
struct ndas_dev *dev;
func();
retval = register_blkdev(0, "myndas");
if (retval <= 0) {
printk(KERN_ERR "ndas: failed to register device\n");
return retval;
} else {
major_number = retval;
printk(KERN_INFO "ndas: register device major number %d\n", major_number);
}
/* init block device */
dev = kmalloc(sizeof(struct ndas_dev), GFP_KERNEL);
if (dev == NULL) {
printk(KERN_ERR "ndas: failed to allocate memory for device\n");
goto err1;
}
memset(dev, sizeof(struct ndas_dev), 0);
spin_lock_init(&dev->lock);
Device = dev;
/* init queue */
dev->queue = blk_init_queue(ndas_request, &dev->lock);
if (dev->queue == NULL) {
printk(KERN_ERR "ndas: failed to allocate memory for queue\n");
goto err2;
}
blk_queue_logical_block_size(dev->queue, HARDSECT_SIZE);
dev->queue->queuedata = dev;
/* gendisk structure */
dev->gd = alloc_disk(NDAS_MINORS);
if (dev->gd == NULL) {
printk(KERN_ERR "ndas: failed to allocate memory for gendisk\n");
goto err3;
}
dev->gd->major = major_number;
dev->gd->first_minor = 0;
dev->gd->fops = &blk_ops;
dev->gd->queue = dev->queue;
dev->gd->private_data = dev;
set_capacity(dev->gd, NSECTOR * (HARDSECT_SIZE / KERNEL_SECTOR_SIZE));
snprintf(dev->gd->disk_name, 6, "myndas");
add_disk(dev->gd);
return 0;
err3:
blk_cleanup_queue(dev->queue);
err2:
kfree(dev);
err1:
Device = NULL;
unregister_blkdev(major_number, "ndas");
return -ENOMEM;
}
开发者ID:aeppert,项目名称:km,代码行数:59,代码来源:ndasblock.c
示例16: __set_size
static void __set_size(struct mapped_device *md, sector_t size)
{
set_capacity(md->disk, size);
down(&md->frozen_bdev->bd_inode->i_sem);
i_size_write(md->frozen_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
up(&md->frozen_bdev->bd_inode->i_sem);
}
开发者ID:waterice,项目名称:Test-Git,代码行数:8,代码来源:dm.c
示例17: __set_size
static void __set_size(struct mapped_device *md, sector_t size)
{
set_capacity(md->disk, size);
mutex_lock(&md->suspended_bdev->bd_inode->i_mutex);
i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
mutex_unlock(&md->suspended_bdev->bd_inode->i_mutex);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:8,代码来源:dm.c
示例18: nbd_size_clear
static int nbd_size_clear(struct nbd_device *nbd, struct block_device *bdev)
{
bdev->bd_inode->i_size = 0;
set_capacity(nbd->disk, 0);
kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
return 0;
}
开发者ID:AngleFork,项目名称:linux,代码行数:8,代码来源:nbd.c
示例19: mbd_init
static int __init mbd_init(void)
{
int err = -ENOMEM;
int i;
for (i = 0; i < MAX_MBD; i++) {
struct gendisk *disk = alloc_disk(1);
if (!disk)
goto out;
mbd_dev[i].disk = disk;
/*
* The new linux 2.5 block layer implementation requires
* every gendisk to have its very own request_queue struct.
* These structs are big so we dynamically allocate them.
*/
disk->queue = blk_init_queue(do_mbd_request, &mbd_lock);
if (!disk->queue) {
put_disk(disk);
goto out;
}
}
if (register_blkdev(MAJOR_NR, "mbd")) {
err = -EIO;
goto out;
}
#ifdef MODULE
printk("mambo bogus disk: registered device at major %d\n", MAJOR_NR);
#else
printk("mambo bogus disk: compiled in with kernel\n");
#endif
devfs_mk_dir("mambobd");
for (i = 0; i < MAX_MBD; i++) { /* load defaults */
struct gendisk *disk = mbd_dev[i].disk;
mbd_dev[i].initialized = 0;
mbd_dev[i].refcnt = 0;
mbd_dev[i].flags = 0;
disk->major = MAJOR_NR;
disk->first_minor = i;
disk->fops = &mbd_fops;
disk->private_data = &mbd_dev[i];
sprintf(disk->disk_name, "mambobd%d", i);
sprintf(disk->devfs_name, "mambobd%d", i);
set_capacity(disk, 0x7ffffc00ULL << 1); /* 2 TB */
add_disk(disk);
}
return 0;
out:
while (i--) {
if (mbd_dev[i].disk->queue)
blk_cleanup_queue(mbd_dev[i].disk->queue);
put_disk(mbd_dev[i].disk);
}
return -EIO;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:57,代码来源:mambo_bd.c
示例20: aoeblk_gdalloc
/* alloc_disk and add_disk can sleep */
void
aoeblk_gdalloc(void *vp)
{
struct aoedev *d = vp;
struct gendisk *gd;
ulong flags;
gd = alloc_disk(AOE_PARTITIONS);
if (gd == NULL) {
printk(KERN_ERR
"aoe: cannot allocate disk structure for %ld.%d\n",
d->aoemajor, d->aoeminor);
goto err;
}
d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache);
if (d->bufpool == NULL) {
printk(KERN_ERR "aoe: cannot allocate bufpool for %ld.%d\n",
d->aoemajor, d->aoeminor);
goto err_disk;
}
d->blkq = blk_alloc_queue(GFP_KERNEL);
if (!d->blkq)
goto err_mempool;
blk_queue_make_request(d->blkq, aoeblk_make_request);
d->blkq->backing_dev_info.name = "aoe";
spin_lock_irqsave(&d->lock, flags);
gd->major = AOE_MAJOR;
gd->first_minor = d->sysminor * AOE_PARTITIONS;
gd->fops = &aoe_bdops;
gd->private_data = d;
set_capacity(gd, d->ssize);
snprintf(gd->disk_name, sizeof gd->disk_name, "etherd/e%ld.%d",
d->aoemajor, d->aoeminor);
gd->queue = d->blkq;
d->gd = gd;
d->flags &= ~DEVFL_GDALLOC;
d->flags |= DEVFL_UP;
spin_unlock_irqrestore(&d->lock, flags);
add_disk(gd);
aoedisk_add_sysfs(d);
return;
err_mempool:
mempool_destroy(d->bufpool);
err_disk:
put_disk(gd);
err:
spin_lock_irqsave(&d->lock, flags);
d->flags &= ~DEVFL_GDALLOC;
spin_unlock_irqrestore(&d->lock, flags);
}
开发者ID:1N4148,项目名称:android_kernel_samsung_golden,代码行数:57,代码来源:aoeblk.c
注:本文中的set_capacity函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论