本文整理汇总了C++中poll_wait函数的典型用法代码示例。如果您正苦于以下问题:C++ poll_wait函数的具体用法?C++ poll_wait怎么用?C++ poll_wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了poll_wait函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mei_poll
/**
* mei_poll - the poll function
*
* @file: pointer to file structure
* @wait: pointer to poll_table structure
*
* Return: poll mask
*/
static unsigned int mei_poll(struct file *file, poll_table *wait)
{
unsigned long req_events = poll_requested_events(wait);
struct mei_cl *cl = file->private_data;
struct mei_device *dev;
unsigned int mask = 0;
if (WARN_ON(!cl || !cl->dev))
return POLLERR;
dev = cl->dev;
mutex_lock(&dev->device_lock);
if (dev->dev_state != MEI_DEV_ENABLED ||
!mei_cl_is_connected(cl)) {
mask = POLLERR;
goto out;
}
if (cl == &dev->iamthif_cl) {
mask = mei_amthif_poll(dev, file, wait);
goto out;
}
if (req_events & (POLLIN | POLLRDNORM)) {
poll_wait(file, &cl->rx_wait, wait);
if (!list_empty(&cl->rd_completed))
mask |= POLLIN | POLLRDNORM;
else
mei_cl_read_start(cl, 0, file);
}
out:
mutex_unlock(&dev->device_lock);
return mask;
}
示例2: datagram_poll
/**
* datagram_poll - generic datagram poll
* @file: file struct
* @sock: socket
* @wait: poll table
*
* Datagram poll: Again totally generic. This also handles
* sequenced packet sockets providing the socket receive queue
* is only ever holding data ready to receive.
*
* Note: when you _don't_ use this routine for this protocol,
* and you use a different write policy from sock_writeable()
* then please supply your own write_space callback.
*/
unsigned int datagram_poll(struct file *file, struct socket *sock,
poll_table *wait)
{
struct sock *sk = sock->sk;
unsigned int mask;
poll_wait(file, sk->sk_sleep, wait);
mask = 0;
/* exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP;
if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= POLLHUP;
/* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue) ||
(sk->sk_shutdown & RCV_SHUTDOWN))
mask |= POLLIN | POLLRDNORM;
/* Connection-based need to check for termination and startup */
if (connection_based(sk)) {
if (sk->sk_state == TCP_CLOSE)
mask |= POLLHUP;
/* connection hasn't started yet? */
if (sk->sk_state == TCP_SYN_SENT)
return mask;
}
/* writable? */
if (sock_writeable(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
else
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
return mask;
}
示例3: vb2_poll
unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
{
unsigned long flags;
unsigned int ret;
struct vb2_buffer *vb = NULL;
if (q->num_buffers == 0 && q->fileio == NULL) {
if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)) {
ret = __vb2_init_fileio(q, 1);
if (ret)
return POLLERR;
}
if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)) {
ret = __vb2_init_fileio(q, 0);
if (ret)
return POLLERR;
return POLLOUT | POLLWRNORM;
}
}
if (list_empty(&q->queued_list))
return POLLERR;
poll_wait(file, &q->done_wq, wait);
spin_lock_irqsave(&q->done_lock, flags);
if (!list_empty(&q->done_list))
vb = list_first_entry(&q->done_list, struct vb2_buffer,
done_entry);
spin_unlock_irqrestore(&q->done_lock, flags);
if (vb && (vb->state == VB2_BUF_STATE_DONE
|| vb->state == VB2_BUF_STATE_ERROR)) {
return (V4L2_TYPE_IS_OUTPUT(q->type)) ? POLLOUT | POLLWRNORM :
POLLIN | POLLRDNORM;
}
return 0;
}
示例4: microdia_queue_poll
/**
* @brief Poll the video queue.
*
* @param queue
* @param file
* @param wait
*
* This function implements video queue polling and is intended to be used by
* the device poll handler.
*/
unsigned int microdia_queue_poll(struct microdia_video_queue *queue,
struct file *file, poll_table *wait)
{
struct microdia_buffer *buf;
unsigned int mask = 0;
mutex_lock(&queue->mutex);
if (list_empty(&queue->mainqueue)) {
mask |= POLLERR;
goto done;
}
buf = list_first_entry(&queue->mainqueue, struct microdia_buffer,
stream);
poll_wait(file, &buf->wait, wait);
if (buf->state == MICRODIA_BUF_STATE_DONE ||
buf->state == MICRODIA_BUF_STATE_ERROR)
mask |= POLLIN | POLLRDNORM;
done:
mutex_unlock(&queue->mutex);
return mask;
}
示例5: dvb_demux_poll
static unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
{
struct dmxdev_filter *dmxdevfilter = dvb_dmxdev_file_to_filter(file);
unsigned int mask = 0;
if (!dmxdevfilter)
return -EINVAL;
poll_wait(file, &dmxdevfilter->buffer.queue, wait);
if (dmxdevfilter->state != DMXDEV_STATE_GO &&
dmxdevfilter->state != DMXDEV_STATE_DONE &&
dmxdevfilter->state != DMXDEV_STATE_TIMEDOUT)
return 0;
if (dmxdevfilter->buffer.error)
mask |= (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
if (dmxdevfilter->buffer.pread != dmxdevfilter->buffer.pwrite)
mask |= (POLLIN | POLLRDNORM | POLLPRI);
return mask;
}
示例6: goldfish_pipe_poll
static __poll_t goldfish_pipe_poll(struct file *filp, poll_table *wait)
{
struct goldfish_pipe *pipe = filp->private_data;
__poll_t mask = 0;
int status;
poll_wait(filp, &pipe->wake_queue, wait);
status = goldfish_pipe_cmd(pipe, PIPE_CMD_POLL);
if (status < 0)
return -ERESTARTSYS;
if (status & PIPE_POLL_IN)
mask |= EPOLLIN | EPOLLRDNORM;
if (status & PIPE_POLL_OUT)
mask |= EPOLLOUT | EPOLLWRNORM;
if (status & PIPE_POLL_HUP)
mask |= EPOLLHUP;
if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))
mask |= EPOLLERR;
return mask;
}
示例7: chardev_poll
/**
* @brief poll handler for char dev
*
* @param filp pointer to structure file
* @param wait pointer to poll_table structure
* @return mask
*/
static unsigned int
chardev_poll(struct file *filp, poll_table * wait)
{
unsigned int mask;
struct char_dev *dev = (struct char_dev *)filp->private_data;
struct m_dev *m_dev = NULL;
ENTER();
if (!dev || !dev->m_dev) {
LEAVE();
return -ENXIO;
}
m_dev = dev->m_dev;
poll_wait(filp, &m_dev->req_wait_q, wait);
mask = POLLOUT | POLLWRNORM;
if (skb_peek(&m_dev->rx_q))
mask |= POLLIN | POLLRDNORM;
if (!test_bit(HCI_UP, &(m_dev->flags)))
mask |= POLLHUP;
PRINTM(INFO, "poll mask=0x%x\n", mask);
LEAVE();
return mask;
}
示例8: co_os_manager_poll
static
unsigned int co_os_manager_poll(struct file *file, struct poll_table_struct *pollts)
{
co_manager_open_desc_t opened = (typeof(opened))(file->private_data);
unsigned int mask = POLLOUT | POLLWRNORM, size;
co_queue_t *queue;
co_os_mutex_acquire(opened->lock);
queue = &opened->out_queue;
size = co_queue_size(queue);
co_os_mutex_release(opened->lock);
poll_wait(file, &opened->os->waitq, pollts);
if (size)
mask |= POLLIN | POLLRDNORM;
if (!opened->active)
mask |= POLLHUP;
return mask;
}
示例9: plog_poll
// We need to support this function if we want the select() call to behave
// properly on this file.
static unsigned int plog_poll(struct file *file, poll_table * wait)
{
unsigned int readable;
plog_reader *s = (plog_reader*) file->private_data;
monotonic_ptr file_rp = s->read_ptr;
unsigned long flags;
poll_wait(file, &plog_wait, wait);
spin_lock_irqsave(&s_lock, flags);
readable = plog_readable(file_rp);
spin_unlock_irqrestore(&s_lock, flags);
// If there is 4096 bytes, you can read data.
if (readable >= 4096)
{
return POLLIN | POLLRDNORM;
}
return 0;
}
示例10: proc_sys_poll
static unsigned int proc_sys_poll(struct file *filp, poll_table *wait)
{
struct inode *inode = filp->f_path.dentry->d_inode;
struct ctl_table *table = PROC_I(inode)->sysctl_entry;
unsigned long event = (unsigned long)filp->private_data;
unsigned int ret = DEFAULT_POLLMASK;
if (!table->proc_handler)
goto out;
if (!table->poll)
goto out;
poll_wait(filp, &table->poll->wait, wait);
if (event != atomic_read(&table->poll->event)) {
filp->private_data = proc_sys_poll_event(table->poll);
ret = POLLIN | POLLRDNORM | POLLERR | POLLPRI;
}
out:
return ret;
}
示例11: normal_poll
static unsigned int normal_poll(struct tty_struct * tty, struct file * file, poll_table *wait)
{
unsigned int mask = 0;
poll_wait(file, &tty->poll_wait, wait);
if (input_available_p(tty, TIME_CHAR(tty) ? 0 : MIN_CHAR(tty)))
mask |= POLLIN | POLLRDNORM;
if (tty->packet && tty->link->ctrl_status)
mask |= POLLPRI | POLLIN | POLLRDNORM;
if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
mask |= POLLHUP;
if (tty_hung_up_p(file))
mask |= POLLHUP;
if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) {
if (MIN_CHAR(tty) && !TIME_CHAR(tty))
tty->minimum_to_wake = MIN_CHAR(tty);
else
tty->minimum_to_wake = 1;
}
if (tty->driver.chars_in_buffer(tty) < WAKEUP_CHARS)
mask |= POLLOUT | POLLWRNORM;
return mask;
}
示例12: dvb_demux_poll
static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
{
struct dmxdev_filter *dmxdevfilter = file->private_data;
unsigned int mask = 0;
if (!dmxdevfilter)
return -EINVAL;
poll_wait(file, &dmxdevfilter->buffer.queue, wait);
if (dmxdevfilter->state != DMXDEV_STATE_GO &&
dmxdevfilter->state != DMXDEV_STATE_DONE &&
dmxdevfilter->state != DMXDEV_STATE_TIMEDOUT)
return 0;
if (dmxdevfilter->buffer.error)
mask |= (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
if (!dvb_ringbuffer_empty(&dmxdevfilter->buffer))
mask |= (POLLIN | POLLRDNORM | POLLPRI);
return mask;
}
示例13: rawchip_fops_poll
static unsigned int rawchip_fops_poll(struct file *filp,
struct poll_table_struct *pll_table)
{
int rc = 0;
unsigned long flags;
poll_wait(filp, &yushan_int.yushan_wait, pll_table);
spin_lock_irqsave(&yushan_int.yushan_spin_lock, flags);
if (atomic_read(&interrupt)) {
atomic_set(&interrupt, 0);
atomic_set(&rawchipCtrl->check_intr0, 1);
rc = POLLIN | POLLRDNORM;
}
if (atomic_read(&interrupt2)) {
atomic_set(&interrupt2, 0);
atomic_set(&rawchipCtrl->check_intr1, 1);
rc = POLLIN | POLLRDNORM;
}
spin_unlock_irqrestore(&yushan_int.yushan_spin_lock, flags);
return rc;
}
示例14: avSync_device_poll
static unsigned int avSync_device_poll(struct file *file, struct poll_table_struct *wait)
{
isil_avSync_dev_t *dev;
unsigned int mask = 0;
dev = (isil_avSync_dev_t*)file->private_data;
if (dev == NULL) {
printk("[%s]:video_dev is null\n", __FUNCTION__);
return -ENODEV;
}
down(&dev->sem);
if(atomic_read(&dev->opened_flags)) {
poll_wait(file, &dev->wait_poll, wait);
if(dev->avSync_frame_queue.op->get_curr_queue_entry_number(&dev->avSync_frame_queue)){
mask = POLLIN | POLLRDNORM;
}
} else {
printk("%s:%s have not been opened\n", __FUNCTION__, dev->name);
mask = POLLOUT | POLLWRNORM | POLLIN | POLLRDNORM;
}
up(&dev->sem);
return mask;
}
示例15: rmnet_ctl_poll
static unsigned int rmnet_ctl_poll(struct file *file, poll_table *wait)
{
unsigned int mask = 0;
struct rmnet_ctrl_dev *dev;
dev = file->private_data;
if (!dev)
return POLLERR;
poll_wait(file, &dev->read_wait_queue, wait);
if (!is_dev_connected(dev)) {
dev_dbg(dev->devicep, "%s: Device not connected\n",
__func__);
return POLLERR;
}
if (!list_empty(&dev->rx_list)) {
poll_time = cpu_clock(smp_processor_id());
rd_poll_delta_time = poll_time - rd_cb_time;
mask |= POLLIN | POLLRDNORM;
}
return mask;
}