]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
documentation: kernel-api: add more info on bitmap functions
authorRandy Dunlap <rdunlap@infradead.org>
Mon, 16 Oct 2017 23:32:51 +0000 (16:32 -0700)
committerJonathan Corbet <corbet@lwn.net>
Thu, 19 Oct 2017 19:01:40 +0000 (13:01 -0600)
There are some good comments about bitmap operations in lib/bitmap.c
and include/linux/bitmap.h, so format them for document generation and
pull them into core-api/kernel-api.rst.

I converted the "tables" of functions from using tabs to using spaces
so that they are more readable in the source file and in the generated
output.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Documentation/core-api/kernel-api.rst
include/linux/bitmap.h
lib/bitmap.c

index 9c6902ba6e67e6e8d652fea2b17bfa40df9fdc33..81754add8a49a2123f5b7bdd8f7bc1d5a458dfd8 100644 (file)
@@ -53,6 +53,18 @@ The Linux kernel provides more basic utility functions.
 Bitmap Operations
 -----------------
 
+.. kernel-doc:: lib/bitmap.c
+   :doc: bitmap introduction
+
+.. kernel-doc:: include/linux/bitmap.h
+   :doc: declare bitmap
+
+.. kernel-doc:: include/linux/bitmap.h
+   :doc: bitmap overview
+
+.. kernel-doc:: include/linux/bitmap.h
+   :doc: bitmap bitops
+
 .. kernel-doc:: lib/bitmap.c
    :export:
 
index 5c4178016b1e63fd338c9a41c95c4e94bcd2ca22..d9974c7a0a61c29f76865a215e2d7aead29a72d0 100644 (file)
  * See lib/bitmap.c for more details.
  */
 
-/*
+/**
+ * DOC: bitmap overview
+ *
  * The available bitmap operations and their rough meaning in the
  * case that the bitmap is a single unsigned long are thus:
  *
  * Note that nbits should be always a compile time evaluable constant.
  * Otherwise many inlines will generate horrible code.
  *
- * bitmap_zero(dst, nbits)                     *dst = 0UL
- * bitmap_fill(dst, nbits)                     *dst = ~0UL
- * bitmap_copy(dst, src, nbits)                        *dst = *src
- * bitmap_and(dst, src1, src2, nbits)          *dst = *src1 & *src2
- * bitmap_or(dst, src1, src2, nbits)           *dst = *src1 | *src2
- * bitmap_xor(dst, src1, src2, nbits)          *dst = *src1 ^ *src2
- * bitmap_andnot(dst, src1, src2, nbits)       *dst = *src1 & ~(*src2)
- * bitmap_complement(dst, src, nbits)          *dst = ~(*src)
- * bitmap_equal(src1, src2, nbits)             Are *src1 and *src2 equal?
- * bitmap_intersects(src1, src2, nbits)        Do *src1 and *src2 overlap?
- * bitmap_subset(src1, src2, nbits)            Is *src1 a subset of *src2?
- * bitmap_empty(src, nbits)                    Are all bits zero in *src?
- * bitmap_full(src, nbits)                     Are all bits set in *src?
- * bitmap_weight(src, nbits)                   Hamming Weight: number set bits
- * bitmap_set(dst, pos, nbits)                 Set specified bit area
- * bitmap_clear(dst, pos, nbits)               Clear specified bit area
- * bitmap_find_next_zero_area(buf, len, pos, n, mask)  Find bit free area
- * bitmap_find_next_zero_area_off(buf, len, pos, n, mask)      as above
- * bitmap_shift_right(dst, src, n, nbits)      *dst = *src >> n
- * bitmap_shift_left(dst, src, n, nbits)       *dst = *src << n
- * bitmap_remap(dst, src, old, new, nbits)     *dst = map(old, new)(src)
- * bitmap_bitremap(oldbit, old, new, nbits)    newbit = map(old, new)(oldbit)
- * bitmap_onto(dst, orig, relmap, nbits)       *dst = orig relative to relmap
- * bitmap_fold(dst, orig, sz, nbits)           dst bits = orig bits mod sz
- * bitmap_parse(buf, buflen, dst, nbits)       Parse bitmap dst from kernel buf
- * bitmap_parse_user(ubuf, ulen, dst, nbits)   Parse bitmap dst from user buf
- * bitmap_parselist(buf, dst, nbits)           Parse bitmap dst from kernel buf
- * bitmap_parselist_user(buf, dst, nbits)      Parse bitmap dst from user buf
- * bitmap_find_free_region(bitmap, bits, order)        Find and allocate bit region
- * bitmap_release_region(bitmap, pos, order)   Free specified bit region
- * bitmap_allocate_region(bitmap, pos, order)  Allocate specified bit region
- * bitmap_from_u32array(dst, nbits, buf, nwords) *dst = *buf (nwords 32b words)
- * bitmap_to_u32array(buf, nwords, src, nbits) *buf = *dst (nwords 32b words)
+ * ::
+ *
+ *  bitmap_zero(dst, nbits)                     *dst = 0UL
+ *  bitmap_fill(dst, nbits)                     *dst = ~0UL
+ *  bitmap_copy(dst, src, nbits)                *dst = *src
+ *  bitmap_and(dst, src1, src2, nbits)          *dst = *src1 & *src2
+ *  bitmap_or(dst, src1, src2, nbits)           *dst = *src1 | *src2
+ *  bitmap_xor(dst, src1, src2, nbits)          *dst = *src1 ^ *src2
+ *  bitmap_andnot(dst, src1, src2, nbits)       *dst = *src1 & ~(*src2)
+ *  bitmap_complement(dst, src, nbits)          *dst = ~(*src)
+ *  bitmap_equal(src1, src2, nbits)             Are *src1 and *src2 equal?
+ *  bitmap_intersects(src1, src2, nbits)        Do *src1 and *src2 overlap?
+ *  bitmap_subset(src1, src2, nbits)            Is *src1 a subset of *src2?
+ *  bitmap_empty(src, nbits)                    Are all bits zero in *src?
+ *  bitmap_full(src, nbits)                     Are all bits set in *src?
+ *  bitmap_weight(src, nbits)                   Hamming Weight: number set bits
+ *  bitmap_set(dst, pos, nbits)                 Set specified bit area
+ *  bitmap_clear(dst, pos, nbits)               Clear specified bit area
+ *  bitmap_find_next_zero_area(buf, len, pos, n, mask)  Find bit free area
+ *  bitmap_find_next_zero_area_off(buf, len, pos, n, mask)  as above
+ *  bitmap_shift_right(dst, src, n, nbits)      *dst = *src >> n
+ *  bitmap_shift_left(dst, src, n, nbits)       *dst = *src << n
+ *  bitmap_remap(dst, src, old, new, nbits)     *dst = map(old, new)(src)
+ *  bitmap_bitremap(oldbit, old, new, nbits)    newbit = map(old, new)(oldbit)
+ *  bitmap_onto(dst, orig, relmap, nbits)       *dst = orig relative to relmap
+ *  bitmap_fold(dst, orig, sz, nbits)           dst bits = orig bits mod sz
+ *  bitmap_parse(buf, buflen, dst, nbits)       Parse bitmap dst from kernel buf
+ *  bitmap_parse_user(ubuf, ulen, dst, nbits)   Parse bitmap dst from user buf
+ *  bitmap_parselist(buf, dst, nbits)           Parse bitmap dst from kernel buf
+ *  bitmap_parselist_user(buf, dst, nbits)      Parse bitmap dst from user buf
+ *  bitmap_find_free_region(bitmap, bits, order)  Find and allocate bit region
+ *  bitmap_release_region(bitmap, pos, order)   Free specified bit region
+ *  bitmap_allocate_region(bitmap, pos, order)  Allocate specified bit region
+ *  bitmap_from_u32array(dst, nbits, buf, nwords)  *dst = *buf (nwords 32b words)
+ *  bitmap_to_u32array(buf, nwords, src, nbits) *buf = *dst (nwords 32b words)
+ *
  */
 
-/*
- * Also the following operations in asm/bitops.h apply to bitmaps.
+/**
+ * DOC: bitmap bitops
+ *
+ * Also the following operations in asm/bitops.h apply to bitmaps.::
+ *
+ *  set_bit(bit, addr)                  *addr |= bit
+ *  clear_bit(bit, addr)                *addr &= ~bit
+ *  change_bit(bit, addr)               *addr ^= bit
+ *  test_bit(bit, addr)                 Is bit set in *addr?
+ *  test_and_set_bit(bit, addr)         Set bit and return old value
+ *  test_and_clear_bit(bit, addr)       Clear bit and return old value
+ *  test_and_change_bit(bit, addr)      Change bit and return old value
+ *  find_first_zero_bit(addr, nbits)    Position first zero bit in *addr
+ *  find_first_bit(addr, nbits)         Position first set bit in *addr
+ *  find_next_zero_bit(addr, nbits, bit)  Position next zero bit in *addr >= bit
+ *  find_next_bit(addr, nbits, bit)     Position next set bit in *addr >= bit
  *
- * set_bit(bit, addr)                  *addr |= bit
- * clear_bit(bit, addr)                        *addr &= ~bit
- * change_bit(bit, addr)               *addr ^= bit
- * test_bit(bit, addr)                 Is bit set in *addr?
- * test_and_set_bit(bit, addr)         Set bit and return old value
- * test_and_clear_bit(bit, addr)       Clear bit and return old value
- * test_and_change_bit(bit, addr)      Change bit and return old value
- * find_first_zero_bit(addr, nbits)    Position first zero bit in *addr
- * find_first_bit(addr, nbits)         Position first set bit in *addr
- * find_next_zero_bit(addr, nbits, bit)        Position next zero bit in *addr >= bit
- * find_next_bit(addr, nbits, bit)     Position next set bit in *addr >= bit
  */
 
-/*
+/**
+ * DOC: declare bitmap
  * The DECLARE_BITMAP(name,bits) macro, in linux/types.h, can be used
  * to declare an array named 'name' of just enough unsigned longs to
  * contain all bit positions from 0 to 'bits' - 1.
index c82c61b66e166b521ff91d4e6055905d7431e6dc..d8f0c094b18eba130571a3e405796040750d9646 100644 (file)
@@ -18,7 +18,9 @@
 
 #include <asm/page.h>
 
-/*
+/**
+ * DOC: bitmap introduction
+ *
  * bitmaps provide an array of bits, implemented using an an
  * array of unsigned longs.  The number of valid bits in a
  * given bitmap does _not_ need to be an exact multiple of