aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/printk-formats.txt12
-rw-r--r--lib/vsprintf.c37
2 files changed, 49 insertions, 0 deletions
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 56804e40cb18..cb6a596072bb 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -261,6 +261,18 @@ struct va_format:
261 261
262 Passed by reference. 262 Passed by reference.
263 263
264struct clk:
265
266 %pC pll1
267 %pCn pll1
268 %pCr 1560000000
269
270 For printing struct clk structures. '%pC' and '%pCn' print the name
271 (Common Clock Framework) or address (legacy clock framework) of the
272 structure; '%pCr' prints the current clock rate.
273
274 Passed by reference.
275
264 276
265Thank you for your cooperation and attention. 277Thank you for your cooperation and attention.
266 278
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
1319static noinline_for_stack
1320char *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
1318int kptr_restrict __read_mostly; 1343int 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 **