7f2e494ddd
Only used by indexer components. Also return void from uds_init_cond(), remove uds_destroy_cond(), and fix up all callers. Signed-off-by: Mike Snitzer <snitzer@kernel.org> Signed-off-by: Matthew Sakai <msakai@redhat.com>
53 lines
1.0 KiB
C
53 lines
1.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright 2023 Red Hat
|
|
*/
|
|
|
|
#ifndef THREAD_UTILS_H
|
|
#define THREAD_UTILS_H
|
|
|
|
#include <linux/atomic.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/jiffies.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/semaphore.h>
|
|
|
|
#include "errors.h"
|
|
|
|
/* Thread and synchronization utilities for UDS */
|
|
|
|
struct thread;
|
|
|
|
|
|
int __must_check uds_create_thread(void (*thread_function)(void *), void *thread_data,
|
|
const char *name, struct thread **new_thread);
|
|
|
|
void uds_perform_once(atomic_t *once_state, void (*function) (void));
|
|
|
|
int uds_join_threads(struct thread *thread);
|
|
|
|
/* FIXME: all below wrappers should be removed! */
|
|
|
|
static inline int __must_check uds_init_mutex(struct mutex *mutex)
|
|
{
|
|
mutex_init(mutex);
|
|
return UDS_SUCCESS;
|
|
}
|
|
|
|
static inline int uds_destroy_mutex(struct mutex *mutex)
|
|
{
|
|
return UDS_SUCCESS;
|
|
}
|
|
|
|
static inline void uds_lock_mutex(struct mutex *mutex)
|
|
{
|
|
mutex_lock(mutex);
|
|
}
|
|
|
|
static inline void uds_unlock_mutex(struct mutex *mutex)
|
|
{
|
|
mutex_unlock(mutex);
|
|
}
|
|
|
|
#endif /* UDS_THREADS_H */
|