linux-yocto/drivers/hwmon
Linus Torvalds 7d4fa074a2 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:40:43 +02:00
..
occ hwmon: (occ) fix unaligned accesses 2025-06-27 11:07:39 +01:00
peci
pmbus hwmon: (pmbus/max34440) Fix support for max34451 2025-07-06 10:57:54 +02:00
abituguru.c
abituguru3.c
acpi_power_meter.c hwmon: (acpi_power_meter) Fix 4.29 MW bug 2023-12-13 18:39:14 +01:00
ad7314.c hwmon: (ad7314) Validate leading zero bits and return error 2025-03-13 12:53:17 +01:00
ad7414.c
ad7418.c
adc128d818.c hwmon: (adc128d818) Fix underflows seen when writing limit attributes 2024-09-12 11:10:23 +02:00
adcxx.c
adm1021.c
adm1025.c
adm1026.c
adm1029.c
adm1031.c
adm1177.c
adm9240.c
ads7828.c
ads7871.c
adt7x10.c
adt7x10.h
adt7310.c
adt7410.c
adt7411.c
adt7462.c
adt7470.c
adt7475.c minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
aht10.c
amc6821.c hwmon: (amc6821) add of_match table 2024-04-03 15:19:32 +02:00
applesmc.c
aquacomputer_d5next.c hwmon: (aquacomputer_d5next) Add selective 200ms delay after sending ctrl report 2023-08-30 16:11:10 +02:00
as370-hwmon.c
asb100.c
asc7621.c
aspeed-pwm-tacho.c hwmon: (aspeed-pwm-tacho) mutex for tach reading 2024-02-16 19:06:26 +01:00
asus_atk0110.c
asus_wmi_sensors.c
asus-ec-sensors.c hwmon: (asus-ec-sensors) check sensor index in read_string() 2025-06-27 11:07:15 +01:00
atxp1.c
axi-fan-control.c hwmon: (axi-fan-control) Fix possible NULL pointer dereference 2023-11-20 11:51:57 +01:00
bt1-pvt.c
bt1-pvt.h
coretemp.c hwmon: (coretemp) Enlarge per package core count limit 2024-03-01 13:26:29 +01:00
corsair-cpro.c hwmon: (corsair-cpro) Validate the size of the received input buffer 2025-07-24 08:51:52 +02:00
corsair-psu.c hwmon: (corsair-psu) Fix probe when built-in 2024-01-20 11:50:06 +01:00
da9052-hwmon.c
da9055-hwmon.c
dell-smm-hwmon.c hwmon: (dell-smm) Increment the number of fans 2025-06-04 14:40:07 +02:00
dme1737.c
drivetemp.c
ds620.c
ds1621.c
emc6w201.c
emc1403.c
emc2103.c
emc2305.c hwmon: (emc2305) Set initial PWM minimum value during probe based on thermal state 2025-08-28 16:25:59 +02:00
f71805f.c
f71882fg.c hwmon: (f71882fg) prevent possible division by zero 2023-07-19 16:21:19 +02:00
f75375s.c
fam15h_power.c
fschmd.c
ftsteutates.c
g760a.c
g762.c
gl518sm.c
gl520sm.c
gpio-fan.c hwmon: (gpio-fan) Add missing mutex locks 2025-06-04 14:40:10 +02:00
gsc-hwmon.c hwmon: (gsc-hwmon) fix fan pwm setpoint show functions 2025-08-28 16:26:07 +02:00
hih6130.c
hwmon-vid.c
hwmon.c
i5k_amb.c
i5500_temp.c
ibmaem.c
ibmpex.c
ibmpowernv.c
iio_hwmon.c
ina2xx.c
ina209.c
ina238.c
ina3221.c
intel-m10-bmc-hwmon.c
it87.c
jc42.c
k8temp.c
k10temp.c hwmon: (k10temp) Check return value of amd_smn_read() 2024-09-08 07:53:11 +02:00
Kconfig hwmon: (adt7470) Add missing dependency on REGMAP_I2C 2024-10-17 15:22:24 +02:00
lan966x-hwmon.c
lineage-pem.c
lm63.c
lm70.c
lm73.c
lm75.c
lm75.h
lm77.c
lm78.c
lm80.c
lm83.c
lm85.c
lm87.c
lm90.c
lm92.c
lm93.c
lm95234.c hwmon: (lm95234) Fix underflows seen when writing limit attributes 2024-09-12 11:10:23 +02:00
lm95241.c
lm95245.c
lochnagar-hwmon.c
ltc2945.c
ltc2947-core.c
ltc2947-i2c.c
ltc2947-spi.c
ltc2947.h
ltc2990.c
ltc2992.c hwmon: (ltc2992) Fix memory leak in ltc2992_parse_dt() 2024-08-29 17:30:51 +02:00
ltc4151.c
ltc4215.c
ltc4222.c
ltc4245.c
ltc4260.c
ltc4261.c
ltq-cputemp.c
Makefile
max127.c
max197.c
max1111.c
max1619.c
max1668.c
max6620.c
max6621.c
max6639.c
max6642.c
max6650.c
max6697.c hwmon: (max6697) Fix swapped temp{1,8} critical alarms 2024-08-03 08:48:56 +02:00
max16065.c hwmon: (max16065) Fix alarm attributes 2024-10-17 15:20:48 +02:00
max31722.c
max31730.c
max31760.c
max31790.c
mc13783-adc.c
mcp3021.c
menf21bmc_hwmon.c
mlxreg-fan.c hwmon: mlxreg-fan: Prevent fans from getting stuck at 0 RPM 2025-09-09 18:54:22 +02:00
mr75203.c
nct6683.c
nct6775-core.c hwmon: (nct6775-core) Fix out of bounds access for NCT679{8,9} 2025-04-10 14:33:39 +02:00
nct6775-i2c.c
nct6775-platform.c
nct6775.h
nct7802.c hwmon: (nct7802) Fix for temp6 (PECI1) processed even if PECI1 disabled 2023-08-03 10:24:12 +02:00
nct7904.c
npcm750-pwm-fan.c
nsa320-hwmon.c
ntc_thermistor.c hwmon: (ntc_thermistor) Fix the ncpXXxh103 sensor table 2025-03-13 12:53:17 +01:00
nzxt-kraken2.c hwmon: (nzxt-kraken2) Fix error handling path in kraken2_probe() 2023-12-13 18:39:14 +01:00
nzxt-smart2.c hwmon: (nzxt-smart2) add another USB ID 2023-10-10 22:00:37 +02:00
pc87360.c hwmon: (pc87360) Bounds check data->innr usage 2024-08-29 17:30:33 +02:00
pc87427.c
pcf8591.c
powr1220.c
pwm-fan.c
raspberrypi-hwmon.c
s3c-hwmon.c
sbrmi.c
sbtsi_temp.c
sch56xx-common.c Revert "hwmon: (sch56xx-common) Add automatic module loading on supported devices" 2023-11-20 11:51:58 +01:00
sch56xx-common.h
sch5627.c hwmon: (sch5627) Disallow write access if virtual registers are locked 2023-11-20 11:51:58 +01:00
sch5636.c
scmi-hwmon.c
scpi-hwmon.c
sht3x.c
sht4x.c
sht15.c
sht21.c
shtc1.c hwmon: (shtc1) Fix property misspelling 2024-06-12 11:03:59 +02:00
sis5595.c
sl28cpld-hwmon.c
smm665.c
smsc47b397.c
smsc47m1.c
smsc47m192.c
sparx5-temp.c
stts751.c
sy7636a-hwmon.c
tc74.c
tc654.c
thmc50.c
tmp102.c
tmp103.c
tmp108.c
tmp401.c
tmp421.c
tmp464.c
tmp513.c hwmon: (tmp513) Fix division of negative numbers 2025-01-23 17:17:10 +01:00
tps23861.c hwmon: (tps23861) Fix reporting of negative temperatures 2024-12-14 19:53:48 +01:00
ultra45_env.c
vexpress-hwmon.c
via-cputemp.c
via686a.c
vt1211.c
vt8231.c
w83l785ts.c
w83l786ng.c
w83627ehf.c hwmon: (w83627ehf) Fix underflows seen when writing limit attributes 2024-09-12 11:10:23 +02:00
w83627hf.c
w83773g.c
w83781d.c
w83791d.c
w83792d.c
w83793.c
w83795.c
wm831x-hwmon.c
wm8350-hwmon.c
xgene-hwmon.c hwmon: (xgene-hwmon) use appropriate type for the latency value 2025-06-04 14:40:16 +02:00