Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4752232pxf; Tue, 30 Mar 2021 16:40:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfXP4GYZnIDIgtH0tZsk4PtcSpiOCultdhvcFNjg06DRaKY0hCUBvottWNYONKHjYkr8M2 X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr650509ejc.292.1617147604754; Tue, 30 Mar 2021 16:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617147604; cv=none; d=google.com; s=arc-20160816; b=r7ZGCrMNu2LDYsJSwmAEJLZew2xXywmq9R7W+Rc4Ozs0FGmLcyhX26tam1kP5YvJK5 73r8pheXwk/JLX1sQFR5VJ8SmcXvevF1TnYsn+W4t1Lee17knh9n2rEFvb7gWDhC7NJq j3TWyk2b6KrptX09zrKAuxLfUeDmQoSRVtesjQ+swxwZ1Hi27IEV9m8jQ9O2rOxmmbEp bSyWhiiarv9uhJqdgjod1d+GnrCaQPYmt7xIMLACyZY7fm8LDG0XN7+WIbqyMqBKlwSA +EY1AbW3wSCk/hgfe4KDFOHnJClV4NJoOYMrYMH9pIZUyHS8d/kYdDOc/Up1Xv5uL9zX 0eeA== 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=pji5vH0BThGaS1FXrXtzWOSiuSTxP/ZrdUk6p/7yaIXXpiDDPdHBZnlzLfByPMqtx2 EgQ9wbHXGGUUV7M7yJg+ACve+LpvVinANIzZaSZfUYlule1xLjn4YG7DLfYkKXjOLU8o IZ+eLaXY/aADfx0c8qhGRw/ytSh48pkCMdW6dvVoqaQHClL3Z60DEazW2OAAwuMfN95i LJl5Y1NbCKJ2e0WNIUx9d1PGUs5DFXmFpsk6GTChLTge7fgf61GwJaL5CSl9QW8xjQbd hsP1eqrytI7S/E9IUzbpPYDRedV3RibEo1AL2KpbjHRAwBTD4jk4Z++KBFpzMGCviUFX vGFA== 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 f1si223797ejz.585.2021.03.30.16.39.42; Tue, 30 Mar 2021 16:40:04 -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 S232661AbhC3Xgk (ORCPT + 99 others); Tue, 30 Mar 2021 19:36:40 -0400 Received: from mga18.intel.com ([134.134.136.126]:39186 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232662AbhC3Xge (ORCPT ); Tue, 30 Mar 2021 19:36:34 -0400 IronPort-SDR: udoQywIGutk/gpHtp09KY9nm+ZSGOzWMHyHVJLuhCZh+5VJtnIFCIMPp8YGZ/w11hYzIRZ93aw H2nVizgVS26w== X-IronPort-AV: E=McAfee;i="6000,8403,9939"; a="179420782" X-IronPort-AV: E=Sophos;i="5.81,291,1610438400"; d="scan'208";a="179420782" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2021 16:36:32 -0700 IronPort-SDR: iIdbyJTJO6m+aiu6caDKj6FupKs1PBMdMae1aTrxXPgjZAB0PinztRQjDxqsNME5NnaiWlDOxA 3UN/51VxJbvA== X-IronPort-AV: E=Sophos;i="5.81,291,1610438400"; d="scan'208";a="377026408" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2021 16:36:32 -0700 Subject: [PATCH v3 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: Tue, 30 Mar 2021 16:36:31 -0700 Message-ID: <161714739187.2168142.4069783082215231589.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161714738634.2168142.10860201861152789544.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161714738634.2168142.10860201861152789544.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 =