perf tools: Use fallback for sample_addr_correlates_sym() cases
[linux/fpc-iii.git] / tools / perf / ui / progress.c
blobbbfbc91a0fa4683c9294247051e4fad532115665
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kernel.h>
3 #include "../cache.h"
4 #include "progress.h"
6 static void null_progress__update(struct ui_progress *p __maybe_unused)
10 static struct ui_progress_ops null_progress__ops =
12 .update = null_progress__update,
15 struct ui_progress_ops *ui_progress__ops = &null_progress__ops;
17 void ui_progress__update(struct ui_progress *p, u64 adv)
19 u64 last = p->curr;
21 p->curr += adv;
23 if (p->curr >= p->next) {
24 u64 nr = DIV_ROUND_UP(p->curr - last, p->step);
26 p->next += nr * p->step;
27 ui_progress__ops->update(p);
31 void __ui_progress__init(struct ui_progress *p, u64 total,
32 const char *title, bool size)
34 p->curr = 0;
35 p->next = p->step = total / 16 ?: 1;
36 p->total = total;
37 p->title = title;
38 p->size = size;
40 if (ui_progress__ops->init)
41 ui_progress__ops->init(p);
44 void ui_progress__finish(void)
46 if (ui_progress__ops->finish)
47 ui_progress__ops->finish();