lkml.org 
[lkml]   [2021]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] Replace for_each_*_bit_from() with for_each_*_bit() where appropriate
On Fri, Jun 18, 2021 at 12:57:35PM -0700, Yury Norov wrote:
> A couple of kernel functions call for_each_*_bit_from() with start
> bit equal to 0. Replace them with for_each_*_bit().
>
> No functional changes, but might improve on readability.

...

> --- a/drivers/hwmon/ltc2992.c
> +++ b/drivers/hwmon/ltc2992.c
> @@ -248,8 +248,7 @@ static int ltc2992_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask
>
> gpio_status = reg;
>
> - gpio_nr = 0;
> - for_each_set_bit_from(gpio_nr, mask, LTC2992_GPIO_NR) {
> + for_each_set_bit(gpio_nr, mask, LTC2992_GPIO_NR) {
> if (test_bit(LTC2992_GPIO_BIT(gpio_nr), &gpio_status))
> set_bit(gpio_nr, bits);
> }

I would replace the entire loop by bitmap_replace() call.

Something like
bitmap_replace(bits, bits, &gpio_status, mask, LTC2992_GPIO_NR);

(Good to split sometimes :-)

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2021-06-19 12:50    [W:0.122 / U:2.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site