-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
static int serial_fops_poll(struct dfs_file *fd, struct rt_pollreq *req)
{
int mask = 0;
int flags = 0;
rt_device_t device;
struct rt_serial_device *serial;
device = (rt_device_t)fd->vnode->data;
RT_ASSERT(device != RT_NULL);
serial = (struct rt_serial_device *)device;
/* only support POLLIN */
flags = fd->flags & O_ACCMODE;
if (flags == O_RDONLY || flags == O_RDWR)
{
rt_base_t level;
struct rt_serial_rx_fifo* rx_fifo;
rt_poll_add(&(device->wait_queue), req);
rx_fifo = (struct rt_serial_rx_fifo*) serial->serial_rx;
level = rt_spin_lock_irqsave(&(serial->spinlock));
if ((rx_fifo->get_index != rx_fifo->put_index) || (rx_fifo->get_index == rx_fifo->put_index && rx_fifo->is_full == RT_TRUE))
mask |= POLLIN;
rt_spin_unlock_irqrestore(&(serial->spinlock), level);
}
mask|=POLLOUT;
return mask;
}
Metadata
Metadata
Assignees
Labels
No labels