diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-06-28 09:07:30 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-06-28 14:44:31 +0200 |
commit | c32343519de1774c09995118d0bae56999902a37 (patch) | |
tree | 2c923abf526e3f743b75da34e9dd2bd3493fb581 /common | |
parent | 57313f83e83e1fac87c1a9088175f12ebd3577a0 (diff) | |
download | barebox-c32343519de1774c09995118d0bae56999902a37.tar.gz barebox-c32343519de1774c09995118d0bae56999902a37.tar.xz |
bthread: remove thread exit codes
Follow-up commit will replace blocking bthread_stop with non-blocking
bthread_cancel. Prepare for this by dropping exit codes. This is not
much of a loss, because most users of bthreads will only call
bthread_stop at cleanup time. bthread command is an exception, so have
it take manual care of passing around exit codes.
As we touch the bthread_stop prototype anyway, rename it to
__bthread_stop. This will make it clearer in the future, that it's not
meant for driver use.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210628070732.16812-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/bthread.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/common/bthread.c b/common/bthread.c index 80651344da..48248dfad4 100644 --- a/common/bthread.c +++ b/common/bthread.c @@ -20,11 +20,8 @@ #endif static struct bthread { - int (*threadfn)(void *); - union { - void *data; - int ret; - }; + void (*threadfn)(void *); + void *data; char *name; jmp_buf jmp_buf; void *stack; @@ -54,7 +51,7 @@ static void __noreturn bthread_trampoline(void) finish_switch_fiber(current); bthread_reschedule(); - current->ret = current->threadfn(current->data); + current->threadfn(current->data); bthread_suspend(current); current->has_stopped = true; @@ -81,7 +78,7 @@ const char *bthread_name(struct bthread *bthread) return bthread->name; } -struct bthread *bthread_create(int (*threadfn)(void *), void *data, +struct bthread *bthread_create(void (*threadfn)(void *), void *data, const char *namefmt, ...) { struct bthread *bthread; @@ -117,6 +114,11 @@ err: return NULL; } +void *bthread_data(struct bthread *bthread) +{ + return bthread->data; +} + void bthread_wake(struct bthread *bthread) { if (bthread->awake) @@ -133,14 +135,12 @@ void bthread_suspend(struct bthread *bthread) list_del(&bthread->list); } -int bthread_stop(struct bthread *bthread) +void __bthread_stop(struct bthread *bthread) { bthread->should_stop = true; while (!bthread->has_stopped) bthread_reschedule(); - - return bthread->ret; } int bthread_should_stop(void) |