unified: Eliminate thread config structure used by work queues

Reworks k_work_q_start() so that it accepts its 3 configuration
settings directly, rather than forcing the caller to pass in a
configuration data structure.

Change-Id: Ic0bd1b94f1a1c8e0f8a84b3bd3677d59d0708734
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
Allan Stephens 2016-10-07 13:59:23 -05:00 committed by Anas Nashif
commit 904cf97263
4 changed files with 19 additions and 27 deletions

View file

@ -102,12 +102,6 @@ enum execution_context_types {
K_PREEMPT_THREAD,
};
struct k_thread_config {
char *stack;
unsigned stack_size;
unsigned prio;
};
typedef void (*k_thread_entry_t)(void *p1, void *p2, void *p3);
extern k_tid_t k_thread_spawn(char *stack, unsigned stack_size,
void (*entry)(void *, void *, void*),
@ -661,8 +655,8 @@ static inline int k_work_pending(struct k_work *work)
* @brief Start a new workqueue. This routine can be called from either
* fiber or task context.
*/
extern void k_work_q_start(struct k_work_q *work_q,
const struct k_thread_config *config);
extern void k_work_q_start(struct k_work_q *work_q, char *stack,
unsigned stack_size, unsigned prio);
#if defined(CONFIG_SYS_CLOCK_EXISTS)

View file

@ -107,7 +107,11 @@ static inline nano_thread_id_t fiber_start(char *stack, unsigned stack_size,
#define fiber_fiber_start fiber_start
#define task_fiber_start fiber_start
#define fiber_config k_thread_config
struct fiber_config {
char *stack;
unsigned stack_size;
unsigned prio;
};
#define fiber_start_config(config, entry, arg1, arg2, options) \
fiber_start(config->stack, config->stack_size, \

View file

@ -73,17 +73,14 @@ int task_offload_to_fiber(int (*func)(), void *argp)
static char __stack offload_work_q_stack[CONFIG_OFFLOAD_WORKQUEUE_STACK_SIZE];
static const struct k_thread_config offload_work_q_config = {
.stack = offload_work_q_stack,
.stack_size = sizeof(offload_work_q_stack),
.prio = CONFIG_OFFLOAD_WORKQUEUE_PRIORITY,
};
static int k_offload_work_q_init(struct device *dev)
{
ARG_UNUSED(dev);
k_work_q_start(&offload_work_q, &offload_work_q_config);
k_work_q_start(&offload_work_q,
offload_work_q_stack,
sizeof(offload_work_q_stack),
CONFIG_OFFLOAD_WORKQUEUE_PRIORITY);
return 0;
}

View file

@ -52,14 +52,14 @@ static void work_q_main(void *work_q_ptr, void *p2, void *p3)
}
}
void k_work_q_start(struct k_work_q *work_q,
const struct k_thread_config *config)
void k_work_q_start(struct k_work_q *work_q, char *stack,
unsigned stack_size, unsigned prio)
{
k_fifo_init(&work_q->fifo);
k_thread_spawn(config->stack, config->stack_size,
k_thread_spawn(stack, stack_size,
work_q_main, work_q, 0, 0,
config->prio, 0, 0);
prio, 0, 0);
}
#ifdef CONFIG_SYS_CLOCK_EXISTS
@ -152,19 +152,16 @@ int k_delayed_work_cancel(struct k_delayed_work *work)
static char __stack sys_work_q_stack[CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE];
static const struct k_thread_config sys_work_q_config = {
.stack = sys_work_q_stack,
.stack_size = sizeof(sys_work_q_stack),
.prio = CONFIG_SYSTEM_WORKQUEUE_PRIORITY,
};
struct k_work_q k_sys_work_q;
static int k_sys_work_q_init(struct device *dev)
{
ARG_UNUSED(dev);
k_work_q_start(&k_sys_work_q, &sys_work_q_config);
k_work_q_start(&k_sys_work_q,
sys_work_q_stack,
sizeof(sys_work_q_stack),
CONFIG_SYSTEM_WORKQUEUE_PRIORITY);
return 0;
}