util_macros.h: add find_closest() macro
This series unduplicates the code used to find the member in an array
closest to 'x'.
The first patch adds a macro implementing the algorithm in two flavors -
for arrays sorted in ascending and descending order. The second updates
Documentation/CodingStyle on the naming convention for local variables in
macros resembling functions. Other three patches replace duplicated code
with calls to one of these macros in some hwmon drivers.
This patch (of 5):
Searching for the member of an array closest to 'x' is duplicated in
several places.
Add a new include - util_macros.h - and two macros that implement this
algorithm for arrays sorted both in ascending and descending order.
Uses linear search.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>