From 2f234c627c84a242a3f100b07f010d8051ce160c Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Wed, 31 Jul 2024 13:22:05 +0200 Subject: [PATCH] scripts: kconfig: Add min/max functions Similar to arithmetic functions, min/max can be useful to use in kconfig. Signed-off-by: Pieter De Gendt --- scripts/kconfig/kconfigfunctions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py index d626bab09b4..c29e039abe8 100644 --- a/scripts/kconfig/kconfigfunctions.py +++ b/scripts/kconfig/kconfigfunctions.py @@ -963,6 +963,10 @@ def arith(kconf, name, *args): return str(int(functools.reduce(operator.truediv, intarray))) elif name == "mod": return str(int(functools.reduce(operator.mod, intarray))) + elif name == "max": + return str(int(functools.reduce(max, intarray))) + elif name == "min": + return str(int(functools.reduce(min, intarray))) else: assert False @@ -1046,6 +1050,8 @@ functions = { "mul": (arith, 1, 255), "div": (arith, 1, 255), "mod": (arith, 1, 255), + "max": (arith, 1, 255), + "min": (arith, 1, 255), "inc": (inc_dec, 1, 255), "dec": (inc_dec, 1, 255), }