Commit eeab9815 authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Steven Rostedt

seq_buf: Create seq_buf_used() to find out how much was written

Add a helper function seq_buf_used() that replaces the SEQ_BUF_USED()
private macro to let callers have a method to know how much of the
seq_buf was written to.

Link: http://lkml.kernel.org/r/20141114011412.170377300@goodmis.org
Link: http://lkml.kernel.org/r/20141114011413.321654244@goodmis.orgReviewed-by: default avatarPetr Mladek <pmladek@suse.cz>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 0736c033
...@@ -64,6 +64,12 @@ seq_buf_buffer_left(struct seq_buf *s) ...@@ -64,6 +64,12 @@ seq_buf_buffer_left(struct seq_buf *s)
return (s->size - 1) - s->len; return (s->size - 1) - s->len;
} }
/* How much buffer was written? */
static inline unsigned int seq_buf_used(struct seq_buf *s)
{
return min(s->len, s->size);
}
extern __printf(2, 3) extern __printf(2, 3)
int seq_buf_printf(struct seq_buf *s, const char *fmt, ...); int seq_buf_printf(struct seq_buf *s, const char *fmt, ...);
extern __printf(2, 0) extern __printf(2, 0)
......
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/seq_buf.h> #include <linux/seq_buf.h>
/* How much buffer is written? */
#define SEQ_BUF_USED(s) min((s)->len, (s)->size - 1)
/** /**
* seq_buf_print_seq - move the contents of seq_buf into a seq_file * seq_buf_print_seq - move the contents of seq_buf into a seq_file
* @m: the seq_file descriptor that is the destination * @m: the seq_file descriptor that is the destination
...@@ -28,7 +25,7 @@ ...@@ -28,7 +25,7 @@
*/ */
int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s) int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s)
{ {
unsigned int len = SEQ_BUF_USED(s); unsigned int len = seq_buf_used(s);
return seq_write(m, s->buffer, len); return seq_write(m, s->buffer, len);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment