linux-yocto/arch
Linus Torvalds 6183c65793 minmax: make generic MIN() and MAX() macros available everywhere
[ Upstream commit 1a251f52cf ]

This just standardizes the use of MIN() and MAX() macros, with the very
traditional semantics.  The goal is to use these for C constant
expressions and for top-level / static initializers, and so be able to
simplify the min()/max() macros.

These macro names were used by various kernel code - they are very
traditional, after all - and all such users have been fixed up, with a
few different approaches:

 - trivial duplicated macro definitions have been removed

   Note that 'trivial' here means that it's obviously kernel code that
   already included all the major kernel headers, and thus gets the new
   generic MIN/MAX macros automatically.

 - non-trivial duplicated macro definitions are guarded with #ifndef

   This is the "yes, they define their own versions, but no, the include
   situation is not entirely obvious, and maybe they don't get the
   generic version automatically" case.

 - strange use case #1

   A couple of drivers decided that the way they want to describe their
   versioning is with

	#define MAJ 1
	#define MIN 2
	#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN)

   which adds zero value and I just did my Alexander the Great
   impersonation, and rewrote that pointless Gordian knot as

	#define DRV_VERSION "1.2"

   instead.

 - strange use case #2

   A couple of drivers thought that it's a good idea to have a random
   'MIN' or 'MAX' define for a value or index into a table, rather than
   the traditional macro that takes arguments.

   These values were re-written as C enum's instead. The new
   function-line macros only expand when followed by an open
   parenthesis, and thus don't clash with enum use.

Happily, there weren't really all that many of these cases, and a lot of
users already had the pattern of using '#ifndef' guarding (or in one
case just using '#undef MIN') before defining their own private version
that does the same thing. I left such cases alone.

Cc: David Laight <David.Laight@aculab.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Eliav Farber <farbere@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-10-02 13:42:55 +02:00
..
alpha alpha/elf: Fix misc/setarch test of util-linux by removing 32bit support 2025-03-22 12:50:41 -07:00
arc ARC: build: Try to guess GCC variant of cross compiler 2025-01-09 13:32:05 +01:00
arm ARM: bcm: Select ARM_GIC_V3 for ARCH_BRCMSTB 2025-10-02 13:42:54 +02:00
arm64 arm64: dts: imx8mp: Correct thermal sensor index 2025-10-02 13:42:49 +02:00
csky of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-09 10:31:56 +01:00
hexagon hexagon: Fix unbalanced spinlock in die() 2025-02-08 09:52:34 +01:00
ia64 vgacon: rework screen_info #ifdef checks 2024-06-27 13:49:15 +02:00
loongarch LoongArch: Check the return value when creating kobj 2025-09-25 11:00:07 +02:00
m68k m68k: Fix lost column on framebuffer debug console 2025-08-28 16:28:33 +02:00
microblaze of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-09 10:31:56 +01:00
mips mips: lantiq: xway: sysctrl: rename the etop node 2025-09-04 15:30:18 +02:00
nios2 of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-09 10:31:56 +01:00
openrisc openrisc: Use asm-generic's version of fix_to_virt() & virt_to_fix() 2024-12-11 16:13:43 +01:00
parisc parisc: Update comments in make_insert_tlb 2025-08-28 16:28:37 +02:00
powerpc powerpc/kvm: Fix ifdef to remove build warning 2025-09-04 15:30:20 +02:00
riscv RISC-V: Remove unnecessary include from compat.h 2025-09-19 16:32:07 +02:00
s390 s390/cpum_cf: Fix uninitialized warning after backport of ce971233242b 2025-10-02 13:42:54 +02:00
sh sh: Do not use hyphen in exported variable name 2025-08-15 12:08:56 +02:00
sparc sparc/mm: avoid calling arch_enter/leave_lazy_mmu() in set_ptes 2025-04-25 10:45:30 +02:00
um minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:42:55 +02:00
x86 minmax: add a few more MIN_T/MAX_T users 2025-09-25 11:00:10 +02:00
xtensa of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify 2024-12-09 10:31:56 +01:00
.gitignore
Kconfig Revert "mm: mmap: allow for the maximum number of bits for randomizing mmap_base by default" 2024-06-27 13:49:15 +02:00