Skip to content

Commit

Permalink
linuxkpi: rwlock: Simplify code
Browse files Browse the repository at this point in the history
Just use a typedef for rwlock_t, no need to create a useless
structure.

Reviewed by:		bz
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D45206
  • Loading branch information
evadot committed May 16, 2024
1 parent ae38a1a commit 5c0a192
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions sys/compat/linuxkpi/common/include/linux/rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@
#include <sys/rwlock.h>
#include <sys/libkern.h>

typedef struct {
struct rwlock rw;
} rwlock_t;
typedef struct rwlock rwlock_t;

#define read_lock(_l) rw_rlock(&(_l)->rw)
#define write_lock(_l) rw_wlock(&(_l)->rw)
#define read_unlock(_l) rw_runlock(&(_l)->rw)
#define write_unlock(_l) rw_wunlock(&(_l)->rw)
#define read_lock(_l) rw_rlock(_l)
#define write_lock(_l) rw_wlock(_l)
#define read_unlock(_l) rw_runlock(_l)
#define write_unlock(_l) rw_wunlock(_l)
#define read_lock_irq(lock) read_lock((lock))
#define read_unlock_irq(lock) read_unlock((lock))
#define write_lock_irq(lock) write_lock((lock))
Expand All @@ -54,13 +52,6 @@ typedef struct {
do { read_unlock(lock); } while (0)
#define write_unlock_irqrestore(lock, flags) \
do { write_unlock(lock); } while (0)

static inline void
rwlock_init(rwlock_t *lock)
{

memset(&lock->rw, 0, sizeof(lock->rw));
rw_init_flags(&lock->rw, "lnxrw", RW_NOWITNESS);
}
#define rwlock_init(_l) rw_init_flags(_l, "lnxrw", RW_NOWITNESS)

#endif /* _LINUXKPI_LINUX_RWLOCK_H_ */

0 comments on commit 5c0a192

Please sign in to comment.