Lines Matching refs:pdev

40     event_dev_t *pdev = (event_dev_t *)aos_malloc(sizeof * pdev);  in event_open()  local
41 memset(pdev, 0, sizeof (*pdev)); in event_open()
42 aos_mutex_new(&pdev->mutex); in event_open()
43 dlist_init(&pdev->bufs); in event_open()
44 dlist_init(&pdev->buf_cache); in event_open()
45 file->f_arg = pdev; in event_open()
51 event_dev_t *pdev = file->f_arg; in event_close() local
52 aos_mutex_free(&pdev->mutex); in event_close()
54 while (!dlist_empty(&pdev->bufs)) { in event_close()
55 dlist_t *n = pdev->bufs.next; in event_close()
60 while (!dlist_empty(&pdev->buf_cache)) { in event_close()
61 dlist_t *n = pdev->buf_cache.next; in event_close()
66 aos_free(pdev); in event_close()
73 event_dev_t *pdev = f->f_arg; in _event_write() local
74 aos_mutex_lock(&pdev->mutex, AOS_WAIT_FOREVER); in _event_write()
78 evt = (dev_event_t *)pdev->buf_cache.next; in _event_write()
80 if (pdev->cache_count > 0 && evt->len == len) { in _event_write()
82 pdev->cache_count --; in _event_write()
92 pdev->counter ++; in _event_write()
97 dlist_add(&evt->node, &pdev->bufs); in _event_write()
99 dlist_add_tail(&evt->node, &pdev->bufs); in _event_write()
102 if (pdev->poll_cb != NULL) { in _event_write()
103 pdev->fd->revents |= POLLIN; in _event_write()
104 pdev->poll_cb(pdev->fd, pdev->poll_data); in _event_write()
107 aos_mutex_unlock(&pdev->mutex); in _event_write()
133 event_dev_t *pdev = f->f_arg; in event_read() local
134 int cnt = pdev->counter; in event_read()
140 aos_mutex_lock(&pdev->mutex, AOS_WAIT_FOREVER); in event_read()
142 dev_event_t *evt = (dev_event_t *)pdev->bufs.next; in event_read()
147 if (pdev->cache_count < CACHE_COUNT) { in event_read()
148 dlist_add(&evt->node, &pdev->buf_cache); in event_read()
149 pdev->cache_count ++; in event_read()
154 if (-- pdev->counter == 0) { in event_read()
155 if (pdev->fd != NULL) { in event_read()
156 pdev->fd->revents &= ~POLLIN; in event_read()
159 aos_mutex_unlock(&pdev->mutex); in event_read()
167 event_dev_t *pdev = f->f_arg; in event_poll() local
169 aos_mutex_lock(&pdev->mutex, AOS_WAIT_FOREVER); in event_poll()
171 pdev->poll_cb = NULL; in event_poll()
172 pdev->poll_data = NULL; in event_poll()
176 pdev->poll_cb = notify; in event_poll()
177 pdev->fd = (struct pollfd *)fd; in event_poll()
178 pdev->poll_data = opa; in event_poll()
180 if (pdev->counter) { in event_poll()
181 pdev->fd->revents |= POLLIN; in event_poll()
184 pdev->fd->revents &= ~POLLIN; in event_poll()
187 aos_mutex_unlock(&pdev->mutex); in event_poll()