From nobody Mon Dec 1 23:06:23 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 068DF3242B2 for ; Wed, 26 Nov 2025 11:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764157055; cv=none; b=DZHbgJ1IB0JHl6I5Tswt2fbDGzvY/ox+b7g7lTq9JVh58APO21TfXQXahHqilubXTsA77raLLMNV0dML8ajsiEvYBvo4Ht2CGpedJ8E7pmRnclD9vChpMt/UJ9jiJ6yxgGLkECpmYoI0njWVETTvw7b736hePDIRisPKgCgjHA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764157055; c=relaxed/simple; bh=k9rf1evcgOHbfI52abG6ZM4IatEIxMqcv9QQySq3Zww=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gSUINh6pZdD9ErBWiwGj687e9rH3n0M3aP83WgDGFseMwvSmupzxn5avv3SAgxYmEn7FBy+pmL1JL9tZ2lC6ZkqRHxiCEuXv5Ba3ohfHbTBPu6RgcSIGc6vS+IWyTmK7qGKNkeT0fJ5rTu8X4aryqke/Y4sd1NdndJeoZgdtR/4= 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=ZjJzbvuy; arc=none smtp.client-ip=192.198.163.14 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="ZjJzbvuy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764157054; x=1795693054; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=k9rf1evcgOHbfI52abG6ZM4IatEIxMqcv9QQySq3Zww=; b=ZjJzbvuyaCHGJNXLbYw8NdhSoR9UREujIHh9GBL0SUYUvZFbgYOo6frN k2fXdRwyCE82eT9La2G7I7v5GhGBGjSRoB4Gu8Pnra/S5Vw1ilFGyrsG/ tobGdYYg3yljjbo7QtPbto+KiloWlb8CXs7YpG+RMCkCWH5mjaF8JczvV Ssyy9KEWRMXzQjhqTcAUKLRZT8r+2mVbARJ0FBKzvaexgBrQUvCWWc8WV 2LZGHGs/NdghB+mJjH6UB7hOeL3uTB7atsfHrK/gU3nQ6iPN5e9hhg5tm +5Qw1aZkeHGBuQ0vR7s7UD53g9HGX7DivG9LlKBhXWrjV9XRExgKWoXRs A==; X-CSE-ConnectionGUID: ADBHLXn/Q3aZqTgj1+r9tA== X-CSE-MsgGUID: yPjSslXrSBifVOcEgbqBMA== X-IronPort-AV: E=McAfee;i="6800,10657,11624"; a="66232838" X-IronPort-AV: E=Sophos;i="6.20,228,1758610800"; d="scan'208";a="66232838" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Nov 2025 03:37:33 -0800 X-CSE-ConnectionGUID: A72E+rh1TGW25s19+VobVA== X-CSE-MsgGUID: 7dNS3MmkTkKzlCA3VQtVgQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,228,1758610800"; d="scan'208";a="192804445" Received: from lab-ah.igk.intel.com (HELO [127.0.1.1]) ([10.211.135.228]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Nov 2025 03:37:30 -0800 From: Andrzej Hajda Date: Wed, 26 Nov 2025 12:35:49 +0100 Subject: [PATCH 1/3] 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: <20251126-va_format_call-v1-1-8a604a331730@intel.com> References: <20251126-va_format_call-v1-0-8a604a331730@intel.com> In-Reply-To: <20251126-va_format_call-v1-0-8a604a331730@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.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2003; i=andrzej.hajda@intel.com; h=from:subject:message-id; bh=k9rf1evcgOHbfI52abG6ZM4IatEIxMqcv9QQySq3Zww=; b=owEB7QES/pANAwAKASNispPeEP3XAcsmYgBpJuYxH0bYKsvR3i+lxG/l3jrDVxriqdFXPMXak P8UotHxgOmJAbMEAAEKAB0WIQT8qEQxNN2/XeF/A00jYrKT3hD91wUCaSbmMQAKCRAjYrKT3hD9 1/q6C/43BTWbOq9jSZxlivOSeTr9vqXUaAzZvFq2HvmBVuNfpUHGUyro3lyoJ8JKJ2C9Zsx6NRy RuT3AYLODLgUyoW3o5yWlolArXSJn13CQGOPpzRQepvWO4NXdeeoeCnUuaQgR6e+xIMPvhPW6Ke mzXdTWT4LbMs+1Uv5U3QIc0GDpqqxqbQT9LVL2OIFOxjanUshofUOVbU56Qu63f4R/V1+qDjW7K oqWPxqoCLdvup6rD3fI2nFqh+7Tfbp+hPLHrmRVfqcrJHqKWklsLI7iC9t6EhsMiR1ULxiSVWzF d8ODZbjEdVlQGtAdry26N6CXO4JcgNZDwWpQfphK5GLsDh0f/Q+oe3q0HuVcA8O1ITAl6aNq9TQ JVMBNovmp9bc34QPml9SoM2ew0ol8Xogj9Dun64/yG8C9aDfk4ZUMX6gyb2BjG3l9ISa7KdoTK0 WIpahnhKZILdUG+iWxSAVw6tAx9kXYVU68LSp5ldmZrA7GIj3fKqUx3xIZWKRcd1xnSh0= 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 45c663124c9bd3b294031d839f1253f410313faa..6fd817ce29a66b33a804b660c2b= 770efa110ee7e 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