From: lijiazi <jqqlijiazi@gmail.com>
To: Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Jonathan Corbet <corbet@lwn.net>,
Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>
Cc: lijiazi <lijiazi@xiaomi.com>,
devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND
FLATTENED DEVICE TREE),
linux-doc@vger.kernel.org (open list:DOCUMENTATION)
Subject: [PATCH v2] lib/vsprintf: introduce OF_DEVICE_NODE_FLAG_MAX for %pOF
Date: Fri, 17 Jan 2020 19:15:19 +0800 [thread overview]
Message-ID: <1579259719-16904-1-git-send-email-lijiazi@xiaomi.com> (raw)
Introduce OF_DEVICE_NODE_FLAG_MAX for device node printk, if add
new device node flag, please add the corresponding flag abbreviation
to tbuf in device_node_string.
Signed-off-by: lijiazi <lijiazi@xiaomi.com>
---
Documentation/core-api/printk-formats.rst | 2 ++
include/linux/of.h | 6 ++++++
lib/vsprintf.c | 14 +++++++-------
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index 8ebe46b1..c73ccad 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -441,6 +441,8 @@ Examples::
d - detached
P - Populated
B - Populated bus
+ O - Overlay
+ F - Overlay free cset
Passed by reference.
diff --git a/include/linux/of.h b/include/linux/of.h
index c669c0a..0453601 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -147,6 +147,12 @@ extern raw_spinlock_t devtree_lock;
#define OF_OVERLAY 5 /* allocated for an overlay */
#define OF_OVERLAY_FREE_CSET 6 /* in overlay cset being freed */
+/* Add flag max for %pOF related printk, if add new flag, please
+ * increase following marco, and add abbreviations to tbuf in
+ * device_node_string function.
+ */
+#define OF_DEVICE_NODE_FLAG_MAX 6 /* maximum available flags */
+
#define OF_BAD_ADDR ((u64)-1)
#ifdef CONFIG_OF
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 7c488a1..3c219b4 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1937,9 +1937,9 @@ static noinline_for_stack
char *device_node_string(char *buf, char *end, struct device_node *dn,
struct printf_spec spec, const char *fmt)
{
- char tbuf[sizeof("xxxx") + 1];
+ char tbuf[OF_DEVICE_NODE_FLAG_MAX + 1] = { "DdPBOF" };
const char *p;
- int ret;
+ int ret, i;
char *buf_start = buf;
struct property *prop;
bool has_mult, pass;
@@ -1997,11 +1997,11 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
buf = string(buf, end, p, str_spec);
break;
case 'F': /* flags */
- tbuf[0] = of_node_check_flag(dn, OF_DYNAMIC) ? 'D' : '-';
- tbuf[1] = of_node_check_flag(dn, OF_DETACHED) ? 'd' : '-';
- tbuf[2] = of_node_check_flag(dn, OF_POPULATED) ? 'P' : '-';
- tbuf[3] = of_node_check_flag(dn, OF_POPULATED_BUS) ? 'B' : '-';
- tbuf[4] = 0;
+ for (i = 0; i < OF_DEVICE_NODE_FLAG_MAX; i++) {
+ if (!of_node_check_flag(dn, OF_DYNAMIC + i))
+ tbuf[i] = '-';
+ }
+ tbuf[OF_DEVICE_NODE_FLAG_MAX] = 0;
buf = string_nocheck(buf, end, tbuf, str_spec);
break;
case 'c': /* major compatible string */
--
2.7.4
next reply other threads:[~2020-01-17 11:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 11:15 lijiazi [this message]
2020-01-17 13:30 ` [PATCH v2] lib/vsprintf: introduce OF_DEVICE_NODE_FLAG_MAX for %pOF Andy Shevchenko
2020-01-17 13:32 ` Andy Shevchenko
2020-01-17 16:02 ` Randy Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1579259719-16904-1-git-send-email-lijiazi@xiaomi.com \
--to=jqqlijiazi@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=lijiazi@xiaomi.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=robh+dt@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).