perf thread-stack: Eliminate code duplicating thread_stack__pop_ks()
[linux-2.6-microblaze.git] / tools / perf / util / thread-stack.c
index 4c826a2..6ff1ff4 100644 (file)
@@ -664,12 +664,9 @@ static int thread_stack__no_call_return(struct thread *thread,
 
        if (ip >= ks && addr < ks) {
                /* Return to userspace, so pop all kernel addresses */
-               while (thread_stack__in_kernel(ts)) {
-                       err = thread_stack__call_return(thread, ts, --ts->cnt,
-                                                       tm, ref, true);
-                       if (err)
-                               return err;
-               }
+               err = thread_stack__pop_ks(thread, ts, sample, ref);
+               if (err)
+                       return err;
 
                /* If the stack is empty, push the userspace address */
                if (!ts->cnt) {
@@ -679,12 +676,9 @@ static int thread_stack__no_call_return(struct thread *thread,
                }
        } else if (thread_stack__in_kernel(ts) && ip < ks) {
                /* Return to userspace, so pop all kernel addresses */
-               while (thread_stack__in_kernel(ts)) {
-                       err = thread_stack__call_return(thread, ts, --ts->cnt,
-                                                       tm, ref, true);
-                       if (err)
-                               return err;
-               }
+               err = thread_stack__pop_ks(thread, ts, sample, ref);
+               if (err)
+                       return err;
        }
 
        if (ts->cnt)