diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2015-04-15 19:17:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 19:35:23 -0400 |
commit | 900cca2944254edd2d54dc181629314d3177a4af (patch) | |
tree | 3e1688e275f749d53d6b276ed00260243d254e0c /lib | |
parent | e8a7ba5f5c8c0c94c0c7f1bcd53c0289560c7446 (diff) |
lib/vsprintf: add %pC{,n,r} format specifiers for clocks
Add format specifiers for printing struct clk:
- '%pC' or '%pCn': name (Common Clock Framework) or address (legacy
clock framework) of the clock,
- '%pCr': rate of the clock.
[akpm@linux-foundation.org: omit code if !CONFIG_HAVE_CLK]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 2753f9261115..3ab8c9cf3980 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <stdarg.h> | 19 | #include <stdarg.h> |
20 | #include <linux/clk-provider.h> | ||
20 | #include <linux/module.h> /* for KSYM_SYMBOL_LEN */ | 21 | #include <linux/module.h> /* for KSYM_SYMBOL_LEN */ |
21 | #include <linux/types.h> | 22 | #include <linux/types.h> |
22 | #include <linux/string.h> | 23 | #include <linux/string.h> |
@@ -1315,6 +1316,30 @@ char *address_val(char *buf, char *end, const void *addr, | |||
1315 | return number(buf, end, num, spec); | 1316 | return number(buf, end, num, spec); |
1316 | } | 1317 | } |
1317 | 1318 | ||
1319 | static noinline_for_stack | ||
1320 | char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, | ||
1321 | const char *fmt) | ||
1322 | { | ||
1323 | if (!IS_ENABLED(CONFIG_HAVE_CLK) || !clk) | ||
1324 | return string(buf, end, NULL, spec); | ||
1325 | |||
1326 | switch (fmt[1]) { | ||
1327 | case 'r': | ||
1328 | return number(buf, end, clk_get_rate(clk), spec); | ||
1329 | |||
1330 | case 'n': | ||
1331 | default: | ||
1332 | #ifdef CONFIG_COMMON_CLK | ||
1333 | return string(buf, end, __clk_get_name(clk), spec); | ||
1334 | #else | ||
1335 | spec.base = 16; | ||
1336 | spec.field_width = sizeof(unsigned long) * 2 + 2; | ||
1337 | spec.flags |= SPECIAL | SMALL | ZEROPAD; | ||
1338 | return number(buf, end, (unsigned long)clk, spec); | ||
1339 | #endif | ||
1340 | } | ||
1341 | } | ||
1342 | |||
1318 | int kptr_restrict __read_mostly; | 1343 | int kptr_restrict __read_mostly; |
1319 | 1344 | ||
1320 | /* | 1345 | /* |
@@ -1397,6 +1422,11 @@ int kptr_restrict __read_mostly; | |||
1397 | * (default assumed to be phys_addr_t, passed by reference) | 1422 | * (default assumed to be phys_addr_t, passed by reference) |
1398 | * - 'd[234]' For a dentry name (optionally 2-4 last components) | 1423 | * - 'd[234]' For a dentry name (optionally 2-4 last components) |
1399 | * - 'D[234]' Same as 'd' but for a struct file | 1424 | * - 'D[234]' Same as 'd' but for a struct file |
1425 | * - 'C' For a clock, it prints the name (Common Clock Framework) or address | ||
1426 | * (legacy clock framework) of the clock | ||
1427 | * - 'Cn' For a clock, it prints the name (Common Clock Framework) or address | ||
1428 | * (legacy clock framework) of the clock | ||
1429 | * - 'Cr' For a clock, it prints the current rate of the clock | ||
1400 | * | 1430 | * |
1401 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 | 1431 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 |
1402 | * function pointers are really function descriptors, which contain a | 1432 | * function pointers are really function descriptors, which contain a |
@@ -1541,6 +1571,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
1541 | return address_val(buf, end, ptr, spec, fmt); | 1571 | return address_val(buf, end, ptr, spec, fmt); |
1542 | case 'd': | 1572 | case 'd': |
1543 | return dentry_name(buf, end, ptr, spec, fmt); | 1573 | return dentry_name(buf, end, ptr, spec, fmt); |
1574 | case 'C': | ||
1575 | return clock(buf, end, ptr, spec, fmt); | ||
1544 | case 'D': | 1576 | case 'D': |
1545 | return dentry_name(buf, end, | 1577 | return dentry_name(buf, end, |
1546 | ((const struct file *)ptr)->f_path.dentry, | 1578 | ((const struct file *)ptr)->f_path.dentry, |
@@ -1785,6 +1817,11 @@ qualifier: | |||
1785 | * %*pE[achnops] print an escaped buffer | 1817 | * %*pE[achnops] print an escaped buffer |
1786 | * %*ph[CDN] a variable-length hex string with a separator (supports up to 64 | 1818 | * %*ph[CDN] a variable-length hex string with a separator (supports up to 64 |
1787 | * bytes of the input) | 1819 | * bytes of the input) |
1820 | * %pC output the name (Common Clock Framework) or address (legacy clock | ||
1821 | * framework) of a clock | ||
1822 | * %pCn output the name (Common Clock Framework) or address (legacy clock | ||
1823 | * framework) of a clock | ||
1824 | * %pCr output the current rate of a clock | ||
1788 | * %n is ignored | 1825 | * %n is ignored |
1789 | * | 1826 | * |
1790 | * ** Please update Documentation/printk-formats.txt when making changes ** | 1827 | * ** Please update Documentation/printk-formats.txt when making changes ** |