Lines Matching refs:pdev

37     epoll_dev_t *pdev = NULL;  in lwip_epoll_notify()  local
44 pdev = item->epoll; in lwip_epoll_notify()
45 if (pdev == NULL) { in lwip_epoll_notify()
49 aos_mutex_lock(&pdev->evt_mutex, AOS_WAIT_FOREVER); in lwip_epoll_notify()
53 dlist_add(&item->link_node, &pdev->ready_list); in lwip_epoll_notify()
56 aos_event_set(&pdev->event, EVENT_FLAG, AOS_EVENT_OR_CLEAR); in lwip_epoll_notify()
63 aos_mutex_unlock(&pdev->evt_mutex); in lwip_epoll_notify()
69 epoll_dev_t *pdev = NULL; in vfs_epoll_notify() local
76 pdev = item->epoll; in vfs_epoll_notify()
77 if (pdev == NULL) { in vfs_epoll_notify()
81 aos_mutex_lock(&pdev->evt_mutex, AOS_WAIT_FOREVER); in vfs_epoll_notify()
85 dlist_add(&item->link_node, &pdev->ready_list); in vfs_epoll_notify()
88 aos_event_set(&pdev->event, EVENT_FLAG, AOS_EVENT_OR_CLEAR); in vfs_epoll_notify()
90 aos_mutex_unlock(&pdev->evt_mutex); in vfs_epoll_notify()
142 epoll_dev_t *pdev = malloc(sizeof(epoll_dev_t)); in epoll_open() local
143 if (pdev == NULL) { in epoll_open()
148 memset(pdev, 0, sizeof(epoll_dev_t)); in epoll_open()
150 ret = aos_mutex_new(&pdev->rbt_mutex); in epoll_open()
154 ret = aos_mutex_new(&pdev->evt_mutex); in epoll_open()
158 ret = aos_event_new(&pdev->event, 0); in epoll_open()
164 pdev->rb_tree = RBT_ROOT; in epoll_open()
165 dlist_init(&pdev->ready_list); in epoll_open()
167 file->f_arg = pdev; in epoll_open()
172 if (*(aos_mutex_t*)(&(pdev->rbt_mutex))) { in epoll_open()
173 aos_mutex_free(&pdev->rbt_mutex); in epoll_open()
175 if (*(aos_mutex_t*)(&(pdev->evt_mutex))) { in epoll_open()
176 aos_mutex_free(&pdev->evt_mutex); in epoll_open()
178 if (*(aos_event_t*)(&(pdev->event))) in epoll_open()
180 aos_event_free(&pdev->event); in epoll_open()
183 free(pdev); in epoll_open()
190 epoll_dev_t *pdev = file->f_arg; in epoll_close() local
194 if (pdev == NULL) { in epoll_close()
198 aos_mutex_lock(&pdev->rbt_mutex, AOS_WAIT_FOREVER); in epoll_close()
199 dlist_for_each_entry_safe(&pdev->ready_list, tmp, node, epoll_item_t, link_node) { in epoll_close()
203 k_rbtree_postorder_for_each_entry_safe(node, rb_tmp, &pdev->rb_tree, tree_node) { in epoll_close()
205 k_rbtree_erase(&node->tree_node, &pdev->rb_tree); in epoll_close()
209 aos_mutex_unlock(&pdev->rbt_mutex); in epoll_close()
211 if (*(aos_mutex_t*)(&(pdev->rbt_mutex))) { in epoll_close()
212 aos_mutex_free(&pdev->rbt_mutex); in epoll_close()
214 if (*(aos_mutex_t*)(&(pdev->evt_mutex))) { in epoll_close()
215 aos_mutex_free(&pdev->evt_mutex); in epoll_close()
217 if (*(aos_event_t*)(&(pdev->event))) in epoll_close()
219 aos_event_free(&pdev->event); in epoll_close()
222 free(pdev); in epoll_close()
241 static int epoll_control(epoll_dev_t *pdev, epoll_ctl_data_t *data) in epoll_control() argument
245 aos_mutex_lock(&pdev->rbt_mutex, AOS_WAIT_FOREVER); in epoll_control()
249 item = rbr_find(&pdev->rb_tree, data->fd); in epoll_control()
261 if (epoll_set_item(item, pdev, data) < 0) { in epoll_control()
266 ret = rbt_insert(&pdev->rb_tree, item); in epoll_control()
275 rbt_delete(&pdev->rb_tree, data->fd); in epoll_control()
287 dlist_for_each_entry_safe(&pdev->ready_list, tmp, node, epoll_item_t, link_node) { in epoll_control()
292 ret = rbt_delete(&pdev->rb_tree, data->fd); in epoll_control()
303 item = rbr_find(&pdev->rb_tree, data->fd); in epoll_control()
309 aos_mutex_lock(&pdev->evt_mutex, AOS_WAIT_FOREVER); in epoll_control()
311 aos_mutex_unlock(&pdev->evt_mutex); in epoll_control()
316 aos_mutex_unlock(&pdev->rbt_mutex); in epoll_control()
320 static int epoll_waitting(epoll_dev_t *pdev, epoll_wait_data_t *data) in epoll_waitting() argument
327 aos_mutex_lock(&pdev->rbt_mutex, AOS_WAIT_FOREVER); in epoll_waitting()
328 dlist_for_each_entry_safe(&pdev->ready_list, tmp, node, epoll_item_t, link_node) { in epoll_waitting()
334 aos_mutex_lock(&pdev->evt_mutex, AOS_WAIT_FOREVER); in epoll_waitting()
336 aos_mutex_unlock(&pdev->evt_mutex); in epoll_waitting()
348 aos_mutex_lock(&pdev->evt_mutex, AOS_WAIT_FOREVER); in epoll_waitting()
353 aos_mutex_unlock(&pdev->evt_mutex); in epoll_waitting()
368 aos_mutex_unlock(&pdev->evt_mutex); in epoll_waitting()
373 aos_mutex_unlock(&pdev->rbt_mutex); in epoll_waitting()
378 aos_event_get(&pdev->event, EVENT_FLAG, AOS_EVENT_OR_CLEAR, &real_flag, data->timeout); in epoll_waitting()
380 aos_mutex_lock(&pdev->rbt_mutex, AOS_WAIT_FOREVER); in epoll_waitting()
381 dlist_for_each_entry_safe(&pdev->ready_list, tmp, node, epoll_item_t, link_node) { in epoll_waitting()
395 aos_mutex_lock(&pdev->evt_mutex, AOS_WAIT_FOREVER); in epoll_waitting()
401 aos_mutex_unlock(&pdev->evt_mutex); in epoll_waitting()
416 aos_mutex_unlock(&pdev->evt_mutex); in epoll_waitting()
422 aos_mutex_unlock(&pdev->rbt_mutex); in epoll_waitting()
431 epoll_dev_t *pdev = f->f_arg; in epoll_ioctl() local
432 if (pdev == NULL || arg == 0) { in epoll_ioctl()
438 return epoll_control(pdev, (epoll_ctl_data_t *)arg); in epoll_ioctl()
440 return epoll_waitting(pdev, (epoll_wait_data_t *)arg); in epoll_ioctl()