diff options
| author | sakumisu <[email protected]> | 2022-08-12 19:42:02 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-08-12 21:34:47 +0800 |
| commit | 88f710458c01c33760e3f9e672064ce2430b03ee (patch) | |
| tree | e8a4321e154ed7c02e2ce88adacf9390766418fa /osal | |
| parent | 5c8c6d6ec2c6c2b068dcbbfe764e99f84a100ab3 (diff) | |
delete workq
Diffstat (limited to 'osal')
| -rw-r--r-- | osal/usb_workq.c | 120 | ||||
| -rw-r--r-- | osal/usb_workq.h | 49 |
2 files changed, 0 insertions, 169 deletions
diff --git a/osal/usb_workq.c b/osal/usb_workq.c deleted file mode 100644 index 99dfd112..00000000 --- a/osal/usb_workq.c +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file usb_workq.c - * @brief - * - * Copyright (c) 2022 sakumisu - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - */ -#include "usb_list.h" -#include "usb_osal.h" -#include "usb_workq.h" -#include "usb_config.h" - -void usb_workqueue_submit(struct usb_workqueue *queue, struct usb_work *work, usb_worker_t worker, void *arg, uint32_t ticks) -{ - size_t flags; - flags = usb_osal_enter_critical_section(); - usb_dlist_remove(&work->list); - work->worker = worker; - work->arg = arg; - - if (ticks == 0) { - usb_dlist_insert_after(&queue->work_list, &work->list); - usb_osal_sem_give(queue->sem); - } - - usb_osal_leave_critical_section(flags); -} - -struct usb_workqueue g_hpworkq = { NULL }; -struct usb_workqueue g_lpworkq = { NULL }; - -#ifdef CONFIG_USBHOST_HIGH_WORKQ -static void usbh_hpwork_thread(void *argument) -{ - struct usb_work *work; - size_t flags; - int ret; - struct usb_workqueue *queue = (struct usb_workqueue *)argument; - while (1) { - ret = usb_osal_sem_take(queue->sem, 0xffffffff); - if (ret < 0) { - continue; - } - flags = usb_osal_enter_critical_section(); - if (usb_dlist_isempty(&queue->work_list)) { - usb_osal_leave_critical_section(flags); - continue; - } - work = usb_dlist_first_entry(&queue->work_list, struct usb_work, list); - usb_dlist_remove(&work->list); - usb_osal_leave_critical_section(flags); - work->worker(work->arg); - } -} -#endif -#ifdef CONFIG_USBHOST_LOW_WORKQ -static void usbh_lpwork_thread(void *argument) -{ - struct usb_work *work; - size_t flags; - int ret; - struct usb_workqueue *queue = (struct usb_workqueue *)argument; - while (1) { - ret = usb_osal_sem_take(queue->sem, 0xffffffff); - if (ret < 0) { - continue; - } - flags = usb_osal_enter_critical_section(); - if (usb_dlist_isempty(&queue->work_list)) { - usb_osal_leave_critical_section(flags); - continue; - } - work = usb_dlist_first_entry(&queue->work_list, struct usb_work, list); - usb_dlist_remove(&work->list); - usb_osal_leave_critical_section(flags); - work->worker(work->arg); - } -} -#endif - -int usbh_workq_initialize(void) -{ -#ifdef CONFIG_USBHOST_HIGH_WORKQ - g_hpworkq.sem = usb_osal_sem_create(0); - if (g_hpworkq.sem == NULL) { - return -1; - } - g_hpworkq.thread = usb_osal_thread_create("usbh_hpworkq", CONFIG_USBHOST_HPWORKQ_STACKSIZE, CONFIG_USBHOST_HPWORKQ_PRIO, usbh_hpwork_thread, &g_hpworkq); - if (g_hpworkq.thread == NULL) { - return -1; - } -#endif -#ifdef CONFIG_USBHOST_LOW_WORKQ - g_lpworkq.sem = usb_osal_sem_create(0); - if (g_lpworkq.sem == NULL) { - return -1; - } - - g_lpworkq.thread = usb_osal_thread_create("usbh_lpworkq", CONFIG_USBHOST_LPWORKQ_STACKSIZE, CONFIG_USBHOST_LPWORKQ_PRIO, usbh_lpwork_thread, &g_lpworkq); - if (g_lpworkq.thread == NULL) { - return -1; - } -#endif - return 0; -} diff --git a/osal/usb_workq.h b/osal/usb_workq.h deleted file mode 100644 index 0c3707dd..00000000 --- a/osal/usb_workq.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @file usb_workq.h - * @brief - * - * Copyright (c) 2022 sakumisu - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - */ -#ifndef _USB_WORKQUEUE_H -#define _USB_WORKQUEUE_H - -/* Defines the work callback */ -typedef void (*usb_worker_t)(void *arg); - -struct usb_work -{ - usb_dlist_t list; - usb_worker_t worker; - void *arg; -}; - -struct usb_workqueue -{ - usb_dlist_t work_list; - usb_dlist_t delay_work_list; - usb_osal_sem_t sem; - usb_osal_thread_t thread; -}; - -extern struct usb_workqueue g_hpworkq; -extern struct usb_workqueue g_lpworkq; - -void usb_workqueue_submit(struct usb_workqueue *queue, struct usb_work *work, usb_worker_t worker, void *arg, uint32_t ticks); -int usbh_workq_initialize(); -#endif |
