]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
lib: count_zeros: unify count_{leading,trailing}_zeros()
authorYury Norov <ynorov@nvidia.com>
Mon, 23 Mar 2026 16:17:12 +0000 (12:17 -0400)
committerYury Norov <ynorov@nvidia.com>
Mon, 23 Mar 2026 17:33:51 +0000 (13:33 -0400)
commitbe56db15fcce8bb8bd85f236382276d52ce73d08
tree88d0d51b496d8d0aa39364ce39080f68129f7d4f
parent4e64c91b813f666dffc3962a815a8a50b7d6f468
lib: count_zeros: unify count_{leading,trailing}_zeros()

The 'leading' helper returns BITS_PER_LONG if x == 0, while 'trailing'
one returns COUNT_TRAILING_ZEROS_0, which turns to be -1.

None of the current users explicitly check the returned value for
COUNT_TRAILING_ZEROS_0, except the loongarch, which tests implicitly
for the '>= 0'.

So, align count_trailing_zeros() with the count_leading_zeros(), and
simplify the loongarch handling.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Yury Norov <ynorov@nvidia.com>
arch/loongarch/kvm/intc/eiointc.c
include/linux/count_zeros.h