1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kernel.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
)
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
)
35 p
->next
= p
->step
= total
/ 16 ?: 1;
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();