diff options
author | Darrick J. Wong <djwong@kernel.org> | 2024-02-10 11:23:01 -0800 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-15 19:45:41 -0500 |
commit | 41fabbfc56cb7e6e891ef05042f668a7473a55a2 (patch) | |
tree | 3d82943289c9e87f3ec6721fd57a844c42be8a2d /lib/thread_with_file.c | |
parent | 45439fea63e241dd34e5ed9fdc600787d5898792 (diff) |
thread_with_file: create ops structure for thread_with_stdio
Create an ops structure so we can add more file-based functionality in
the next few patches.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'lib/thread_with_file.c')
-rw-r--r-- | lib/thread_with_file.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/thread_with_file.c b/lib/thread_with_file.c index 70a805ef017f..2edf33c3e7dc 100644 --- a/lib/thread_with_file.c +++ b/lib/thread_with_file.c @@ -359,7 +359,7 @@ static int thread_with_stdio_release(struct inode *inode, struct file *file) thread_with_file_exit(&thr->thr); darray_exit(&thr->stdio.input.buf); darray_exit(&thr->stdio.output.buf); - thr->exit(thr); + thr->ops->exit(thr); return 0; } @@ -398,33 +398,29 @@ static int thread_with_stdio_fn(void *arg) { struct thread_with_stdio *thr = arg; - thr->fn(thr); + thr->ops->fn(thr); thread_with_stdio_done(thr); return 0; } int run_thread_with_stdio(struct thread_with_stdio *thr, - void (*exit)(struct thread_with_stdio *), - void (*fn)(struct thread_with_stdio *)) + const struct thread_with_stdio_ops *ops) { stdio_buf_init(&thr->stdio.input); stdio_buf_init(&thr->stdio.output); - thr->exit = exit; - thr->fn = fn; + thr->ops = ops; return run_thread_with_file(&thr->thr, &thread_with_stdio_fops, thread_with_stdio_fn); } EXPORT_SYMBOL_GPL(run_thread_with_stdio); int run_thread_with_stdout(struct thread_with_stdio *thr, - void (*exit)(struct thread_with_stdio *), - void (*fn)(struct thread_with_stdio *)) + const struct thread_with_stdio_ops *ops) { stdio_buf_init(&thr->stdio.input); stdio_buf_init(&thr->stdio.output); - thr->exit = exit; - thr->fn = fn; + thr->ops = ops; return run_thread_with_file(&thr->thr, &thread_with_stdout_fops, thread_with_stdio_fn); } |