Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1344664rdb; Wed, 24 Jan 2024 12:04:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2dhvzbUy89n86doZSr48DaTnatA3Ao2ojyOKDVzgmTA+UIpyX88YvHTcuEEvY4n09WSq0 X-Received: by 2002:a92:d2ca:0:b0:361:a9af:8f18 with SMTP id w10-20020a92d2ca000000b00361a9af8f18mr2026091ilg.97.1706126689768; Wed, 24 Jan 2024 12:04:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706126689; cv=pass; d=google.com; s=arc-20160816; b=aWliF8SCXu2BNUwgCy9V/x7TFhYBwcZPAY63PwUgfal7DfD0hYCuNMW+l6YoOPN+K1 eo4N39oJ48wTBqKUbK7bugC+3qltxz3wRXJO8UqGoztvu3Zde2yIuHsTKnNeFMr4F8zO KkVNuDUI0Mob8JP/P+SngjVTmp0sc9qA1tdockENWRhGlSQJ8gxhb6FHYs9K4J5sgEY9 i5aRAf1cBPcAepyHUqXS486w0SwoLuOXRMan6NonGHP/OeiuE/PML4fLVVcN8K8AMtZ/ C9BMfPmK7rph4oP6piuIwmVyNPPuLd+fprGvmxDsPagXaOP2ELtk0s0wIQ9hKc3vAJ7j 4kXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=AcC6QAOmr8SGg10jtCgJ40Pni6duinW4+w/MW4U+57s=; fh=+BeaWZRadguR9y+9h7pbJ5UtmwqKwJoFWKh1eOMbEo0=; b=DaEpNurLuLJKAySrQa0RADNULlwJKFqVrMlZ5D9a7JVRK8pGocxxu+LCEsabT2DkK0 zmhhNA7QlWVW2c38eyHF9Kt/a0vRsym3XSRLkphTW4JXtzEfdK9r8hiclQtpa+DB4jfZ zv2nikvB/qzj9MPNP0ZTqoi2qmWvSSJ7MkHQ+VkqDts29KXb8IAaHE5zMenmfEX4Dn+3 AG3Z1UCB37dFaiI6A3eNAmF3QnbpeKakK8feIiCnGBRBffpVaAO0283uyxIz+yPRI8uY y2yi0Lzf9v9bkGpS9VGSijtZF5v/fbb4xzzzQg2TNleXMOVNRnrDimG+UgsZ7mcFaESA D8sw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IqnnQdny; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-37626-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dv21-20020a056122365500b004b28c87427fsi93896vkb.253.2024.01.24.12.04.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 12:04:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37626-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IqnnQdny; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-37626-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 54DAF1C2305C for ; Wed, 24 Jan 2024 20:04:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 859CE1339BD; Wed, 24 Jan 2024 20:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IqnnQdny" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA13E7C091; Wed, 24 Jan 2024 20:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706126666; cv=none; b=iknnCXm8njK6Y0txn+JKK5LAAhesJBxFfFBa2KYXfBVWQdGOPtDFQeWpGqeN4wt6yHnn3v9iunTjTYYjiohgIkZAELXS8W8Xdq3Ajs3jLwqc/NeBhEWpT19F1z/6CDrFmQkPksUd2QWISodM/Ck85PQ/jrLLJ+V+I3r5NW7qO8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706126666; c=relaxed/simple; bh=mYxIOVPok7zj5mr8tVu7SKhQQM/JT9jvpgs14KCdT/k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d7UMchOmWEsdIoKL3Y/w3tRrJ4QRXleNlm69r7rOXnBSydCMQDtzP/p+0x9fqmGJV8B3TzeMTYWe4NR6eoEDTK1pxwUgmfFp80lckbGGQdh1JsCsaH+cCC7mIy39f7iFzcLQyiJXmALBj4LU9t8ssNzrbPJOQZxhc7mQMmAsV3E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IqnnQdny; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com 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="1836101" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1836101" 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() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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 --- 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); -- 2.43.0