Skip to content
Commit de5f8433 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by David S. Miller
Browse files

lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers



These helpers scatters or gathers a bitmap with the help of the mask
position bits parameter.

bitmap_scatter() does the following:
  src:  0000000001011010
                  ||||||
           +------+|||||
           |  +----+||||
           |  |+----+|||
           |  ||   +-+||
           |  ||   |  ||
  mask: ...v..vv...v..vv
        ...0..11...0..10
  dst:  0000001100000010

and bitmap_gather() performs this one:
   mask: ...v..vv...v..vv
   src:  0000001100000010
            ^  ^^   ^   0
            |  ||   |  10
            |  ||   > 010
            |  |+--> 1010
            |  +--> 11010
            +----> 011010
   dst:  0000000000011010

bitmap_gather() can the seen as the reverse bitmap_scatter() operation.

Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/lkml/20230926052007.3917389-3-andriy.shevchenko@linux.intel.com/


Co-developed-by: default avatarHerve Codina <herve.codina@bootlin.com>
Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
Acked-by: default avatarYury Norov <yury.norov@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 79699228
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment