aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/seq_buf.h6
-rw-r--r--kernel/trace/seq_buf.c5
2 files changed, 7 insertions, 4 deletions
diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
index 5d91262433e2..93718e570d4c 100644
--- a/include/linux/seq_buf.h
+++ b/include/linux/seq_buf.h
@@ -64,6 +64,12 @@ seq_buf_buffer_left(struct seq_buf *s)
64 return (s->size - 1) - s->len; 64 return (s->size - 1) - s->len;
65} 65}
66 66
67/* How much buffer was written? */
68static inline unsigned int seq_buf_used(struct seq_buf *s)
69{
70 return min(s->len, s->size);
71}
72
67extern __printf(2, 3) 73extern __printf(2, 3)
68int seq_buf_printf(struct seq_buf *s, const char *fmt, ...); 74int seq_buf_printf(struct seq_buf *s, const char *fmt, ...);
69extern __printf(2, 0) 75extern __printf(2, 0)
diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c
index 7dac34d1235b..9ec5305d9da7 100644
--- a/kernel/trace/seq_buf.c
+++ b/kernel/trace/seq_buf.c
@@ -16,9 +16,6 @@
16#include <linux/seq_file.h> 16#include <linux/seq_file.h>
17#include <linux/seq_buf.h> 17#include <linux/seq_buf.h>
18 18
19/* How much buffer is written? */
20#define SEQ_BUF_USED(s) min((s)->len, (s)->size - 1)
21
22/** 19/**
23 * seq_buf_print_seq - move the contents of seq_buf into a seq_file 20 * seq_buf_print_seq - move the contents of seq_buf into a seq_file
24 * @m: the seq_file descriptor that is the destination 21 * @m: the seq_file descriptor that is the destination
@@ -28,7 +25,7 @@
28 */ 25 */
29int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s) 26int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s)
30{ 27{
31 unsigned int len = SEQ_BUF_USED(s); 28 unsigned int len = seq_buf_used(s);
32 29
33 return seq_write(m, s->buffer, len); 30 return seq_write(m, s->buffer, len);
34} 31}