Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755354AbbESJM7 (ORCPT ); Tue, 19 May 2015 05:12:59 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:16915 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755337AbbESJL1 (ORCPT ); Tue, 19 May 2015 05:11:27 -0400 From: Wang Long To: , , , CC: , , , , , , , , , Subject: [PATCH v2 05/17] seq_buf: Create seq_buf_used() to find out how much was written Date: Tue, 19 May 2015 09:08:50 +0000 Message-ID: <1432026542-123571-6-git-send-email-long.wanglong@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1432026542-123571-1-git-send-email-long.wanglong@huawei.com> References: <1432026542-123571-1-git-send-email-long.wanglong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.200] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2128 Lines: 68 From: "Steven Rostedt (Red Hat)" commit eeab98154dc0b49afd398afdd71c464a8af5911f upstream. 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.org Reviewed-by: Petr Mladek [wanglong: backport to 3.10 stable] Signed-off-by: Wang Long Signed-off-by: Steven Rostedt --- include/linux/seq_buf.h | 6 ++++++ kernel/trace/seq_buf.c | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 5d91262..93718e5 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) 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) int seq_buf_printf(struct seq_buf *s, const char *fmt, ...); extern __printf(2, 0) diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index 7dac34d..9ec5305 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -16,9 +16,6 @@ #include #include -/* 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 * @m: the seq_file descriptor that is the destination @@ -28,7 +25,7 @@ */ 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); } -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/