0001
0002 #ifndef _LINUX_TRACE_SEQ_H
0003 #define _LINUX_TRACE_SEQ_H
0004
0005 #include <linux/seq_buf.h>
0006
0007 #include <asm/page.h>
0008
0009
0010
0011
0012
0013
0014 struct trace_seq {
0015 char buffer[PAGE_SIZE];
0016 struct seq_buf seq;
0017 int full;
0018 };
0019
0020 static inline void
0021 trace_seq_init(struct trace_seq *s)
0022 {
0023 seq_buf_init(&s->seq, s->buffer, PAGE_SIZE);
0024 s->full = 0;
0025 }
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 static inline int trace_seq_used(struct trace_seq *s)
0041 {
0042 return seq_buf_used(&s->seq);
0043 }
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 static inline char *
0055 trace_seq_buffer_ptr(struct trace_seq *s)
0056 {
0057 return s->buffer + seq_buf_used(&s->seq);
0058 }
0059
0060
0061
0062
0063
0064
0065
0066
0067 static inline bool trace_seq_has_overflowed(struct trace_seq *s)
0068 {
0069 return s->full || seq_buf_has_overflowed(&s->seq);
0070 }
0071
0072
0073
0074
0075 #ifdef CONFIG_TRACING
0076 extern __printf(2, 3)
0077 void trace_seq_printf(struct trace_seq *s, const char *fmt, ...);
0078 extern __printf(2, 0)
0079 void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args);
0080 extern void
0081 trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
0082 extern int trace_print_seq(struct seq_file *m, struct trace_seq *s);
0083 extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
0084 int cnt);
0085 extern void trace_seq_puts(struct trace_seq *s, const char *str);
0086 extern void trace_seq_putc(struct trace_seq *s, unsigned char c);
0087 extern void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len);
0088 extern void trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
0089 unsigned int len);
0090 extern int trace_seq_path(struct trace_seq *s, const struct path *path);
0091
0092 extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
0093 int nmaskbits);
0094
0095 extern int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str,
0096 int prefix_type, int rowsize, int groupsize,
0097 const void *buf, size_t len, bool ascii);
0098
0099 #else
0100 static inline void trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
0101 {
0102 }
0103 static inline void
0104 trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
0105 {
0106 }
0107
0108 static inline void
0109 trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
0110 int nmaskbits)
0111 {
0112 }
0113
0114 static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s)
0115 {
0116 return 0;
0117 }
0118 static inline int trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
0119 int cnt)
0120 {
0121 return 0;
0122 }
0123 static inline void trace_seq_puts(struct trace_seq *s, const char *str)
0124 {
0125 }
0126 static inline void trace_seq_putc(struct trace_seq *s, unsigned char c)
0127 {
0128 }
0129 static inline void
0130 trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len)
0131 {
0132 }
0133 static inline void trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
0134 unsigned int len)
0135 {
0136 }
0137 static inline int trace_seq_path(struct trace_seq *s, const struct path *path)
0138 {
0139 return 0;
0140 }
0141 #endif
0142
0143 #endif