mirror of
https://github.com/torvalds/linux.git
synced 2024-11-07 04:32:03 +00:00
4d3001fdfd
That will ease using a progress bar across multiple functions, like in the upcoming patches that will present a progress bar when collapsing histograms. Based on a previous patch by Namhyung Kim. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-cr7lq7ud9fj21bg7wvq27w1u@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
39 lines
704 B
C
39 lines
704 B
C
#include "../cache.h"
|
|
#include "progress.h"
|
|
|
|
static void null_progress__update(struct ui_progress *p __maybe_unused)
|
|
{
|
|
}
|
|
|
|
static struct ui_progress_ops null_progress__ops =
|
|
{
|
|
.update = null_progress__update,
|
|
};
|
|
|
|
struct ui_progress_ops *ui_progress__ops = &null_progress__ops;
|
|
|
|
void ui_progress__update(struct ui_progress *p, u64 adv)
|
|
{
|
|
p->curr += adv;
|
|
|
|
if (p->curr >= p->next) {
|
|
p->next += p->step;
|
|
ui_progress__ops->update(p);
|
|
}
|
|
}
|
|
|
|
void ui_progress__init(struct ui_progress *p, u64 total, const char *title)
|
|
{
|
|
p->curr = 0;
|
|
p->next = p->step = total / 16;
|
|
p->total = total;
|
|
p->title = title;
|
|
|
|
}
|
|
|
|
void ui_progress__finish(void)
|
|
{
|
|
if (ui_progress__ops->finish)
|
|
ui_progress__ops->finish();
|
|
}
|