All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Frank Rowand <frowand.list@gmail.com>, devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] vsprintf: print OF node name using full_name
Date: Tue, 28 Aug 2018 10:52:54 -0500	[thread overview]
Message-ID: <20180828155254.10709-5-robh@kernel.org> (raw)
In-Reply-To: <20180828155254.10709-1-robh@kernel.org>

In preparation to remove the node name pointer from struct device_node,
convert the node name print to get the node name from the full name.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 lib/vsprintf.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d5b3a3f95c01..891c282092a0 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1596,6 +1596,7 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
 		fmt = "f";
 
 	for (pass = false; strspn(fmt,"fnpPFcC"); fmt++, pass = true) {
+		int precision;
 		if (pass) {
 			if (buf < end)
 				*buf = ':';
@@ -1607,7 +1608,11 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
 			buf = device_node_gen_full_name(dn, buf, end);
 			break;
 		case 'n':	/* name */
-			buf = string(buf, end, dn->name, str_spec);
+			p = kbasename(of_node_full_name(dn));
+			precision = str_spec.precision;
+			str_spec.precision = strchrnul(p, '@') - p;
+			buf = string(buf, end, p, str_spec);
+			str_spec.precision = precision;
 			break;
 		case 'p':	/* phandle */
 			buf = number(buf, end, (unsigned int)dn->phandle, num_spec);
-- 
2.17.1


  parent reply	other threads:[~2018-08-28 15:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 15:52 [PATCH 0/4] of: Convert to using %pOFn for node name printf Rob Herring
2018-08-28 15:52 ` [PATCH 1/4] of/unittest: remove use of node name pointer in overlay high level test Rob Herring
2018-08-28 15:52 ` [PATCH 2/4] of/unittest: add printf tests for node name Rob Herring
2018-08-28 15:52 ` [PATCH 3/4] of: Convert to using %pOFn instead of device_node.name Rob Herring
2018-09-07 12:29   ` Thierry Reding
2018-09-07 14:58     ` Rob Herring
2018-09-08  0:30     ` Joe Perches
2018-09-10  9:06       ` Thierry Reding
2018-08-28 15:52 ` Rob Herring [this message]
2018-08-31 23:51 ` [PATCH 0/4] of: Convert to using %pOFn for node name printf Frank Rowand

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=20180828155254.10709-5-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.