[PATCH] of: increase readability when reading prop through sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: lijiazi <lijiazi@xxxxxxxxxx>
---
 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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux