Skip to content

Commit 430cd4a

Browse files
mchehabYuryNorov
authored andcommitted
lib/bitmap.c make bitmap_print_bitmask_to_buf parseable
The documentation of such function is not on a proper ReST format, as reported by Sphinx: Documentation/core-api/kernel-api:81: ./lib/bitmap.c:532: WARNING: Unexpected indentation. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:526: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:532: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:532: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:533: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:536: WARNING: Definition list ends without a blank line; unexpected unindent. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:542: WARNING: Unexpected indentation. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:536: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:536: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:543: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:552: WARNING: Unexpected indentation. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:545: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:545: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:552: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:552: WARNING: Inline emphasis start-string without end-string. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:554: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:556: WARNING: Definition list ends without a blank line; unexpected unindent. Documentation/core-api/kernel-api:81: ./lib/bitmap.c:580: WARNING: Unexpected indentation. So, the produced output at: https://www.kernel.org/doc/html/latest/core-api/kernel-api.html?#c.bitmap_print_bitmask_to_buf is broken. Fix it by adding spaces and marking the literal blocks. Signed-off-by: Mauro Carvalho Chehab <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Yury Norov <[email protected]>
1 parent c6bc5a3 commit 430cd4a

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

lib/bitmap.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -527,33 +527,39 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
527527
* cpumap_print_to_pagebuf() or directly by drivers to export hexadecimal
528528
* bitmask and decimal list to userspace by sysfs ABI.
529529
* Drivers might be using a normal attribute for this kind of ABIs. A
530-
* normal attribute typically has show entry as below:
531-
* static ssize_t example_attribute_show(struct device *dev,
530+
* normal attribute typically has show entry as below::
531+
*
532+
* static ssize_t example_attribute_show(struct device *dev,
532533
* struct device_attribute *attr, char *buf)
533-
* {
534+
* {
534535
* ...
535536
* return bitmap_print_to_pagebuf(true, buf, &mask, nr_trig_max);
536-
* }
537+
* }
538+
*
537539
* show entry of attribute has no offset and count parameters and this
538540
* means the file is limited to one page only.
539541
* bitmap_print_to_pagebuf() API works terribly well for this kind of
540-
* normal attribute with buf parameter and without offset, count:
541-
* bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
542+
* normal attribute with buf parameter and without offset, count::
543+
*
544+
* bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
542545
* int nmaskbits)
543-
* {
544-
* }
546+
* {
547+
* }
548+
*
545549
* The problem is once we have a large bitmap, we have a chance to get a
546550
* bitmask or list more than one page. Especially for list, it could be
547551
* as complex as 0,3,5,7,9,... We have no simple way to know it exact size.
548552
* It turns out bin_attribute is a way to break this limit. bin_attribute
549-
* has show entry as below:
550-
* static ssize_t
551-
* example_bin_attribute_show(struct file *filp, struct kobject *kobj,
553+
* has show entry as below::
554+
*
555+
* static ssize_t
556+
* example_bin_attribute_show(struct file *filp, struct kobject *kobj,
552557
* struct bin_attribute *attr, char *buf,
553558
* loff_t offset, size_t count)
554-
* {
559+
* {
555560
* ...
556-
* }
561+
* }
562+
*
557563
* With the new offset and count parameters, this makes sysfs ABI be able
558564
* to support file size more than one page. For example, offset could be
559565
* >= 4096.
@@ -577,6 +583,7 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
577583
* This function is not a replacement for sprintf() or bitmap_print_to_pagebuf().
578584
* It is intended to workaround sysfs limitations discussed above and should be
579585
* used carefully in general case for the following reasons:
586+
*
580587
* - Time complexity is O(nbits^2/count), comparing to O(nbits) for snprintf().
581588
* - Memory complexity is O(nbits), comparing to O(1) for snprintf().
582589
* - @off and @count are NOT offset and number of bits to print.

0 commit comments

Comments
 (0)