Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp894704pxk; Thu, 17 Sep 2020 20:35:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwX3drtRxdGuyUaGQYXvrsqu2/CfnmMJGDch/pmFeGd9JWXdCAFOLljUfR6zGKWh4OrOUwM X-Received: by 2002:a05:6402:503:: with SMTP id m3mr36842915edv.45.1600400141125; Thu, 17 Sep 2020 20:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600400141; cv=none; d=google.com; s=arc-20160816; b=ed1k6llqNQP+pD+aX+NDN8EID/ZdZwGoQPa2YqNAeOBN6R/NHgncCXJs3qYWv19ItM ByFl43rp9zKxA0BuAKPMC5hgpeQt7ImvNiFOX96m4rWxYSWNYHFRp3TrsK29PhcUYE6B kd+SDUhmOpEz3lkOKlw80+Li9DyxROl4HERgKXJyDP+zzmfaBH+Z4Cg+5jRF//e0yRfD JuYUFO4Mth0fvZZ4BjhvmXaTJBN5Fj8hWIGoDXAgp68yXYCd5yREBbHOR9zHAPTv7inf E3qb/EtbSgQDClFksPiUGhxSkpmdorJpyFW4dmxe9XK2/4JVSpPSI/wUjij2vgalGNLY tFOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=fUDUX2OFiOnrPh6OcTg4L8MT0qtEFbhqAQ41viPQICI=; b=VrukW2Yj3MGw2P3XV9F1Kb1Qnv7Q7K+8wFkCab3FkEjdzcydvJsve8u5CZb5s05ZvA EFhVdZnrjaUOhfzkXjidQLB07Vu/52kTSkcdVotgztVzJpKOGaaQfhxzz5cCuJmegppm W7gaCc258FhoI4Pm98d7xdclMgG90BF/+vWIHfXgbh48Q4vxPjN/u2GvvFbn6KDnjzCx MlfbvKVUGCjvuYQVGnohnhVE9kM7m98IG8zo1q2B+/MNHSRXesquY9bkSpU7skj+l8LX xtmJVGyY9yEnYAvm6LcU6ivucu/UUiQcs1CjLA8WWhPxzLwfPJSLxD4z0FvoSFK4m7f0 pIYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz19si1729268ejb.241.2020.09.17.20.35.18; Thu, 17 Sep 2020 20:35:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbgIRDds (ORCPT + 99 others); Thu, 17 Sep 2020 23:33:48 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13287 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726102AbgIRDds (ORCPT ); Thu, 17 Sep 2020 23:33:48 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2DD473B87BF4DD4B65B0; Fri, 18 Sep 2020 11:33:46 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Fri, 18 Sep 2020 11:33:39 +0800 From: Xiongfeng Wang To: , , CC: , , , Subject: [PATCH v3] EDAC/mc_sysfs: Add missing newlines when printing {max,dimm}_location Date: Fri, 18 Sep 2020 11:26:08 +0800 Message-ID: <1600399568-21649-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Borislav Petkov Suggested-by: Joe Perches --- drivers/edac/edac_mc_sysfs.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 4e6aca5..2f9f1e7 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 += scnprintf(data + count, PAGE_SIZE - count, "\n"); + + return count; } static ssize_t dimmdev_label_show(struct device *dev, @@ -813,15 +817,23 @@ static ssize_t mci_max_location_show(struct device *dev, char *data) { struct mem_ctl_info *mci = to_mci(dev); - int i; + int len = PAGE_SIZE; char *p = data; + int i, n; for (i = 0; i < mci->n_layers; i++) { - p += sprintf(p, "%s %d ", - edac_layer_name[mci->layers[i].type], - mci->layers[i].size - 1); + n = scnprintf(p, len, "%s %d ", + edac_layer_name[mci->layers[i].type], + mci->layers[i].size - 1); + len -= n; + if (len <= 0) + goto out; + + p += n; } + p += scnprintf(p, len, "\n"); +out: return p - data; } -- 1.7.12.4