Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/linear_ranges: Add linear_range_get_selector_high_array

Add a helper function to find the selector for a given value in a linear
range array. The selector should be such that the value it represents
should be higher or equal to the given value.

Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://patch.msgid.link/20260325-max77759-charger-v9-4-4486dd297adc@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Amit Sunil Dhamne and committed by
Greg Kroah-Hartman
f23388d0 b422f7c0

+39
+3
include/linux/linear_range.h
··· 57 57 int linear_range_get_selector_low_array(const struct linear_range *r, 58 58 int ranges, unsigned int val, 59 59 unsigned int *selector, bool *found); 60 + int linear_range_get_selector_high_array(const struct linear_range *r, 61 + int ranges, unsigned int val, 62 + unsigned int *selector, bool *found); 60 63 61 64 #endif
+36
lib/linear_ranges.c
··· 242 242 EXPORT_SYMBOL_GPL(linear_range_get_selector_high); 243 243 244 244 /** 245 + * linear_range_get_selector_high_array - return linear range selector for value 246 + * @r: pointer to array of linear ranges where selector is looked from 247 + * @ranges: amount of ranges to scan from array 248 + * @val: value for which the selector is searched 249 + * @selector: address where found selector value is updated 250 + * @found: flag to indicate that given value was in the range 251 + * 252 + * Scan array of ranges for selector for which range value matches given 253 + * input value. Value is matching if it is equal or higher than given value 254 + * If given value is found to be in a range scanning is stopped and @found is 255 + * set true. If a range with values greater than given value is found 256 + * but the range min is being greater than given value, then the range's 257 + * lowest selector is updated to @selector and scanning is stopped. 258 + * 259 + * Return: 0 on success, -EINVAL if range array is invalid or does not contain 260 + * range with a value greater or equal to given value 261 + */ 262 + int linear_range_get_selector_high_array(const struct linear_range *r, 263 + int ranges, unsigned int val, 264 + unsigned int *selector, bool *found) 265 + { 266 + int i; 267 + int ret; 268 + 269 + for (i = 0; i < ranges; i++) { 270 + ret = linear_range_get_selector_high(&r[i], val, selector, 271 + found); 272 + if (!ret) 273 + return 0; 274 + } 275 + 276 + return -EINVAL; 277 + } 278 + EXPORT_SYMBOL_GPL(linear_range_get_selector_high_array); 279 + 280 + /** 245 281 * linear_range_get_selector_within - return linear range selector for value 246 282 * @r: pointer to linear range where selector is looked from 247 283 * @val: value for which the selector is searched