linux/drivers/staging
Linus Torvalds e035ca130f 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>
History 2025-10-19 16:21:52 +02:00
..
android staging: android: ashmem: add size field in procfs fdinfo 2021-06-18 13:02:40 +02:00
axis-fifo staging: axis-fifo: flush RX FIFO on read errors 2025-10-19 16:21:28 +02:00
board staging: board: Fix uninitialized spinlock when attaching genpd 2021-07-21 11:22:15 +02:00
clocking-wizard clk: clocking-wizard: Fix Oops in clk_wzrd_register_divider() 2023-07-23 13:47:07 +02:00
emxx_udc staging: emxx_udc: Add checks for dma_alloc_coherent() 2023-03-11 13:57:34 +01:00
fbtft staging: fbtft: fix potential memory leak in fbtft_framebuffer_alloc() 2025-08-28 16:24:06 +02:00
fieldbus staging: fieldbus: Fix the error handling path in anybuss_host_common_probe() 2022-06-14 18:36:04 +02:00
fwserial tty: drop put_tty_driver 2021-07-27 12:17:21 +02:00
gdm724x net: vlan: introduce skb_vlan_eth_hdr() 2023-12-20 15:17:35 +01:00
greybus greybus: arche-ctrl: move device table to its right location 2024-06-16 13:39:35 +02:00
gs_fpgaboot staging: fpgaboot: change FPGA indirect article to an 2021-06-09 14:26:54 +02:00
iio staging: iio: ad5933: Correct settling cycles encoding per datasheet 2025-06-27 11:05:26 +01:00
ks7010 staging: ks7010: disable bh on tx_dev_lock 2024-09-04 13:23:22 +02:00
media minmax: make generic MIN() and MAX() macros available everywhere 2025-10-19 16:21:52 +02:00
most staging: most: dim2: use device release method 2021-12-17 10:30:16 +01:00
mt7621-dma staging/mt7621-dma: mtk-hsdma.c->hsdma-mt7621.c 2021-01-31 13:39:53 +01:00
mt7621-dts staging: mt7621-dts: change palmbus address to lower case 2023-03-03 11:45:53 +01:00
mt7621-pci PCI: mt7621: Add sentinel to quirks table 2022-12-31 13:14:26 +01:00
netlogic drivers: staging: netlogic: fix unmet dependency for PHYLIB 2021-03-26 15:06:15 +01:00
nvec staging: nvec: Fix incorrect null termination of battery manufacturer 2025-08-28 16:24:07 +02:00
octeon dev_ioctl: split out ndo_eth_ioctl 2021-07-27 20:11:45 +01:00
octeon-usb staging: octeon-hcd: Directly include linux/of.h 2021-06-10 13:09:15 +01:00
olpc_dcon kernel.h: split out panic and oops helpers 2021-07-01 11:06:04 -07:00
pi433 staging: pi433: break long lines 2020-09-04 15:39:07 +02:00
qlge IIO / Staging driver update for 5.15-rc1 2021-09-01 09:45:57 -07:00
r8188eu staging: r8188eu: Add Rosewill USB-N150 Nano to device tables 2022-09-28 11:11:38 +02:00
ralink-gdma staging: ralink-gdma: Remove incorrect author information 2021-06-09 12:07:52 +02:00
rtl8192e Revert "staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE" 2023-06-14 11:13:10 +02:00
rtl8192u staging: rtl8192u: Fix use after free in ieee80211_rx() 2022-12-31 13:14:30 +01:00
rtl8712 staging: rtl8712: fix race condition 2023-09-06 21:28:39 +01:00
rtl8723bs staging: rtl8723bs: Avoid memset() in aes_cipher() and aes_decipher() 2025-07-10 15:57:39 +02:00
rts5208 staging: rts5208: Fix get_ms_information() heap buffer size 2021-08-18 10:10:49 +02:00
sm750fb staging: sm750fb: Rename vScreen to v_screen in lynxfb_crtc 2021-07-28 20:17:26 +02:00
unisys staging: unisys: visorhba: Convert module from IDR to XArray 2021-06-15 13:55:11 +02:00
vc04_services staging: vc04_services: fix information leak in create_component() 2024-04-10 16:19:32 +02:00
vme Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2021-02-27 08:07:12 -08:00
vt6655 staging: vt6655: fix potential memory leak 2022-10-26 12:35:47 +02:00
vt6656 staging: vt6656: Remove filenames in files 2021-08-28 08:33:33 +02:00
wfx wifi: wfx: Fix error handling in wfx_core_init() 2024-12-14 19:50:56 +01:00
wlan-ng staging: wlan-ng: Avoid bitwise vs logical OR warning in hfa384x_usb_throttlefn() 2022-01-16 09:12:45 +01:00
Kconfig staging: rtl8188eu: remove rtl8188eu driver from staging dir 2021-08-01 08:10:42 +02:00
Makefile staging: rtl8188eu: remove rtl8188eu driver from staging dir 2021-08-01 08:10:42 +02:00