devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: increase readability when reading prop through sysfs
@ 2019-12-06 12:15 lijiazi
  2019-12-06 15:47 ` Rob Herring
  0 siblings, 1 reply; 2+ messages in thread
From: lijiazi @ 2019-12-06 12:15 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand; +Cc: lijiazi, devicetree

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-06 15:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-06 12:15 [PATCH] of: increase readability when reading prop through sysfs lijiazi
2019-12-06 15:47 ` Rob Herring

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).