From: Xiongfeng Wang <wangxiongfeng2@huawei.com>
To: <bp@alien8.de>, <mchehab@kernel.org>, <tony.luck@intel.com>
Cc: <linux-edac@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<wangxiongfeng2@huawei.com>
Subject: [PATCH v2] EDAC/mc_sysfs: Add missing newlines when printing {max,dimm}_location
Date: Mon, 14 Sep 2020 10:48:54 +0800 [thread overview]
Message-ID: <1600051734-8993-1-git-send-email-wangxiongfeng2@huawei.com> (raw)
Reading those sysfs entries gives:
[root@localhost /]# cat /sys/devices/system/edac/mc/mc0/max_location
memory 3 [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/dimm0/dimm_location
memory 0 [root@localhost /]#
Add newlines after the value it prints for better readability.
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
drivers/edac/edac_mc_sysfs.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 4e6aca5..bf0e075 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -474,8 +474,12 @@ static ssize_t dimmdev_location_show(struct device *dev,
struct device_attribute *mattr, char *data)
{
struct dimm_info *dimm = to_dimm(dev);
+ ssize_t count;
- return edac_dimm_info_location(dimm, data, PAGE_SIZE);
+ count = edac_dimm_info_location(dimm, data, PAGE_SIZE);
+ count += snprintf(data + count, PAGE_SIZE - count, "\n");
+
+ return count;
}
static ssize_t dimmdev_label_show(struct device *dev,
@@ -813,15 +817,21 @@ static ssize_t mci_max_location_show(struct device *dev,
char *data)
{
struct mem_ctl_info *mci = to_mci(dev);
- int i;
+ int i, n;
char *p = data;
+ unsigned int len = PAGE_SIZE;
for (i = 0; i < mci->n_layers; i++) {
- p += sprintf(p, "%s %d ",
+ n = snprintf(p, len, "%s %d ",
edac_layer_name[mci->layers[i].type],
mci->layers[i].size - 1);
+ p += n;
+ len -= n;
+ if (!len)
+ goto out;
}
-
+ p += snprintf(p, len, "\n");
+out:
return p - data;
}
--
1.7.12.4
next reply other threads:[~2020-09-14 2:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-14 2:48 Xiongfeng Wang [this message]
2020-09-16 17:00 ` [PATCH v2] EDAC/mc_sysfs: Add missing newlines when printing {max,dimm}_location Borislav Petkov
2020-09-17 11:38 ` Xiongfeng Wang
2020-09-17 15:28 ` Joe Perches
2020-09-17 16:25 ` Borislav Petkov
2020-09-18 2:37 ` Xiongfeng Wang
2020-09-18 7:12 ` Borislav Petkov
2020-09-18 13:31 ` Joe Perches
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=1600051734-8993-1-git-send-email-wangxiongfeng2@huawei.com \
--to=wangxiongfeng2@huawei.com \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=tony.luck@intel.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).