linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/16] lib: Refactor find_closest() and find_closest_descending() from macros to lib functions
@ 2025-05-15  8:13 Alexandru Soponar
  2025-05-15  8:13 ` [PATCH 01/16] hwmon: w83795: Fix type incompatibility with non-macro find_closest Alexandru Soponar
                   ` (16 more replies)
  0 siblings, 17 replies; 24+ messages in thread
From: Alexandru Soponar @ 2025-05-15  8:13 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon, linux-iio, linux-leds, linux-watchdog
  Cc: jdelvare, linux, jic23, pavel, lee, baocheng.su, wim,
	tobias.schaffner, angelogioacchino.delregno, benedikt.niedermayr,
	matthias.bgg, aardelean, contact, Alexandru Soponar

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


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2025-05-22 14:33 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15  8:13 [PATCH 0/16] lib: Refactor find_closest() and find_closest_descending() from macros to lib functions Alexandru Soponar
2025-05-15  8:13 ` [PATCH 01/16] hwmon: w83795: Fix type incompatibility with non-macro find_closest Alexandru Soponar
2025-05-15  8:13 ` [PATCH 02/16] hwmon: emc1403: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 03/16] hwmon: ina3221: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 04/16] hwmon: lm95234: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 05/16] hwmon: max1619: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 06/16] hwmon: lm75: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 07/16] hwmon: ltc4282: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 08/16] hwmon: max6639: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 09/16] hwmon: max20740: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 10/16] iio: ad7606: " Alexandru Soponar
2025-05-15 17:13   ` Jonathan Cameron
2025-05-15  8:13 ` [PATCH 11/16] iio: mcp3564: " Alexandru Soponar
2025-05-15 17:14   ` Jonathan Cameron
2025-05-19  8:09   ` Marius.Cristea
2025-05-15  8:13 ` [PATCH 12/16] iio: max44009: " Alexandru Soponar
2025-05-15 17:14   ` Jonathan Cameron
2025-05-15  8:13 ` [PATCH 13/16] leds: eds-mt6370-rgb: Fix type incompatibility with find_closest() Alexandru Soponar
2025-05-22 14:33   ` Lee Jones
2025-05-15  8:13 ` [PATCH 14/16] regulator: max77857: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 15/16] watchdog: simatic-ipc-wdt: " Alexandru Soponar
2025-05-15  8:13 ` [PATCH 16/16] lib: move find_closest() and find_closest_descending() to lib functions Alexandru Soponar
2025-05-19 16:35   ` David Lechner
2025-05-19 15:44 ` [PATCH 0/16] lib: Refactor find_closest() and find_closest_descending() from macros " Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).