devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: lijiazi <jqqlijiazi@gmail.com>
To: Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com>
Cc: lijiazi <lijiazi@xiaomi.com>, devicetree@vger.kernel.org
Subject: [PATCH] of: increase readability when reading prop through sysfs
Date: Fri,  6 Dec 2019 20:15:32 +0800	[thread overview]
Message-ID: <02bf81614fd5806fbdb8e58760f424adeee3fdc6.1575611847.git.lijiazi@xiaomi.com> (raw)

Replace '\0' with '\n', output will display on a single line.

Signed-off-by: lijiazi <lijiazi@xiaomi.com>
---
 drivers/of/kobj.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c
index c72eef9..c776610 100644
--- a/drivers/of/kobj.c
+++ b/drivers/of/kobj.c
@@ -32,8 +32,18 @@ static ssize_t of_node_property_read(struct file *filp, struct kobject *kobj,
 				struct bin_attribute *bin_attr, char *buf,
 				loff_t offset, size_t count)
 {
+	ssize_t pos = 0;
 	struct property *pp = container_of(bin_attr, struct property, attr);
-	return memory_read_from_buffer(buf, count, &offset, pp->value, pp->length);
+	pos = memory_read_from_buffer(buf, count, &offset,
+			pp->value, pp->length);
+	/*
+	 * value is ends with '\0', so if read prop value through sysfs, the
+	 * output will be displayed on the same line as the shell prompt.
+	 * Replace '\0' with '\n', increase readability of output.
+	 */
+	if (pos >= 1)
+		buf[pos-1] = '\n';
+	return pos;
 }
 
 /* always return newly allocated name, caller must free after use */
-- 
2.7.4


             reply	other threads:[~2019-12-06 12:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06 12:15 lijiazi [this message]
2019-12-06 15:47 ` [PATCH] of: increase readability when reading prop through sysfs Rob Herring

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=02bf81614fd5806fbdb8e58760f424adeee3fdc6.1575611847.git.lijiazi@xiaomi.com \
    --to=jqqlijiazi@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=lijiazi@xiaomi.com \
    --cc=robh+dt@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 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).