Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4042943pxf; Mon, 29 Mar 2021 19:51:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZVh0GOwH8fMtA5m9o7dOSB9Pg+N6YaSUmEGqy5XRceGDvSqgbeORg+zTIIlTmRRm7JwI9 X-Received: by 2002:a17:907:d8b:: with SMTP id go11mr19655558ejc.167.1617072680756; Mon, 29 Mar 2021 19:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617072680; cv=none; d=google.com; s=arc-20160816; b=w27dRhFlDLay8fzyQ2t2COJvCHfctXEYCZWNqobvFz2Wuc1XraI7vgucreL3JQnYV0 NxsdNfsCyjTjRSDi0E6iyEjwmk2NAew4Kd2KGzKcdPJgFGsg3czjH890dfmOvmxbsZ2l bwmP90N5EUaUDBPHA2H1TjbMd349culpeZYSJOGjj8Rm6xeYKauQQVzYsRwX1+FdN3zl EThoeJTzOT4lvFetLM8gbl/j/gQAI4xkIrXzADTCMkWTieWbF0HDKtWqY/rKsWwLcldN E6vsM3GRb2Qb1tw26qgVOEcsecGMbbPVgWSltW1MJG+MNROW53r6hwMn7o2IvTZea6mj ZyTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=5MTvy36zZa+Mv58Qh/mmOHhyugxj/CbNeQLnAHefpQg=; b=Qmix9QizT5q0LZenLynlpzhynu0wlkJLz+Vkup20esm/k7NfTsHYtrZ5cAyy7AOcyf 8a9Ycdm4l8pnhXqjj4Etqc4tgPNgU5pRTn/F9ylupWJq0C76cM0XHH0s2zd85hLxMcSy JYg9QmYY9Ka1339obaOjpwu8KpESse6v4eeC+9v1rPYV86G8xBk9l3mDLad+JF7NFfWs T7at+xgZKI4D1Y+GsogrEux3LDnsuFTANkJd0+Uj+1ANOm7olD5CV/z9lFQV55ds0w67 xdSx0mZXoqIgt+ST/DcVbID8VF250ZvB96bFUrmPHMsoidcFT5dxbSfatHtObrNYtUYm 8d4Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v25si13979168edx.598.2021.03.29.19.50.58; Mon, 29 Mar 2021 19:51:20 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231299AbhC3Crw (ORCPT + 99 others); Mon, 29 Mar 2021 22:47:52 -0400 Received: from mga03.intel.com ([134.134.136.65]:51772 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231551AbhC3Crp (ORCPT ); Mon, 29 Mar 2021 22:47:45 -0400 IronPort-SDR: jGuBcx3FAEpzNxOAC/nsueGSbGvp8CXsO8Hqyj73Vm4xzSusmwDS/HW+vgXMYBaq4ritvnBvd5 0lkJgrtVmsnw== X-IronPort-AV: E=McAfee;i="6000,8403,9938"; a="191702615" X-IronPort-AV: E=Sophos;i="5.81,289,1610438400"; d="scan'208";a="191702615" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 19:47:44 -0700 IronPort-SDR: Qzy+Sb8DjbopHtwVsOFmuv/fBOz8wgTC0fUUIctntwIrr68QQXH39hNW3SRYKWxuU6NQTgcQhN bU3IgQfHPO6Q== X-IronPort-AV: E=Sophos;i="5.81,289,1610438400"; d="scan'208";a="393434189" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 19:47:44 -0700 Subject: [PATCH v2 1/4] cxl/mem: Use sysfs_emit() for attribute show routines From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Jason Gunthorpe , Ben Widawsky , Jason Gunthorpe , linux-kernel@vger.kernel.org, vishal.l.verma@intel.com, ira.weiny@intel.com, alison.schofield@intel.com Date: Mon, 29 Mar 2021 19:47:44 -0700 Message-ID: <161707246420.2072157.2319415706768984458.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161707245893.2072157.6743322596719518693.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161707245893.2072157.6743322596719518693.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While none the CXL sysfs attributes are threatening to overrun a PAGE_SIZE of output, it is good form to use the recommended helpers. Fixes: b39cb1052a5c ("cxl/mem: Register CXL memX devices") Reported-by: Jason Gunthorpe Reviewed-by: Ben Widawsky Reviewed-by: Jason Gunthorpe Link: https://lore.kernel.org/r/161661971101.1721612.16412318662284948582.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams --- drivers/cxl/mem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index ecfc9ccdba8d..30bf4f0f3c17 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -1066,7 +1066,7 @@ static ssize_t firmware_version_show(struct device *dev, struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_mem *cxlm = cxlmd->cxlm; - return sprintf(buf, "%.16s\n", cxlm->firmware_version); + return sysfs_emit(buf, "%.16s\n", cxlm->firmware_version); } static DEVICE_ATTR_RO(firmware_version); @@ -1076,7 +1076,7 @@ static ssize_t payload_max_show(struct device *dev, struct cxl_memdev *cxlmd = to_cxl_memdev(dev); struct cxl_mem *cxlm = cxlmd->cxlm; - return sprintf(buf, "%zu\n", cxlm->payload_size); + return sysfs_emit(buf, "%zu\n", cxlm->payload_size); } static DEVICE_ATTR_RO(payload_max); @@ -1087,7 +1087,7 @@ static ssize_t ram_size_show(struct device *dev, struct device_attribute *attr, struct cxl_mem *cxlm = cxlmd->cxlm; unsigned long long len = range_len(&cxlm->ram_range); - return sprintf(buf, "%#llx\n", len); + return sysfs_emit(buf, "%#llx\n", len); } static struct device_attribute dev_attr_ram_size = @@ -1100,7 +1100,7 @@ static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr, struct cxl_mem *cxlm = cxlmd->cxlm; unsigned long long len = range_len(&cxlm->pmem_range); - return sprintf(buf, "%#llx\n", len); + return sysfs_emit(buf, "%#llx\n", len); } static struct device_attribute dev_attr_pmem_size =