[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250515081332.151250-1-asoponar@taladin.ro>
Date: Thu, 15 May 2025 11:13:16 +0300
From: Alexandru Soponar <asoponar@...adin.ro>
To: linux-kernel@...r.kernel.org,
linux-hwmon@...r.kernel.org,
linux-iio@...r.kernel.org,
linux-leds@...r.kernel.org,
linux-watchdog@...r.kernel.org
Cc: jdelvare@...e.com,
linux@...ck-us.net,
jic23@...nel.org,
pavel@....cz,
lee@...nel.org,
baocheng.su@...mens.com,
wim@...ux-watchdog.org,
tobias.schaffner@...mens.com,
angelogioacchino.delregno@...labora.com,
benedikt.niedermayr@...mens.com,
matthias.bgg@...il.com,
aardelean@...libre.com,
contact@...y.one,
Alexandru Soponar <asoponar@...adin.ro>
Subject: [PATCH 0/16] lib: Refactor find_closest() and find_closest_descending() from macros to lib functions
This patch series converts the find_closest() and find_closest_descending() macros
into proper library functions. The conversion moves these utilities from macro
implementations in util_macros.h to standard C functions in lib/find_closest.c.
The first 15 patches modify individual callers across hwmon, iio, leds, regulator,
and watchdog subsystems to ensure they work correctly with the new function-based
implementation. This maintains compatibility while allowing the final conversion.
The final patch implements the actual refactoring by moving the code to
lib/find_closest.c. This approach was chosen based on discussions between
Andrew Morton and Alexandru Ardelean[1], who suggested that a non-inline
implementation would be appropriate given the size of the functions.
The refactoring avoids of macro expansion-related issues and proper function
prototypes with well-defined parameter types.
Links:
[1] https://lore.kernel.org/lkml/20241105145406.554365-1-aardelean@baylibre.com/
Alexandru Soponar (16):
hwmon: w83795: Fix type incompatibility with non-macro find_closest
hwmon: emc1403: Fix type incompatibility with non-macro find_closest
hwmon: ina3221: Fix type incompatibility with non-macro find_closest
hwmon: lm95234: Fix type incompatibility with non-macro find_closest
hwmon: max1619: Fix type incompatibility with non-macro find_closest
hwmon: lm75: Fix type incompatibility with non-macro find_closest
hwmon: ltc4282: Fix type incompatibility with non-macro find_closest
hwmon: max6639: Fix type incompatibility with non-macro find_closest
hwmon: max20740: Fix type incompatibility with non-macro find_closest
iio: ad7606: Fix type incompatibility with non-macro find_closest
iio: mcp3564: Fix type incompatibility with non-macro find_closest
iio: max44009: Fix type incompatibility with non-macro find_closest
leds: eds-mt6370-rgb: Fix type incompatibility with find_closest()
regulator: max77857: Fix type incompatibility with find_closest()
watchdog: simatic-ipc-wdt: Fix type incompatibility with
find_closest()
lib: move find_closest() and find_closest_descending() to lib
functions
drivers/hwmon/emc1403.c | 2 +-
drivers/hwmon/ina3221.c | 8 +--
drivers/hwmon/lm75.c | 42 +++++++--------
drivers/hwmon/lm95234.c | 2 +-
drivers/hwmon/ltc4282.c | 2 +-
drivers/hwmon/max1619.c | 2 +-
drivers/hwmon/max6639.c | 2 +-
drivers/hwmon/pmbus/max20730.c | 4 +-
drivers/hwmon/w83795.c | 2 +-
drivers/iio/adc/ad7606.c | 8 +--
drivers/iio/adc/mcp3564.c | 2 +-
drivers/iio/light/max44009.c | 2 +-
drivers/leds/rgb/leds-mt6370-rgb.c | 9 ++--
drivers/regulator/max77857-regulator.c | 2 +-
drivers/watchdog/simatic-ipc-wdt.c | 2 +-
include/linux/find_closest.h | 13 +++++
include/linux/util_macros.h | 61 +---------------------
lib/Makefile | 2 +-
lib/find_closest.c | 71 ++++++++++++++++++++++++++
19 files changed, 132 insertions(+), 106 deletions(-)
create mode 100644 include/linux/find_closest.h
create mode 100644 lib/find_closest.c
--
2.49.0
Powered by blists - more mailing lists