1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/kernel.h>
8 #include <linux/time64.h>
10 unsigned long parse_tag_value(const char *str
, struct parse_tag
*tags
)
12 struct parse_tag
*i
= tags
;
15 char *s
= strchr(str
, i
->tag
);
18 unsigned long int value
;
21 value
= strtoul(str
, &endptr
, 10);
25 if (value
> ULONG_MAX
/ i
->mult
)
33 return (unsigned long) -1;
36 unsigned long convert_unit(unsigned long value
, char *unit
)
58 int unit_number__scnprintf(char *buf
, size_t size
, u64 n
)
60 char unit
[4] = "BKMG";
63 while (((n
/ 1024) > 1) && (i
< 3)) {
68 return scnprintf(buf
, size
, "%" PRIu64
"%c", n
, unit
[i
]);