From f6f975f74e57492d952ce03c4f410d16935a3161 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 2 Aug 2019 22:06:21 +0200 Subject: header: Add trace_##name##_enabled() This adds the function trace_##name##_enabled to __DECLARE_TRACE() which was added in commit 7c65bbc7dc ("tracing: Add trace__enabled() function"). This is now used by ath10k. __DECLARE_TRACE() got other changes wit kernel 3.16, so add two different versions. Signed-off-by: Hauke Mehrtens --- backport/backport-include/linux/tracepoint.h | 132 +++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/backport/backport-include/linux/tracepoint.h b/backport/backport-include/linux/tracepoint.h index a695c6fc..6bb91ad3 100644 --- a/backport/backport-include/linux/tracepoint.h +++ b/backport/backport-include/linux/tracepoint.h @@ -7,4 +7,136 @@ #define TRACE_DEFINE_ENUM(a) #endif +#if LINUX_VERSION_IS_LESS(3,15,0) +#ifdef TRACEPOINTS_ENABLED +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + extern struct tracepoint __tracepoint_##name; \ + static inline void trace_##name(proto) \ + { \ + if (static_key_false(&__tracepoint_##name.key)) \ + __DO_TRACE(&__tracepoint_##name, \ + TP_PROTO(data_proto), \ + TP_ARGS(data_args), \ + TP_CONDITION(cond),,); \ + } \ + __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \ + PARAMS(cond), PARAMS(data_proto), PARAMS(data_args)) \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + return tracepoint_probe_register(#name, (void *)probe, \ + data); \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + return tracepoint_probe_unregister(#name, (void *)probe, \ + data); \ + } \ + static inline void \ + check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return static_key_false(&__tracepoint_##name.key); \ + } + +#else +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + static inline void trace_##name(proto) \ + { } \ + static inline void trace_##name##_rcuidle(proto) \ + { } \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return false; \ + } +#endif /* TRACEPOINTS_ENABLED */ +#elif LINUX_VERSION_IS_LESS(3,16,0) +#ifdef TRACEPOINTS_ENABLED +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + extern struct tracepoint __tracepoint_##name; \ + static inline void trace_##name(proto) \ + { \ + if (static_key_false(&__tracepoint_##name.key)) \ + __DO_TRACE(&__tracepoint_##name, \ + TP_PROTO(data_proto), \ + TP_ARGS(data_args), \ + TP_CONDITION(cond),,); \ + } \ + __DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \ + PARAMS(cond), PARAMS(data_proto), PARAMS(data_args)) \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + return tracepoint_probe_register(&__tracepoint_##name, \ + (void *)probe, data); \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + return tracepoint_probe_unregister(&__tracepoint_##name,\ + (void *)probe, data); \ + } \ + static inline void \ + check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return static_key_false(&__tracepoint_##name.key); \ + } + +#else +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + static inline void trace_##name(proto) \ + { } \ + static inline void trace_##name##_rcuidle(proto) \ + { } \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return false; \ + } +#endif /* TRACEPOINTS_ENABLED */ +#endif /* < 3.16 */ + #endif /* __BACKPORT_LINUX_TRACEPOINT_H */ -- cgit v1.2.3