From patchwork Tue Jan 7 10:09:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13928610 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 7BD9DE77197 for ; Tue, 7 Jan 2025 10:09:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B7E36B0088; Tue, 7 Jan 2025 05:09:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 066846B0089; Tue, 7 Jan 2025 05:09:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E22F16B00C1; Tue, 7 Jan 2025 05:09:50 -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 BC0FF6B0088 for ; Tue, 7 Jan 2025 05:09:50 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 47672C0880 for ; Tue, 7 Jan 2025 10:09:50 +0000 (UTC) X-FDA: 82980234540.13.4781573 Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) by imf13.hostedemail.com (Postfix) with ESMTP id D2C8020006 for ; Tue, 7 Jan 2025 10:09:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=ObvnleMY; dmarc=pass (policy=reject) header.from=fujitsu.com; spf=pass (imf13.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 139.138.37.100 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736244588; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=9O4JxoRECoTykDVlHIZkeqdXrS2CVw84Qn1oO/SX+hw=; b=ohoxlt+2wt9LhX/lXTMpfRtc4KG253+oUNuNsCiDmQ1J4sYnPfbgnNaWogQ/w18sU+zTvz 04+b9ZSHgP7PcK5s3RW/z9N1+yuCu2YTIMMt/FyoZH+x+eh8TVz3poJacQgcoWicSOLmSh w+DIrU5aHNtnJ5u3oldWSgxgaPGW71g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736244588; a=rsa-sha256; cv=none; b=m8KgN47G34BBG8VJ1NTnK4iyyK5Dx1hTT0drRx1At0Q3DBwfVNh6IZYWFmCISzZ5IK3x8t QDlTwGpIQeKhrUeKTq4b526aPdoZV8yqXQ2Q35LKgI6pBW75r+vWrWsmPtP0uXlsQs3Zyc tF2CFGy03S+clO9dGpv8DN/PVfXZPQQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=ObvnleMY; dmarc=pass (policy=reject) header.from=fujitsu.com; spf=pass (imf13.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 139.138.37.100 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1736244588; x=1767780588; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=r+tDfpNPRrOppf7K53M+nylNIb2ZE1//XX7Ha6Y/G2Y=; b=ObvnleMY09v8YhVIrt8gmLFaxNgruejY6WQAnTwbNvxEJ3SzIEjFDR06 +rVMQf0oIPHSuuTuPZCT3mpXgDFgnXx7XdxuJw1/yGpgwFzATrwyGhpar x2CXlLJIQfDErU3EDww/E070fyo0PH29hBUf//vi5938pqiooB9aLZB8y R4jsad94mjeYq4HTFP3ArM7tBQE16D4SbVlUMVC/9t8okd5Jpr/BcYl4O dqxUKEJ4Fp8xsO+GeJnAHDoa0j7mhBMWn7AL5a8N8sM/EafEDwU8jBKQd 21NVBBaSfNrmWiRc4BX/glbPGbjFQZEGrGVR2i39COZsOVuDHdPsD8ztI A==; X-CSE-ConnectionGUID: dsL6nVlpSYCyW87KiGNUWQ== X-CSE-MsgGUID: mRWy1/5BT/qq4ZoceCeA0Q== X-IronPort-AV: E=McAfee;i="6700,10204,11307"; a="164747684" X-IronPort-AV: E=Sophos;i="6.12,295,1728918000"; d="scan'208";a="164747684" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jan 2025 19:09:45 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id AAE01D5011 for ; Tue, 7 Jan 2025 19:09:43 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 70302D5097 for ; Tue, 7 Jan 2025 19:09:43 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id F4111200930C7 for ; Tue, 7 Jan 2025 19:09:42 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.135.81]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 2D04C1A0003; Tue, 7 Jan 2025 18:09:42 +0800 (CST) From: Shiyang Ruan To: linux-mm@kvack.org, david@redhat.com, osalvador@suse.de, rafael@kernel.org Subject: [PATCH] drivers/base/memory: simplify outputting of valid_zones_show() Date: Tue, 7 Jan 2025 18:09:41 +0800 Message-ID: <20250107100941.1169222-1-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28908.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28908.003 X-TMASE-Result: 10--3.168900-10.000000 X-TMASE-MatchedRID: zcABQyk7l6mjw14NC3gXsBF4zyLyne+ATJDl9FKHbrmeEPi9wVyFrv7L 3VZcu8PZJjdZvprOsDzbDtH7FSeUzhgHZ8655DOPFEUknJ/kEl5lVdRvgpNpe/oLR4+zsDTtDbL Ql5n/OxxZRohttWiDFa6u/tw6IPEcFm0zAmiHeer4ittC/MrlNHqJMEW+Fi4Wpl5PY5KTL/lhq9 KkAp5azfPwhiZIvbCnH6QnMBWwC6AbbX/JlD33JMLCdvxS7i6JtrD3776b3L0gh1aNqXaEIQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Stat-Signature: 7t8c9ge5e14hepqrw7w1zakgj4r8fh5p X-Rspamd-Queue-Id: D2C8020006 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736244587-650393 X-HE-Meta: U2FsdGVkX1+OWD5JNmSvCWQz268m/pQ8eL7LYVqvDKOhJEz1uSBmqNEQqx5jT1N3bZjiXT6HpT/IUzA6rhH4ziFTg4AqE6WsYWfSyLKGon+mMG3Eymznpl38UMQdecy8L/ekCISMf1J56HH8RiNjZuX3YEBExjJmgp0Zmt5PO02fdsJLKHfPfmoX62Iwf/RcJ1X5wW7Yc2bo3n7WhlR/Lyf0pdma7y/1r6OEhUUdXA7eKC51izwI5HLCjhyWGulIDFIvNNtZ+pPstcvSkFB+mvbHIVmhex4DLB9BPiFnetZj4Z4dYd4CbLQiL7L7j+uHvRamYL853PX9a6lv8DQssTctqQ4GPdpnmtQiwvPHVKNudF4MZ8sCpaaJjdypRU6NzDcMOaS6ewU8kZIDwT5LHg0/m6IiVM6en/2hVsXUxUMLuDg40LJIJFW4JhSydyblQ4+Y7k1WWWo4woXnhuX1x8UTkXUKTGqjNYyFcy7VE1m//kPf8ob6M+8JI4w/jtlwZyUHu8vJYGJ6xEsXeChzW2/NUT2UCsYXEchduqFxpcaDPS5qyqvRGS5bToPWkxYfEQCo3VGzLkCnKg9JDmqO+ukYm4jmUncIZJHUdgPSLPIW19YBr1F16/f8SY5tmD1+vrxYqSte+1T5/lDttSUuzm7ysPtB4UxKK7ro1CR2WJXZGRkCao5hxEFbHv8Y9JM2JPqv/EMVpIDpK4IgKJ8LSNz2OTwq3qbmm334AXB8bHdyTmByAiTONrEyouT/Or+/nxk4YIzfY64ELjd4ZUEY074t4YCPrSaBp953+PeHCUFLjtAGW9pn98HJnmVrtCt4FYEIUw5i/C8FDf7ANDJqO+kW4XY8AHfapsUjmVd2+iqS4xWF16Fw2BDgFl0gyU8zCJw7l7xzwx0Og2AEIERWKHyTLXGdPqx47QaE+4goRQRP3atI8w1Rl7bsAiKz7Wwk3zFaKfU8QA3oHNCl9w8 pEv0dJYb jMsxnUQORskocibQucVRgOYgkRDoFQVy3/BlcUMb9oo8EzWpt3wPbntRe4vU/inJOtPFkr90KWEVpNAqNiY9tco1o/DfM8q2Qr362RzL5Ri5DdpLLsyppaY7rdF4yMrVkEYBDopDOC0kwOuv1CMVHG1iD9gUxpYGSXB4GalNni94ZwnxTQkUbT2P/3Wjc3lP/FBhMU1JcsUFVs/rBWU2pTiSNWXte9gzhOiFv+rwv3SLc+vZa5P5yL/UaatVc1eVoUJTXVrduMhxKck6yvWYs/v5bXwTLiNDW5v56ztIUeXvb4P6X55msedvRWw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000026, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: No need to specific position at the first writing to the buf because the @len is always 0 at this time. Use sysfs_emit() instead to simplify it. Signed-off-by: Shiyang Ruan --- drivers/base/memory.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 67858eeb92ed..d77a83c9af39 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -469,19 +469,17 @@ static ssize_t valid_zones_show(struct device *dev, default_zone = mem->zone; if (!default_zone) return sysfs_emit(buf, "%s\n", "none"); - len += sysfs_emit_at(buf, len, "%s", default_zone->name); - goto out; + return sysfs_emit(buf, "%s\n", default_zone->name); } default_zone = zone_for_pfn_range(MMOP_ONLINE, nid, group, start_pfn, nr_pages); - len += sysfs_emit_at(buf, len, "%s", default_zone->name); + len += sysfs_emit(buf, "%s", default_zone->name); len += print_allowed_zone(buf, len, nid, group, start_pfn, nr_pages, MMOP_ONLINE_KERNEL, default_zone); len += print_allowed_zone(buf, len, nid, group, start_pfn, nr_pages, MMOP_ONLINE_MOVABLE, default_zone); -out: len += sysfs_emit_at(buf, len, "\n"); return len; }