aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-03 13:50:55 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-03 13:50:55 -0500
commit1e7972cc5c16e06f258b0278d8c9adfb5aa75c68 (patch)
treeb73bbe4083bba9e345474fd17082d8a179f93157 /tools/perf/util/session.c
parentdaec78a09de3df5fbfbbd167da0304d49d7fcfe5 (diff)
perf util: Move do_read from session to util
Not really something to be exported from session.c. Rename it to 'readn' as others did in the past. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 0f7e544544f5..b163dfd6cbc5 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -838,23 +838,6 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se
838 return thread; 838 return thread;
839} 839}
840 840
841int do_read(int fd, void *buf, size_t size)
842{
843 void *buf_start = buf;
844
845 while (size) {
846 int ret = read(fd, buf, size);
847
848 if (ret <= 0)
849 return ret;
850
851 size -= ret;
852 buf += ret;
853 }
854
855 return buf - buf_start;
856}
857
858#define session_done() (*(volatile int *)(&session_done)) 841#define session_done() (*(volatile int *)(&session_done))
859volatile int session_done; 842volatile int session_done;
860 843
@@ -872,7 +855,7 @@ static int __perf_session__process_pipe_events(struct perf_session *self,
872 855
873 head = 0; 856 head = 0;
874more: 857more:
875 err = do_read(self->fd, &event, sizeof(struct perf_event_header)); 858 err = readn(self->fd, &event, sizeof(struct perf_event_header));
876 if (err <= 0) { 859 if (err <= 0) {
877 if (err == 0) 860 if (err == 0)
878 goto done; 861 goto done;
@@ -892,8 +875,7 @@ more:
892 p += sizeof(struct perf_event_header); 875 p += sizeof(struct perf_event_header);
893 876
894 if (size - sizeof(struct perf_event_header)) { 877 if (size - sizeof(struct perf_event_header)) {
895 err = do_read(self->fd, p, 878 err = readn(self->fd, p, size - sizeof(struct perf_event_header));
896 size - sizeof(struct perf_event_header));
897 if (err <= 0) { 879 if (err <= 0) {
898 if (err == 0) { 880 if (err == 0) {
899 pr_err("unexpected end of event stream\n"); 881 pr_err("unexpected end of event stream\n");