From nobody Mon Dec 1 22:03:57 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 36A263009DA for ; Mon, 1 Dec 2025 09:33:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764581613; cv=none; b=adZy48NvCkYBmRRtw654g6vrAqrOSdGdky4Y8C3pM47d+1tDTDaLs0CykaHhF2Xgr9LnZzwLNDU4GiXLgDUY7StzdztzWwqyTWGTj3135zVBLmREeE6bCfpq/gJvtE95c1Cz+DrmIvAW+TajMXqzGxvfpAZs2Bt13BHZIGzTbBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764581613; c=relaxed/simple; bh=BidZ//3QtMfU86Ob65UNf2tBPu4j0g1ruYdm5SKevM8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PneS3omp4Zk61ZhAjxuiB2ZET5McFzFzL6wDM7l5zTOv/dconB2pGy9w9nZYm8XyIOzMb/+ECbwu2qaeKs1s1Qe+l6nLc9uzrHSCPl81E/SbsLglk10tIRT9g/BdFHOqp9BdHSBILIrdW7Esmr4Shz0r5QdrfzuwzBJKtARajlE= 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=WddiyLdc; arc=none smtp.client-ip=192.198.163.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WddiyLdc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764581612; x=1796117612; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=BidZ//3QtMfU86Ob65UNf2tBPu4j0g1ruYdm5SKevM8=; b=WddiyLdcEvyUrVJRJtjmD4xpSit0uFdgXqyS/jVa4AGG/P2Cip6jZsze /Pk8ZRXkLSRE18aQXKkVVx10WUhZcbJvRJzlUznvPUOR2l+vmw3QT6QWo LE7KllWCGrqGBphXjDhHFaraBHUDHuj3O9PVqvJaQnNOCMvkQNk/rw6hx OsGrA4l8bTQHjI+T/gOP6BVXlQRDe0UwDLwmy3Lu0Bp4r6aNuLAETkBGG 3/aqCWHhTc65R48y09xpVGeE9so3aVk9eJlYh7xSKcekxVIc8xjFMcGIO Gy4bABDLtDgSHFeK4ZyQ4GHTXnIAXZfWN3QgdhCtfe7PS/AyIOvPORaKQ g==; X-CSE-ConnectionGUID: CYNkpsalQFebHiFYc9eGAg== X-CSE-MsgGUID: m9s6rX85Qe2koSDrthAaTQ== X-IronPort-AV: E=McAfee;i="6800,10657,11629"; a="66586436" X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="66586436" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2025 01:33:07 -0800 X-CSE-ConnectionGUID: +J98+KRZSvm7YE8YjCy+CQ== X-CSE-MsgGUID: L6Caq9yqTHCBLTiQiLwuTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,240,1758610800"; d="scan'208";a="194014735" Received: from lab-ah.igk.intel.com (HELO [127.0.1.1]) ([10.211.135.228]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2025 01:33:00 -0800 From: Andrzej Hajda Date: Mon, 01 Dec 2025 10:31:22 +0100 Subject: [PATCH v2 1/5] printk: add macros to simplify handling struct va_format 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: quoted-printable Message-Id: <20251201-va_format_call-v2-1-2906f3093b60@intel.com> References: <20251201-va_format_call-v2-0-2906f3093b60@intel.com> In-Reply-To: <20251201-va_format_call-v2-0-2906f3093b60@intel.com> To: Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrzej Hajda X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=1947; i=andrzej.hajda@intel.com; h=from:subject:message-id; bh=BidZ//3QtMfU86Ob65UNf2tBPu4j0g1ruYdm5SKevM8=; b=owEB7QES/pANAwAKASNispPeEP3XAcsmYgBpLWCCqgrlEBLHWYOOFjlFGD6Tu10XWZeK7VfDi s7v0zzoNeGJAbMEAAEKAB0WIQT8qEQxNN2/XeF/A00jYrKT3hD91wUCaS1gggAKCRAjYrKT3hD9 15gVDAClfsOsq5oWz8xyehgotr2qX0EkmLOP4SHstCcoZwpFPmgVpFXJZsbrEQq61BdxV34LMGS RUseDWoRcuoe+E01xsLw/6ML5YqOYeBYhebiw4yLIi+rSgnLkfa3SIiSMxlYvqwTqL7StV50nBy /1Ig+eXoLoOddJtC+dsWQmbBagt97nH1D10ROZ621wfpQ4GV4BuOXk2xt0g0qnpnJarOFtZx5aa UeKzZQC8rzlcODyO9v4NlizeITJjxeF+FGCVP0mTHPRoZmGfOilPj70Ow+35ufdkEvCZw7QZHIY 5eePg5IfX5fJbtnx4rBVUfU2xReXZgRVFQNuc+QXIdHA7jcwMYPp7tjSIFxGRIYJfqCqZNOhBv4 dP5JfXLQbmtf3UyTztapg8k4Hh/PV7DCptMswCWa6jlDQfO5nW8Y0gBg9xgicCOJIzQzseOr1Nn PH45VkUjdFzO5bmNCnLNzdg/t6SYU0oYSUeVCmq6ETxynodehHR6UD/Erlg+kq10ezhVE= X-Developer-Key: i=andrzej.hajda@intel.com; a=openpgp; fpr=FCA8443134DDBF5DE17F034D2362B293DE10FDD7 struct va_format is used to facilitate implementation of variadic functions. Most of variadic users do not parse arguments one by one, they just forward them to some helper via va_format pointer. Introduced helpers simplifies it more. Signed-off-by: Andrzej Hajda --- include/linux/printk.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/linux/printk.h b/include/linux/printk.h index 45c663124c9b..6fd817ce29a6 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -87,6 +87,36 @@ struct va_format { va_list *va; }; =20 +/* Special macro used only by callers of va_format_call to position va_for= mat argument */ +#define va_format_arg (&vaf) + +/** + * va_format_call() - forward variable arguments to va_format aware functi= on + * @_fmt: format used by @_func function + * @_func: function which should be called + * @_args: arguments passed to @_func. Exactly one of them must be va_form= at_arg, + * to indicate position of *va_format type arg in arguments of @_f= unc. + * + * Many variadic functions just forwards their variadic arguments to some = helper + * function via va_format pointer. It involves few common steps encapsulat= ed in + * this macro. The macro is accompanied by va_format_arg macro, described = above. + * Sample implementation of common helper: + * void dev_err(struct device *dev, const char* fmt, ...) + * { + * va_format_call(fmt, pr_err, "%s %s: %pV", dev_driver_string(dev), + * dev_name(dev), va_format_arg); + * } + */ +#define va_format_call(_fmt, _func, _args...) \ +({ \ + va_list ap; \ + struct va_format vaf =3D { .fmt =3D _fmt, .va =3D &ap }; \ + \ + va_start(ap, _fmt); \ + _func(_args); \ + va_end(ap); \ +}) + /* * FW_BUG * Add this to a message where you are sure the firmware is buggy or behav= es --=20 2.43.0