Re: [PATCH 3/3] Replace for_each_*_bit_from() with for_each_*_bit() where appropriate

From: Andy Shevchenko
Date: Sat Jun 19 2021 - 06:50:13 EST


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