diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2016-01-28 09:56:01 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2016-02-02 14:40:33 +1100 |
commit | 2d01f489f2981d8f58e479709a444a114cbd80e2 (patch) | |
tree | 0b75bd791db4159eb34dac8f7240569248e441a2 /lib | |
parent | 1ff131862962951bce63f6359c48bb6d8ce8401e (diff) | |
download | linux-next-2d01f489f2981d8f58e479709a444a114cbd80e2.tar.gz |
lib/string_helpers: export string_units_{2,10} for others
There is one user coming which would like to use those string arrays. It might
be useful for any other user in the future.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Robert Elliott <elliott@hpe.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/string_helpers.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/string_helpers.c b/lib/string_helpers.c index 5c88204b6f1f..c62acc0583a7 100644 --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -13,6 +13,15 @@ #include <linux/string.h> #include <linux/string_helpers.h> +const char * const string_units_10[STRING_UNITS_10_NUM] = { + "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", +}; +EXPORT_SYMBOL(string_units_10); +const char * const string_units_2[STRING_UNITS_2_NUM] = { + "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", +}; +EXPORT_SYMBOL(string_units_2); + /** * string_get_size - get the size in the specified units * @size: The size to be converted in blocks @@ -29,15 +38,9 @@ void string_get_size(u64 size, u64 blk_size, const enum string_size_units units, char *buf, int len) { - static const char *const units_10[] = { - "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" - }; - static const char *const units_2[] = { - "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" - }; static const char *const *const units_str[] = { - [STRING_UNITS_10] = units_10, - [STRING_UNITS_2] = units_2, + [STRING_UNITS_10] = string_units_10, + [STRING_UNITS_2] = string_units_2, }; static const unsigned int divisor[] = { [STRING_UNITS_10] = 1000, @@ -115,7 +118,7 @@ void string_get_size(u64 size, u64 blk_size, const enum string_size_units units, } out: - if (i >= ARRAY_SIZE(units_2)) + if (i >= STRING_UNITS_2_NUM) unit = "UNK"; else unit = units_str[units][i]; |