Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1862690pxk; Sun, 13 Sep 2020 19:57:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+CBkNolIlKyDlMv2YZMCqqrvPYprNm3SlU7PfEf+wMuHM+cWDBRIHnMdkmJIRIaYygIRs X-Received: by 2002:a17:906:a1d0:: with SMTP id bx16mr11913859ejb.65.1600052250964; Sun, 13 Sep 2020 19:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600052250; cv=none; d=google.com; s=arc-20160816; b=RfDj28/LQ9n0vyORarwznM1oV9WpLZGxrY590KO7qHBiNOkKcglyjAb3zzJOgiWXYs D6x2xMdjrFZG1J8glNrR9GZpnQar5qnxMpbnZqmEtQcWGQdtM+DPYtm8oM+YxPcP5Mf0 rtSPeK8jCi48TUxFpiR3gqEAonOl2SGgZodJnz0SoIFAJt/0rRSW6ZcdeAvBGoqKrGzc 1McVAiV5osAx0drEfxbrFsHCig9wLSnaRYXP86EqR9TQYIh5ml4BdNedFZVsN2MuEACy QDCK6hwx+MvS1yzdUhACBPrTSfaQTwa6BzedR/7jnQ1wurQat3yZuinCBjS2HqtCGAoG 1Yqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=5TekAH8HzoUjVdwucTCKi4lgEHMw+YKf9HZoDTZF8lc=; b=IQJ3iZWL/KZGdRRvnpXhmcQHhCWwUcHJRrcQvpaEY7+mvKbRxZO4Xl7W8clLwikwbt NRms5SB4D7aNf5Ne6Z3d3+JSgL+gGX7q+gGHVko0V6kKXVjWw3Ncl96pykTTQSgeJ8TN Db3D8sp3N83vgtamoK+dhwDsYI8oxS3W4xhS8LAU5zNiJzmAdpT3pJnXMuA/ddqYSgz6 JDQoirD6Ukvf1IdmbzmKqEunlTt9v1Mg/7ecmsoPAs3KGWVXHVBKU8+znl8OYRkWHfWM 9IyMLCn5/aGDhAdSLEdj2Aw8FF/3iY8GkNGAGgYaZ0FOux7m2uddELsaDZo8dB+DQQY4 AFWw== 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 qp7si6082230ejb.550.2020.09.13.19.57.06; Sun, 13 Sep 2020 19:57:30 -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 S1725993AbgINC4f (ORCPT + 99 others); Sun, 13 Sep 2020 22:56:35 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:58376 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725973AbgINC4e (ORCPT ); Sun, 13 Sep 2020 22:56:34 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B7ADABA9B79046030BEE; Mon, 14 Sep 2020 10:56:30 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Mon, 14 Sep 2020 10:56:20 +0800 From: Xiongfeng Wang To: , , CC: , , Subject: [PATCH v2] EDAC/mc_sysfs: Add missing newlines when printing {max,dimm}_location Date: Mon, 14 Sep 2020 10:48:54 +0800 Message-ID: <1600051734-8993-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 Sender: linux-kernel-owner@vger.kernel.org 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 --- 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