diff mbox

backports: provide backport for setup_deferrable_timer()

Message ID 1489140070-29878-1-git-send-email-arend.vanspriel@broadcom.com (mailing list archive)
State Accepted
Headers show

Commit Message

Arend van Spriel March 10, 2017, 10:01 a.m. UTC
Since commit f8f118ceaa56 ("mac80211: Use setup_timer instead of
init_timer") mac80211 needs setup_deferrable_timer() which is not
available in older kernels. Provide a backport in linux/timer.h.
Really need two flavors of backport to support up to 3.0 kernel.

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
Hit another one last night so here it is.

Regards,
Arend
---
 backport/backport-include/linux/timer.h | 35 +++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 backport/backport-include/linux/timer.h

Comments

Johannes Berg March 31, 2017, 7:30 a.m. UTC | #1
On Fri, 2017-03-10 at 10:01 +0000, Arend van Spriel wrote:
> Since commit f8f118ceaa56 ("mac80211: Use setup_timer instead of
> init_timer") mac80211 needs setup_deferrable_timer() which is not
> available in older kernels. Provide a backport in linux/timer.h.
> Really need two flavors of backport to support up to 3.0 kernel.
> 
Applied.

johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox

Patch

diff --git a/backport/backport-include/linux/timer.h b/backport/backport-include/linux/timer.h
new file mode 100644
index 0000000..df560a2
--- /dev/null
+++ b/backport/backport-include/linux/timer.h
@@ -0,0 +1,35 @@ 
+#ifndef _BACKPORT_TIMER_H
+#define _BACKPORT_TIMER_H
+
+#include_next <linux/timer.h>
+
+#ifndef setup_deferrable_timer
+/*
+ * The TIMER_DEFERRABLE flag has not been around since 3.0 so
+ * two different backports are needed here.
+ */
+#ifdef TIMER_DEFERRABLE
+#define setup_deferrable_timer(timer, fn, data)                         \
+        __setup_timer((timer), (fn), (data), TIMER_DEFERRABLE)
+#else
+static inline void setup_deferrable_timer_key(struct timer_list *timer,
+					      const char *name,
+					      struct lock_class_key *key,
+					      void (*func)(unsigned long),
+					      unsigned long data)
+{
+	timer->function = func;
+	timer->data = data;
+	init_timer_deferrable_key(timer, name, key);
+}
+#define setup_deferrable_timer(timer, fn, data)				\
+	do {								\
+		static struct lock_class_key __key;			\
+		setup_deferrable_timer_key((timer), #timer, &__key,	\
+					   (fn), (data));		\
+	} while (0)
+#endif
+
+#endif
+
+#endif /* _BACKPORT_TIMER_H */