From ac05e613e225dee266af91661fdd7666e7ac3747 Mon Sep 17 00:00:00 2001 From: Jeremie Courreges-Anglas Date: Sun, 12 Apr 2020 17:47:26 +0000 Subject: Turn those spinlock and seqlock inline functions to macros They're macros on Linux because they save state in their flags parameter. Turning them to static inline functions creates a lot of -Wuninitialized warnings, so just use macros which set their flags argument. ok kettenis@ --- sys/dev/pci/drm/include/linux/seqlock.h | 12 ++++++++++-- sys/dev/pci/drm/include/linux/spinlock.h | 31 +++++++++++++++---------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/sys/dev/pci/drm/include/linux/seqlock.h b/sys/dev/pci/drm/include/linux/seqlock.h index 7e3ba8dc136..63490a20d93 100644 --- a/sys/dev/pci/drm/include/linux/seqlock.h +++ b/sys/dev/pci/drm/include/linux/seqlock.h @@ -99,12 +99,16 @@ write_seqlock(seqlock_t *sl) } static inline void -write_seqlock_irqsave(seqlock_t *sl, __unused long flags) +__write_seqlock_irqsave(seqlock_t *sl) { mtx_enter(&sl->lock); sl->seq++; membar_producer(); } +#define write_seqlock_irqsave(_sl, _flags) do { \ + _flags = 0; \ + __write_seqlock_irqsave(_sl); \ + } while (0) static inline void write_sequnlock(seqlock_t *sl) @@ -115,12 +119,16 @@ write_sequnlock(seqlock_t *sl) } static inline void -write_sequnlock_irqrestore(seqlock_t *sl, __unused long flags) +__write_sequnlock_irqrestore(seqlock_t *sl) { membar_producer(); sl->seq++; mtx_leave(&sl->lock); } +#define write_sequnlock_irqrestore(_sl, _flags) do { \ + (void)(_flags); \ + __write_sequnlock_irqrestore(_sl); \ + } while (0) static inline unsigned int read_seqbegin(seqlock_t *sl) diff --git a/sys/dev/pci/drm/include/linux/spinlock.h b/sys/dev/pci/drm/include/linux/spinlock.h index 14dc60ebfe2..e40d2872d00 100644 --- a/sys/dev/pci/drm/include/linux/spinlock.h +++ b/sys/dev/pci/drm/include/linux/spinlock.h @@ -8,22 +8,21 @@ #include #include -static inline void -spin_lock_irqsave(struct mutex *mtxp, __unused unsigned long flags) -{ - mtx_enter(mtxp); -} -static inline void -spin_lock_irqsave_nested(struct mutex *mtxp, __unused unsigned long flags, - __unused int subclass) -{ - mtx_enter(mtxp); -} -static inline void -spin_unlock_irqrestore(struct mutex *mtxp, __unused unsigned long flags) -{ - mtx_leave(mtxp); -} +#define spin_lock_irqsave(_mtxp, _flags) do { \ + _flags = 0; \ + mtx_enter(_mtxp); \ + } while (0) + +#define spin_lock_irqsave_nested(_mtxp, _flags, _subclass) do { \ + (void)(_subclass); \ + _flags = 0; \ + mtx_enter(_mtxp); \ + } while (0) + +#define spin_unlock_irqrestore(_mtxp, _flags) do { \ + (void)(_flags); \ + mtx_leave(_mtxp); \ + } while (0) #define spin_lock(mtxp) mtx_enter(mtxp) #define spin_lock_nested(mtxp, l) mtx_enter(mtxp) -- cgit v1.2.3