本文整理汇总了C++中elv_next_request函数的典型用法代码示例。如果您正苦于以下问题:C++ elv_next_request函数的具体用法?C++ elv_next_request怎么用?C++ elv_next_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elv_next_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: simpleblkdrv_do_request
static void simpleblkdrv_do_request(struct request_queue *q)
{
struct request *req;
while ((req = elv_next_request(q)) != NULL)
{
if ((req->sector + req->current_nr_sectors) << 9 > BLK_BYTES)
{
printk(KERN_ERR"request error!\n");
end_request(req, 0);/*transfer fail*/
continue;
}
switch (rq_data_dir(req))
{
case READ:
memcpy(req->buffer, blkdev_data + (req->sector << 9), req->current_nr_sectors << 9);
end_request(req, 1);/*transfer ok*/
break;
case WRITE:
memcpy(blkdev_data + (req->sector << 9), req->buffer, req->current_nr_sectors << 9);
end_request(req, 1);/*transfer ok*/
break;
default:
/* No default because rq_data_dir(req) is 1 bit */
break;
}
}
}
示例2: omap_mbox_read
static ssize_t
omap_mbox_read(struct device *dev, struct device_attribute *attr, char *buf)
{
unsigned long flags;
struct request *rq;
mbox_msg_t *p = (mbox_msg_t *) buf;
struct omap_mbox *mbox = dev_get_drvdata(dev);
struct request_queue *q = mbox->rxq->queue;
while (1) {
spin_lock_irqsave(q->queue_lock, flags);
rq = elv_next_request(q);
spin_unlock_irqrestore(q->queue_lock, flags);
if (!rq)
break;
*p = (mbox_msg_t) rq->data;
if (blk_end_request(rq, 0, 0))
BUG();
if (unlikely(mbox_seq_test(mbox, *p))) {
pr_info("mbox: Illegal seq bit!(%08x) ignored\n", *p);
continue;
}
p++;
}
pr_debug("%02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3]);
return (size_t) ((char *)p - buf);
}
示例3: do_mbd_request
static void do_mbd_request(request_queue_t * q)
{
int result = 0;
struct request *req;
while ((req = elv_next_request(q)) != NULL) {
int minor = req->rq_disk->first_minor;
switch (rq_data_dir(req)) {
case READ:
result = MamboBogusDiskRead(minor,
req->buffer, req->sector,
req->current_nr_sectors);
break;
case WRITE:
result = MamboBogusDiskWrite(minor,
req->buffer, req->sector,
req->current_nr_sectors);
};
if (result)
end_request(req, 0); /* failure */
else
end_request(req, 1); /* success */
}
}
示例4: mtd_blktrans_thread
static int mtd_blktrans_thread(void *arg)
{
struct mtd_blktrans_ops *tr = arg;
struct request_queue *rq = tr->blkcore_priv->rq;
/* we might get involved when memory gets low, so use PF_MEMALLOC */
current->flags |= PF_MEMALLOC | PF_NOFREEZE;
daemonize("%sd", tr->name);
/* daemonize() doesn't do this for us since some kernel threads
actually want to deal with signals. We can't just call
exit_sighand() since that'll cause an oops when we finally
do exit. */
spin_lock_irq(¤t->sighand->siglock);
sigfillset(¤t->blocked);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
spin_lock_irq(rq->queue_lock);
while (!tr->blkcore_priv->exiting) {
struct request *req;
struct mtd_blktrans_dev *dev;
int res = 0;
DECLARE_WAITQUEUE(wait, current);
req = elv_next_request(rq);
if (!req) {
add_wait_queue(&tr->blkcore_priv->thread_wq, &wait);
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(rq->queue_lock);
schedule();
remove_wait_queue(&tr->blkcore_priv->thread_wq, &wait);
spin_lock_irq(rq->queue_lock);
continue;
}
dev = req->rq_disk->private_data;
tr = dev->tr;
spin_unlock_irq(rq->queue_lock);
down(&dev->sem);
res = do_blktrans_request(tr, dev, req);
up(&dev->sem);
spin_lock_irq(rq->queue_lock);
end_request(req, res);
}
spin_unlock_irq(rq->queue_lock);
complete_and_exit(&tr->blkcore_priv->thread_dead, 0);
}
示例5: do_ramdisk_request
static void do_ramdisk_request (request_queue_t * q)
{
static int r_cnt = 0;
static int w_cnt = 0;
struct request *req;
// printk("do_ramdisk_request = %d \n",++cnt);
while ((req = elv_next_request(q)) != NULL)
{
/*数据传输3要素 : 源,目的,长度*/
/*源/目的*/
unsigned long offset = req->sector *512;
/*目的/源*/
//req->buffer
/*长度*/
unsigned long len = req->current_nr_sectors *512;
if (rq_data_dir(req) == READ)
{
printk("do_ramdisk_request read = %d \n",++r_cnt);
memcpy(req->buffer, ramblock_buf+offset, len);
}
else
{
printk("do_ramdisk_request wirte = %d \n",++w_cnt);
memcpy(ramblock_buf+offset,req->buffer, len);
}
end_request(req, 1); /* wrap up, 0 = fail, 1 = success */
}
}
示例6: Virtual_blkdev_do_request
static void Virtual_blkdev_do_request(struct request_queue *q)
{
struct request *req;
while ((req = elv_next_request(q)) != NULL)
{
if ((req->sector + req->current_nr_sectors) << 9> VIRTUAL_BLKDEV_BYTES)
{
printk(KERN_ERR VIRTUAL_BLKDEV_DISKNAME": bad request: block=%llu, count=%u\n",
(unsigned long long)req->sector,
req->current_nr_sectors);
end_request(req, 0);
continue;
}/*endif*/
switch (rq_data_dir(req))
{
case READ:
memcpy(req->buffer,Virtual_blkdev_data + (req->sector << 9),
req->current_nr_sectors << 9);
end_request(req, 1);
break;
case WRITE:
memcpy(Virtual_blkdev_data + (req->sector << 9),
req->buffer, req->current_nr_sectors << 9);
end_request(req, 1);
break;
default:
/* No default because rq_data_dir(req) is 1 bit */
break;
}
}/*endwhile*/
}
示例7: do_z2_request
static void do_z2_request(struct request_queue *q)
{
struct request *req;
while ((req = elv_next_request(q)) != NULL) {
unsigned long start = req->sector << 9;
unsigned long len = req->current_nr_sectors << 9;
if (start + len > z2ram_size) {
printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n",
req->sector, req->current_nr_sectors);
end_request(req, 0);
continue;
}
while (len) {
unsigned long addr = start & Z2RAM_CHUNKMASK;
unsigned long size = Z2RAM_CHUNKSIZE - addr;
if (len < size)
size = len;
addr += z2ram_map[ start >> Z2RAM_CHUNKSHIFT ];
if (rq_data_dir(req) == READ)
memcpy(req->buffer, (char *)addr, size);
else
memcpy((char *)addr, req->buffer, size);
start += size;
len -= size;
}
end_request(req, 1);
}
}
示例8: virtualblockdevice_do_request
static void virtualblockdevice_do_request(struct request_queue *q)
{
struct request *req;
// printk(KERN_ALERT "VirtualBlockDevice: Entry virtualblockdevice_do_request !\n");
while( NULL != ( req = elv_next_request( q ) ) ) {
if( ( ( req->sector + req->current_nr_sectors ) << 9 ) > VIRTUALBLOCKDEVICE_DISK_CAPACITY ) {
printk(KERN_ALERT "VirtualBlockDevice: bad request: start sector: = %llu\t sector count: = %lu \n", (unsigned long long) req->sector, (unsigned long)req->current_nr_sectors);
end_request( req, 0 );
continue;
}
printk(KERN_ALERT "VirtualBlockDevice: request: start sector: = %llu\t sector count: = %lu \n", (unsigned long long) req->sector, (unsigned long)req->current_nr_sectors);
switch( rq_data_dir( req ) ) {
case READ:
memcpy( req->buffer, (virtualblockdevice_data + (req->sector << 9)), (req->current_nr_sectors << 9) );
end_request( req, 1 );
break;
case WRITE:
memcpy( (virtualblockdevice_data + (req->sector << 9)), req->buffer, (req->current_nr_sectors << 9) );
end_request( req, 1 );
break;
default:
printk(KERN_ALERT "VirtualBlockDevice: Unknown data direction !\n");
break;
}
}
}
示例9: do_ramblock_request
static void do_ramblock_request(request_queue_t * q)
{
static int r_cnt = 0;
static int w_cnt = 0;
struct request *req;
//printk("do_ramblock_request %d\n", ++cnt);
while ((req = elv_next_request(q)) != NULL) {
/* 数据传输三要素: 源,目的,长度 */
/* 源/目的: */
unsigned long offset = req->sector * 512;
/* 目的/源: */
// req->buffer
/* 长度: */
unsigned long len = req->current_nr_sectors * 512;
if (rq_data_dir(req) == READ)
{
//printk("do_ramblock_request read %d\n", ++r_cnt);
memcpy(req->buffer, ramblock_buf+offset, len);
}
else
{
//printk("do_ramblock_request write %d\n", ++w_cnt);
memcpy(ramblock_buf+offset, req->buffer, len);
}
end_request(req, 1);
}
}
示例10: do_ramblock_request
static void do_ramblock_request(request_queue_t *q)
{
struct request *req;
while ((req = elv_next_request(q)) != NULL)
{
/* 数据传输三要素:源,目的,长度 */
/* 源/目的 */
unsigned long offset = req->sector << 9;
/* 目的/源 */
/* req->buffer */
/* 长度 */
unsigned long len = req->current_nr_sectors << 9;
if (rq_data_dir(req) == READ)
{
memcpy(req->buffer, ramblock_buf+offset, len);
}
else
{
memcpy(ramblock_buf+offset, req->buffer, len);
}
end_request(req, 1);
}
}
示例11: mmc_request
/*
* Generic MMC request handler. This is called for any queue on a
* particular host. When the host is not busy, we look for a request
* on any queue on this host, and attempt to issue it. This may
* not be the queue we were asked to process.
*/
static void mmc_request(struct request_queue *q)
{
struct mmc_queue *mq = q->queuedata;
struct request *req;
int ret, count = 0;
if (!mq) {
printk(KERN_ERR "MMC: killing requests for dead queue\n");
while ((req = elv_next_request(q)) != NULL) {
do {
ret = end_that_request_chunk(req, 0,
req->current_nr_sectors << 9);
count++;
if (count > 100) {
/* dequeue the request in the queue */
printk(KERN_ERR "dequeue req\n");
blkdev_dequeue_request(req);
break;
}
count++;
} while (ret);
}
return;
}
if (!mq->req)
wake_up_process(mq->thread);
}
示例12: mem_block_requeut_fn
static void mem_block_requeut_fn(struct request_queue* q)
{
struct request* req = NULL;
while(NULL != (req = elv_next_request(q)))
{
if(req -> sector + req -> current_nr_sectors > get_capacity(req->rq_disk))
{
end_request(req,0);
// return 0;
LogPath();
continue;
}
// Log("sector:%d,current_nr_sectors:%d",req->sector,req->current_nr_sectors);
switch(rq_data_dir(req))
{
case READ:
{
memcpy(req->buffer,g_mem_buf + (req->sector << 9),req->current_nr_sectors << 9);
end_request(req,1);
break;
}
case WRITE:
{
memcpy(g_mem_buf + (req->sector << 9), req->buffer,req->current_nr_sectors << 9);
end_request(req,1);
break;
}
default:
Log("[Error] Unknown request...");
break;
// return 0;
}
}
}
示例13: mbox_tx_work
static void mbox_tx_work(struct work_struct *work)
{
int ret;
struct request *rq;
struct omap_mbox_queue *mq = container_of(work,
struct omap_mbox_queue, work);
struct omap_mbox *mbox = mq->queue->queuedata;
struct request_queue *q = mbox->txq->queue;
while (1) {
spin_lock(q->queue_lock);
rq = elv_next_request(q);
spin_unlock(q->queue_lock);
if (!rq)
break;
ret = __mbox_msg_send(mbox, (mbox_msg_t) rq->data, rq->special);
if (ret) {
enable_mbox_irq(mbox, IRQ_TX);
return;
}
spin_lock(q->queue_lock);
if (__blk_end_request(rq, 0, 0))
BUG();
spin_unlock(q->queue_lock);
}
}
示例14: mbox_rx_work
/*
* Message receiver(workqueue)
*/
static void mbox_rx_work(struct work_struct *work)
{
struct omap_mbox_queue *mq =
container_of(work, struct omap_mbox_queue, work);
struct omap_mbox *mbox = mq->queue->queuedata;
struct request_queue *q = mbox->rxq->queue;
struct request *rq;
mbox_msg_t msg;
unsigned long flags;
if (mbox->rxq->callback == NULL) {
sysfs_notify(&mbox->dev.kobj, NULL, "mbox");
return;
}
while (1) {
spin_lock_irqsave(q->queue_lock, flags);
rq = elv_next_request(q);
spin_unlock_irqrestore(q->queue_lock, flags);
if (!rq)
break;
msg = (mbox_msg_t) rq->data;
if (blk_end_request(rq, 0, 0))
BUG();
mbox->rxq->callback((void *)msg);
}
}
示例15: request_exemple
static void request_exemple(request_queue_t * rqueue)
{
unsigned long secteur_debut;
unsigned long nb_secteurs;
struct request * rq;
while ((rq = elv_next_request(rqueue)) != NULL) {
if (! blk_fs_request(rq)) {
end_request(rq, 0);
continue;
}
/*
* Les numeros de secteurs pour le transfert correspondent
* a des secteurs de 512 octets... -> convertir.
*/
secteur_debut = rq->sector * 512 / lg_sect_exemple;
nb_secteurs = rq->current_nr_sectors * 512 / lg_sect_exemple;
if (secteur_debut + nb_secteurs > nb_sect_exemple) {
end_request(rq,1);
continue;
}
if (rq_data_dir(rq)) /* write */
memmove(& data_exemple[secteur_debut * lg_sect_exemple],
rq->buffer,
nb_secteurs * lg_sect_exemple);
else /* read */
memmove(rq->buffer,
& data_exemple[secteur_debut * lg_sect_exemple],
nb_secteurs * lg_sect_exemple);
end_request(rq, 1);
}
}