Skip to content

Commit 34507f4

Browse files
ktrzcinxlgirdwood
authored andcommitted
trace: Improve sof/trace/trace.h code formatting
Align escape characters in macros, use tabs instead of spaces (when possible), use single tab indentation in tracec context declaration. Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
1 parent 0de401f commit 34507f4

1 file changed

Lines changed: 49 additions & 46 deletions

File tree

src/include/sof/trace/trace.h

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ static inline struct trace *trace_get(void)
115115
_trace_event_atomic_with_ids(LOG_LEVEL_INFO, class, ctx, id_1, id_2, \
116116
format, ##__VA_ARGS__)
117117

118-
#define trace_warn_with_ids(class, ctx, id_1, id_2, format, ...) \
119-
_trace_event_with_ids(LOG_LEVEL_WARNING, class, ctx, id_1, id_2, \
118+
#define trace_warn_with_ids(class, ctx, id_1, id_2, format, ...) \
119+
_trace_event_with_ids(LOG_LEVEL_WARNING, class, ctx, id_1, id_2, \
120120
format, ##__VA_ARGS__)
121121

122-
#define trace_warn_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
123-
_trace_event_atomic_with_ids(LOG_LEVEL_WARNING, class, \
124-
ctx, id_1, id_2, \
122+
#define trace_warn_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
123+
_trace_event_atomic_with_ids(LOG_LEVEL_WARNING, class, \
124+
ctx, id_1, id_2, \
125125
format, ##__VA_ARGS__)
126126

127127
void trace_flush(void);
@@ -132,19 +132,19 @@ void trace_log(bool send_atomic, const void *log_entry,
132132
const struct tr_ctx *ctx, uint32_t lvl, uint32_t id_1,
133133
uint32_t id_2, int arg_count, ...);
134134

135-
#define _trace_event_with_ids(lvl, class, ctx, id_1, id_2, format, ...) \
136-
_log_message(false, lvl, class, ctx, id_1, id_2, \
135+
#define _trace_event_with_ids(lvl, class, ctx, id_1, id_2, format, ...) \
136+
_log_message(false, lvl, class, ctx, id_1, id_2, \
137137
format, ##__VA_ARGS__)
138138

139-
#define _trace_event_atomic_with_ids(lvl, class, ctx, id_1, id_2, format, ...)\
139+
#define _trace_event_atomic_with_ids(lvl, class, ctx, id_1, id_2, format, ...) \
140140
_log_message(true, lvl, class, ctx, id_1, \
141141
id_2, format, ##__VA_ARGS__)
142142

143143
#define trace_point(x) platform_trace_point(x)
144144

145145
#ifndef CONFIG_LIBRARY
146146

147-
#define _DECLARE_LOG_ENTRY(lvl, format, comp_class, params) \
147+
#define _DECLARE_LOG_ENTRY(lvl, format, comp_class, params) \
148148
__section(".static_log." #lvl) \
149149
static const struct { \
150150
uint32_t level; \
@@ -170,21 +170,22 @@ void trace_log(bool send_atomic, const void *log_entry,
170170
unsupported_amount_of_params_in_trace_event\
171171
_thrown_from_macro_BASE_LOG_in_trace_h
172172

173-
#define _log_message(atomic, lvl, comp_class, ctx, id_1, id_2, \
174-
format, ...) \
175-
do { \
176-
_DECLARE_LOG_ENTRY(lvl, format, comp_class, \
177-
PP_NARG(__VA_ARGS__)); \
178-
STATIC_ASSERT( \
179-
_TRACE_EVENT_MAX_ARGUMENT_COUNT >= \
180-
META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \
181-
BASE_LOG_ASSERT_FAIL_MSG \
182-
); \
183-
trace_log(atomic, &log_entry, ctx, lvl, id_1, id_2, \
184-
PP_NARG(__VA_ARGS__), ##__VA_ARGS__); \
173+
#define _log_message(atomic, lvl, comp_class, ctx, id_1, id_2, \
174+
format, ...) \
175+
do { \
176+
_DECLARE_LOG_ENTRY(lvl, format, comp_class, \
177+
PP_NARG(__VA_ARGS__)); \
178+
STATIC_ASSERT( \
179+
_TRACE_EVENT_MAX_ARGUMENT_COUNT >= \
180+
META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \
181+
BASE_LOG_ASSERT_FAIL_MSG \
182+
); \
183+
trace_log(atomic, &log_entry, ctx, lvl, id_1, id_2, \
184+
PP_NARG(__VA_ARGS__), ##__VA_ARGS__); \
185185
} while (0)
186186

187187
#else /* CONFIG_LIBRARY */
188+
188189
extern int test_bench_trace;
189190
char *get_trace_class(uint32_t trace_class);
190191
#define _log_message(atomic, level, comp_class, ctx, id_1, id_2, \
@@ -202,16 +203,17 @@ do { \
202203
} while (0)
203204

204205
#endif /* CONFIG_LIBRARY */
206+
205207
#else /* CONFIG_TRACE */
206208

207-
#define trace_event_with_ids(class, ctx, id_1, id_2, format, ...) \
209+
#define trace_event_with_ids(class, ctx, id_1, id_2, format, ...) \
208210
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
209211
#define trace_event_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
210212
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
211213

212-
#define trace_warn_with_ids(class, ctx, id_1, id_2, format, ...) \
214+
#define trace_warn_with_ids(class, ctx, id_1, id_2, format, ...) \
213215
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
214-
#define trace_warn_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
216+
#define trace_warn_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
215217
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
216218

217219
#define trace_point(x) do {} while (0)
@@ -225,17 +227,18 @@ static inline void trace_init(struct sof *sof) { }
225227

226228
/* verbose tracing */
227229
#if CONFIG_TRACEV
228-
#define tracev_event_with_ids(class, ctx, id_1, id_2, format, ...) \
229-
_trace_event_with_ids(LOG_LEVEL_VERBOSE, class, ctx, id_1, id_2, \
230+
#define tracev_event_with_ids(class, ctx, id_1, id_2, format, ...) \
231+
_trace_event_with_ids(LOG_LEVEL_VERBOSE, class, \
232+
ctx, id_1, id_2, \
230233
format, ##__VA_ARGS__)
231234

232235
#define tracev_event_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
233-
_trace_event_atomic_with_ids(LOG_LEVEL_VERBOSE, class, \
234-
ctx, id_1, id_2, \
236+
_trace_event_atomic_with_ids(LOG_LEVEL_VERBOSE, class, \
237+
ctx, id_1, id_2, \
235238
format, ##__VA_ARGS__)
236239

237240
#else /* CONFIG_TRACEV */
238-
#define tracev_event_with_ids(class, ctx, id_1, id_2, format, ...) \
241+
#define tracev_event_with_ids(class, ctx, id_1, id_2, format, ...) \
239242
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
240243
#define tracev_event_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
241244
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
@@ -255,7 +258,7 @@ static inline void trace_init(struct sof *sof) { }
255258
#define trace_error_atomic_with_ids(...) \
256259
trace_event_atomic_with_ids(__VA_ARGS__)
257260
#else /* CONFIG_TRACEE CONFIG_TRACE */
258-
#define trace_error_with_ids(class, ctx, id_1, id_2, format, ...) \
261+
#define trace_error_with_ids(class, ctx, id_1, id_2, format, ...) \
259262
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
260263
#define trace_error_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
261264
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
@@ -284,10 +287,10 @@ struct tr_ctx {
284287
* @param uuid UUID pointer, use SOF_UUID() to inititalize.
285288
* @param default_log_level Default log level.
286289
*/
287-
#define DECLARE_TR_CTX(ctx_name, uuid, default_log_level) \
288-
struct tr_ctx ctx_name TRACE_CONTEXT_SECTION = { \
289-
.uuid_p = uuid, \
290-
.level = default_log_level, \
290+
#define DECLARE_TR_CTX(ctx_name, uuid, default_log_level) \
291+
struct tr_ctx ctx_name TRACE_CONTEXT_SECTION = { \
292+
.uuid_p = uuid, \
293+
.level = default_log_level, \
291294
}
292295

293296
/* tracing from device (component, pipeline, dai, ...) */
@@ -301,27 +304,27 @@ struct tr_ctx {
301304
* @param fmt Format followed by parameters
302305
* @param ... Parameters
303306
*/
304-
#define trace_dev_err(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
305-
trace_error_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev),\
306-
get_id_m(dev), get_subid_m(dev), \
307+
#define trace_dev_err(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
308+
trace_error_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
309+
get_id_m(dev), get_subid_m(dev), \
307310
fmt, ##__VA_ARGS__)
308311

309312
/** \brief Trace from a device on warning level. */
310-
#define trace_dev_warn(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
311-
trace_warn_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
312-
get_id_m(dev), get_subid_m(dev), \
313+
#define trace_dev_warn(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
314+
trace_warn_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
315+
get_id_m(dev), get_subid_m(dev), \
313316
fmt, ##__VA_ARGS__)
314317

315318
/** \brief Trace from a device on info level. */
316-
#define trace_dev_info(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
317-
trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev),\
318-
get_id_m(dev), get_subid_m(dev), \
319+
#define trace_dev_info(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
320+
trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
321+
get_id_m(dev), get_subid_m(dev), \
319322
fmt, ##__VA_ARGS__)
320323

321324
/** \brief Trace from a device on dbg level. */
322-
#define trace_dev_dbg(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
323-
tracev_event_with_ids(_TRACE_INV_CLASS, \
324-
get_ctx_m(dev), get_id_m(dev), \
325+
#define trace_dev_dbg(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
326+
tracev_event_with_ids(_TRACE_INV_CLASS, \
327+
get_ctx_m(dev), get_id_m(dev), \
325328
get_subid_m(dev), fmt, ##__VA_ARGS__)
326329

327330
/* tracing from infrastructure part */

0 commit comments

Comments
 (0)