diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2022-10-13 18:36:24 -0700 |
---|---|---|
committer | Mark Gross <markgross@kernel.org> | 2022-10-13 18:40:20 -0700 |
commit | 0bb4cb66b0ed194bd443a21fded24da919cd8cc5 (patch) | |
tree | 7397da0363da839b53ae6d60800b43d574e72397 | |
parent | 2ba8778e2b30c114a4c9902c6f3ead2aa2b66f39 (diff) | |
download | linux-v4.9-rt-next.tar.gz |
[PATCH] local_lock: Provide INIT_LOCAL_LOCK().v4.9-rt-next
The original code was using INIT_LOCAL_LOCK() and I tried to sneak
around it and forgot that this code also needs to compile on !RT
platforms.
Provide INIT_LOCAL_LOCK() to initialize properly on RT and do nothing on
!RT. Let random.c use which is the only user so far and oes not compile
on !RT otherwise.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-rw-r--r-- | drivers/char/random.c | 4 | ||||
-rw-r--r-- | include/linux/locallock.h | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index daea466812fedc..86c475f70343db 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -236,7 +236,7 @@ struct crng { static DEFINE_PER_CPU(struct crng, crngs) = { .generation = ULONG_MAX, - .lock.lock = __SPIN_LOCK_UNLOCKED(crngs.lock.lock), + .lock = INIT_LOCAL_LOCK(crngs.lock), }; /* Used by crng_reseed() and crng_make_state() to extract a new seed from the input pool. */ @@ -515,7 +515,7 @@ struct batch_ ##type { \ }; \ \ static DEFINE_PER_CPU(struct batch_ ##type, batched_entropy_ ##type) = { \ - .lock.lock = __SPIN_LOCK_UNLOCKED(batched_entropy_ ##type.lock.lock), \ + .lock = INIT_LOCAL_LOCK(batched_entropy_ ##type.lock), \ .position = UINT_MAX \ }; \ \ diff --git a/include/linux/locallock.h b/include/linux/locallock.h index 0c3ff5b23f6a18..70af9a177197e5 100644 --- a/include/linux/locallock.h +++ b/include/linux/locallock.h @@ -22,6 +22,8 @@ struct local_irq_lock { unsigned long flags; }; +#define INIT_LOCAL_LOCK(lvar) { .lock = __SPIN_LOCK_UNLOCKED((lvar).lock.lock) } + #define DEFINE_LOCAL_IRQ_LOCK(lvar) \ DEFINE_PER_CPU(struct local_irq_lock, lvar) = { \ .lock = __SPIN_LOCK_UNLOCKED((lvar).lock) } @@ -256,6 +258,9 @@ static inline int __local_unlock_irqrestore(struct local_irq_lock *lv, #else /* PREEMPT_RT_BASE */ +struct local_irq_lock { }; +#define INIT_LOCAL_LOCK(lvar) { } + #define DEFINE_LOCAL_IRQ_LOCK(lvar) __typeof__(const int) lvar #define DECLARE_LOCAL_IRQ_LOCK(lvar) extern __typeof__(const int) lvar |