From patchwork Wed Jan 24 20:03:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 13529616 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A319C46CD2 for ; Wed, 24 Jan 2024 20:04:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 101266B0081; Wed, 24 Jan 2024 15:04:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 089376B0083; Wed, 24 Jan 2024 15:04:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1D416B0085; Wed, 24 Jan 2024 15:04:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D38C56B0081 for ; Wed, 24 Jan 2024 15:04:27 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A52EAA2394 for ; Wed, 24 Jan 2024 20:04:27 +0000 (UTC) X-FDA: 81715281774.15.397970E Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by imf01.hostedemail.com (Postfix) with ESMTP id 6492140011 for ; Wed, 24 Jan 2024 20:04:25 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=IqnnQdny; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf01.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706126665; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AcC6QAOmr8SGg10jtCgJ40Pni6duinW4+w/MW4U+57s=; b=6v2w0zOAjNVHyRaXw6I6Bid8KwrbKstA5HdjzGgUS15LTZwYPPJ4mt++N9PcfSDjP/gKrt VM6WnseYesLDqYl5AEO9TFkXrZzlsvHWefifRJlk0QIO9buLVNzSXEAhmx2+4rfJdAOK/R pBEgDpnw0H3cGyVhS61aQ0NG/bmedl0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=IqnnQdny; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf01.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706126665; a=rsa-sha256; cv=none; b=Eb6ij0I0KjFiGdo67omsEpLKejA4sp8+kTmDVNteQfjhQXADiCXo7Cm4KPV3tReH4e5ZwC HK/E4LCl0eMSU1zi76knjXobvJfce65l6mfkCPYFE0SqhsqKyA0HMPvhVY5TMyDatQ9I0w ATMmeFngoStGpZ1Uk3UzHY4sTM9u5xI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706126665; x=1737662665; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=mYxIOVPok7zj5mr8tVu7SKhQQM/JT9jvpgs14KCdT/k=; b=IqnnQdnyYth76mX8uj/d/jLxPZ+9WJSj5lDRgCFJGYLwQSmZCCWmU+xT OPdBpz3gwOEeW6loZNpbOVD9FCw4RzEbcwodZ05tARsCIwbsOibKL47Ks vzqUZppSXPDIB1DWyjr8q4/il3nRX+vYsyxCActpJ6j8VMR6yb2axnnTZ hh/qwi3BJq7jhVdQ2KkbneKUBSQJi5P5dUv2K86d/aVJY9FQmlJNp6ROi LV6J7fe7OhX6FVNvf+evOs3O8p5cRdg1OeDQxXPocehaqRh9gcJHz8I2l 0yw6PsmnHhN+C6bO7J9HUMUOC1pnOE2E7DPW3nxFCoOAE4VFwRXU1M3Vh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1836106" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1836106" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2024 12:04:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1117735125" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1117735125" Received: from vverma7-mobl3.amr.corp.intel.com (HELO [10.0.0.223]) ([10.251.14.61]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2024 12:04:21 -0800 From: Vishal Verma Date: Wed, 24 Jan 2024 12:03:47 -0800 Subject: [PATCH v7 2/5] dax/bus.c: replace several sprintf() with sysfs_emit() MIME-Version: 1.0 Message-Id: <20240124-vv-dax_abi-v7-2-20d16cb8d23d@intel.com> References: <20240124-vv-dax_abi-v7-0-20d16cb8d23d@intel.com> In-Reply-To: <20240124-vv-dax_abi-v7-0-20d16cb8d23d@intel.com> To: Dan Williams , Vishal Verma , Dave Jiang , Andrew Morton , Oscar Salvador Cc: linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, David Hildenbrand , Dave Hansen , Huang Ying , Greg Kroah-Hartman , Matthew Wilcox , linux-mm@kvack.org X-Mailer: b4 0.13-dev-a684c X-Developer-Signature: v=1; a=openpgp-sha256; l=5299; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=mYxIOVPok7zj5mr8tVu7SKhQQM/JT9jvpgs14KCdT/k=; b=owGbwMvMwCXGf25diOft7jLG02pJDKkbc51aNcyLd59M+vAnQJuv9cKWC28PyIbMOhQbrPNRb 5Gwv/eUjlIWBjEuBlkxRZa/ez4yHpPbns8TmOAIM4eVCWQIAxenAExkWxfD/+qY2iizk+avOY5J 8LJd2RK2fdbEB2ZbOKZFZ3Xsal646Bgjw5SvBW9Pvevi+zG/+cnxb//auSw3rG44w/3KtfNY85z J+XwA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6492140011 X-Stat-Signature: dd63ui8scfpj6nf5neow95epwgcterre X-Rspam-User: X-HE-Tag: 1706126665-238234 X-HE-Meta: U2FsdGVkX19o6bzQcDdp9FGk+kUdYdkIgq9qshZr7VweOeCv7ivMCKaOgpDz5UPcRq9Ly1nEtOGmLiqiVZGN8FoW9mvYR80aJJA2Fk5IdETjpJH1i/ecgeTzcfujr/0JTplN+6c5TL+3m1MUEcCGyShhwThnt2PeWoGFqyNMKo6ABrID4dalIXmfYyDJUdwiRkx7LBhagvfNxdA3jnLoX9DRKUFygzLOmQgbLVmQ7ANeAL8ONBdZ5/hPEqVX277+0KTh1ns3H2DBPNOMhK6/J1xYMCwauwBsDTKm2HC5UENxkqo1Yg0sNGb9xIyKy3SasmBizEIQtlxuny5vOYn1ez+09RmR78M3TQTYHuIryt6lBYKB8SS7w94G7FC8t2ggdkTJKhGHGAvwKOK01az/I5KZG2urLp23uzaE9hRz41Q8cvqYNmj9XzAN3WC7wZEh1z5rmT6mmmSDlHCAwf1Xg/7GyQMOOjsF129IXzLFv/FHJbC4iX5pZsgDPMUDE/P9JPPGyAfy3dJcVRys7O1E2h9ckdTwT7L8zKQ14KA5/EC4szTSWRgXfj7EbNLzpvrkEUwcUlIUUDxBp3AniV/Ge7sc9db6kh5HV97XZhbV489di66yyhF3aEuigP+RAPUkwEoCs/qnmVjj0LMbzfh2GqLio22AzDbQe8F+Lnd+M8ln0Hk5z7BPEPk/gd6nc+O7+aOI9OVhd244BybUnRmuKWOCkeZdL8czSZ3DwSs5Md0iu2TK6xuZ+yf27WnjoygSrqIc+rXTwSjsgH79YpgVXT0rRSaIQSdjLxjpe6u+5PQRptKG/UlVxPjjWQqbAm6bMICVahJbovOw7fglyty9tiAAwg8AHQd3RSXFrMxOZV+UIkSBrkSfxzBRoFkuvnsWFoTvL/Xr0eLdgoT8NNbQ9y/Tm+mBQN2OY7mCQYcUZ+oAOtHm+FtisukKYBPeRcmqdxB1RXPrFmyrR11ltU/ sbjkB9/D HHVQX/QI/2pWXI9wdzVI8Ov74wH8cwWPFrjN/I0E4uzgkc7N1AwnQ/67XOwVAs/m+f1PnWqbWQyLiwbJftqGb3Zw0coOp2PZeqaituNgLeRUFOZj6FRattqh1+7iQUQfUOutXD0YzcUu4Jxs8h+FHewOelroY1smhCn3SzQkD2s6OcYQsnWjYHgSQgIqdJBj//nYA5EPdsLtZFn05y6OBySeXVM8pBQ3jB3rSK0dyILGekODHaCvt5FhJW1X0zv92Hvu+cxWB7x1P8cZSm7uXT+eTZg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: There were several places where drivers/dax/bus.c uses 'sprintf' to print sysfs data. Since a sysfs_emit() helper is available specifically for this purpose, replace all the sprintf() usage for sysfs with sysfs_emit() in this file. Cc: Dan Williams Reported-by: Greg Kroah-Hartman Signed-off-by: Vishal Verma Reviewed-by: Alison Schofield --- drivers/dax/bus.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index cb148f74ceda..0fd948a4443e 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -269,7 +269,7 @@ static ssize_t id_show(struct device *dev, { struct dax_region *dax_region = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", dax_region->id); + return sysfs_emit(buf, "%d\n", dax_region->id); } static DEVICE_ATTR_RO(id); @@ -278,8 +278,8 @@ static ssize_t region_size_show(struct device *dev, { struct dax_region *dax_region = dev_get_drvdata(dev); - return sprintf(buf, "%llu\n", (unsigned long long) - resource_size(&dax_region->res)); + return sysfs_emit(buf, "%llu\n", + (unsigned long long)resource_size(&dax_region->res)); } static struct device_attribute dev_attr_region_size = __ATTR(size, 0444, region_size_show, NULL); @@ -289,7 +289,7 @@ static ssize_t region_align_show(struct device *dev, { struct dax_region *dax_region = dev_get_drvdata(dev); - return sprintf(buf, "%u\n", dax_region->align); + return sysfs_emit(buf, "%u\n", dax_region->align); } static struct device_attribute dev_attr_region_align = __ATTR(align, 0400, region_align_show, NULL); @@ -322,7 +322,7 @@ static ssize_t available_size_show(struct device *dev, size = dax_region_avail_size(dax_region); up_read(&dax_region_rwsem); - return sprintf(buf, "%llu\n", size); + return sysfs_emit(buf, "%llu\n", size); } static DEVICE_ATTR_RO(available_size); @@ -340,7 +340,7 @@ static ssize_t seed_show(struct device *dev, if (rc) return rc; seed = dax_region->seed; - rc = sprintf(buf, "%s\n", seed ? dev_name(seed) : ""); + rc = sysfs_emit(buf, "%s\n", seed ? dev_name(seed) : ""); up_read(&dax_region_rwsem); return rc; @@ -361,7 +361,7 @@ static ssize_t create_show(struct device *dev, if (rc) return rc; youngest = dax_region->youngest; - rc = sprintf(buf, "%s\n", youngest ? dev_name(youngest) : ""); + rc = sysfs_emit(buf, "%s\n", youngest ? dev_name(youngest) : ""); up_read(&dax_region_rwsem); return rc; @@ -763,7 +763,7 @@ static ssize_t start_show(struct device *dev, dax_range = get_dax_range(dev); if (!dax_range) return -ENXIO; - rc = sprintf(buf, "%#llx\n", dax_range->range.start); + rc = sysfs_emit(buf, "%#llx\n", dax_range->range.start); put_dax_range(); return rc; @@ -779,7 +779,7 @@ static ssize_t end_show(struct device *dev, dax_range = get_dax_range(dev); if (!dax_range) return -ENXIO; - rc = sprintf(buf, "%#llx\n", dax_range->range.end); + rc = sysfs_emit(buf, "%#llx\n", dax_range->range.end); put_dax_range(); return rc; @@ -795,7 +795,7 @@ static ssize_t pgoff_show(struct device *dev, dax_range = get_dax_range(dev); if (!dax_range) return -ENXIO; - rc = sprintf(buf, "%#lx\n", dax_range->pgoff); + rc = sysfs_emit(buf, "%#lx\n", dax_range->pgoff); put_dax_range(); return rc; @@ -969,7 +969,7 @@ static ssize_t size_show(struct device *dev, size = dev_dax_size(dev_dax); up_write(&dax_dev_rwsem); - return sprintf(buf, "%llu\n", size); + return sysfs_emit(buf, "%llu\n", size); } static bool alloc_is_aligned(struct dev_dax *dev_dax, resource_size_t size) @@ -1233,7 +1233,7 @@ static ssize_t align_show(struct device *dev, { struct dev_dax *dev_dax = to_dev_dax(dev); - return sprintf(buf, "%d\n", dev_dax->align); + return sysfs_emit(buf, "%d\n", dev_dax->align); } static ssize_t dev_dax_validate_align(struct dev_dax *dev_dax) @@ -1311,7 +1311,7 @@ static ssize_t target_node_show(struct device *dev, { struct dev_dax *dev_dax = to_dev_dax(dev); - return sprintf(buf, "%d\n", dev_dax_target_node(dev_dax)); + return sysfs_emit(buf, "%d\n", dev_dax_target_node(dev_dax)); } static DEVICE_ATTR_RO(target_node); @@ -1327,7 +1327,7 @@ static ssize_t resource_show(struct device *dev, else start = dev_dax->ranges[0].range.start; - return sprintf(buf, "%#llx\n", start); + return sysfs_emit(buf, "%#llx\n", start); } static DEVICE_ATTR(resource, 0400, resource_show, NULL); @@ -1338,14 +1338,14 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, * We only ever expect to handle device-dax instances, i.e. the * @type argument to MODULE_ALIAS_DAX_DEVICE() is always zero */ - return sprintf(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0); + return sysfs_emit(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0); } static DEVICE_ATTR_RO(modalias); static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%d\n", dev_to_node(dev)); + return sysfs_emit(buf, "%d\n", dev_to_node(dev)); } static DEVICE_ATTR_RO(numa_node);