All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/bitmap.c make bitmap_print_bitmask_to_buf parseable
@ 2022-03-26 10:41 Mauro Carvalho Chehab
  2022-03-27 20:04 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2022-03-26 10:41 UTC (permalink / raw)
  To: Yury Norov, Linux Doc Mailing List
  Cc: Mauro Carvalho Chehab, Jonathan Corbet, Andy Shevchenko,
	Rasmus Villemoes, linux-kernel

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 <mchehab@kernel.org>
---
 lib/bitmap.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/lib/bitmap.c b/lib/bitmap.c
index 0d5c2ece0bcb..8ebe508580ea 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -527,33 +527,39 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
  * cpumap_print_to_pagebuf() or directly by drivers to export hexadecimal
  * bitmask and decimal list to userspace by sysfs ABI.
  * Drivers might be using a normal attribute for this kind of ABIs. A
- * normal attribute typically has show entry as below:
- * static ssize_t example_attribute_show(struct device *dev,
+ * normal attribute typically has show entry as below::
+ *
+ *   static ssize_t example_attribute_show(struct device *dev,
  * 		struct device_attribute *attr, char *buf)
- * {
+ *   {
  * 	...
  * 	return bitmap_print_to_pagebuf(true, buf, &mask, nr_trig_max);
- * }
+ *   }
+ *
  * show entry of attribute has no offset and count parameters and this
  * means the file is limited to one page only.
  * bitmap_print_to_pagebuf() API works terribly well for this kind of
- * normal attribute with buf parameter and without offset, count:
- * bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
+ * normal attribute with buf parameter and without offset, count::
+ *
+ *   bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
  * 			   int nmaskbits)
- * {
- * }
+ *   {
+ *   }
+ *
  * The problem is once we have a large bitmap, we have a chance to get a
  * bitmask or list more than one page. Especially for list, it could be
  * as complex as 0,3,5,7,9,... We have no simple way to know it exact size.
  * It turns out bin_attribute is a way to break this limit. bin_attribute
- * has show entry as below:
- * static ssize_t
- * example_bin_attribute_show(struct file *filp, struct kobject *kobj,
+ * has show entry as below::
+ *
+ *   static ssize_t
+ *   example_bin_attribute_show(struct file *filp, struct kobject *kobj,
  * 		struct bin_attribute *attr, char *buf,
  * 		loff_t offset, size_t count)
- * {
+ *   {
  * 	...
- * }
+ *   }
+ *
  * With the new offset and count parameters, this makes sysfs ABI be able
  * to support file size more than one page. For example, offset could be
  * >= 4096.
@@ -577,6 +583,7 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
  * This function is not a replacement for sprintf() or bitmap_print_to_pagebuf().
  * It is intended to workaround sysfs limitations discussed above and should be
  * used carefully in general case for the following reasons:
+ *
  *  - Time complexity is O(nbits^2/count), comparing to O(nbits) for snprintf().
  *  - Memory complexity is O(nbits), comparing to O(1) for snprintf().
  *  - @off and @count are NOT offset and number of bits to print.
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] lib/bitmap.c make bitmap_print_bitmask_to_buf parseable
  2022-03-26 10:41 [PATCH] lib/bitmap.c make bitmap_print_bitmask_to_buf parseable Mauro Carvalho Chehab
@ 2022-03-27 20:04 ` Andy Shevchenko
  2022-03-28  1:11   ` Yury Norov
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-03-27 20:04 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Yury Norov, Linux Doc Mailing List, Jonathan Corbet,
	Andy Shevchenko, Rasmus Villemoes, Linux Kernel Mailing List

On Sat, Mar 26, 2022 at 8:39 PM Mauro Carvalho Chehab
<mchehab@kernel.org> wrote:
>
> 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.

LGTM,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Thanks!

> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
> ---
>  lib/bitmap.c | 33 ++++++++++++++++++++-------------
>  1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/lib/bitmap.c b/lib/bitmap.c
> index 0d5c2ece0bcb..8ebe508580ea 100644
> --- a/lib/bitmap.c
> +++ b/lib/bitmap.c
> @@ -527,33 +527,39 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
>   * cpumap_print_to_pagebuf() or directly by drivers to export hexadecimal
>   * bitmask and decimal list to userspace by sysfs ABI.
>   * Drivers might be using a normal attribute for this kind of ABIs. A
> - * normal attribute typically has show entry as below:
> - * static ssize_t example_attribute_show(struct device *dev,
> + * normal attribute typically has show entry as below::
> + *
> + *   static ssize_t example_attribute_show(struct device *dev,
>   *             struct device_attribute *attr, char *buf)
> - * {
> + *   {
>   *     ...
>   *     return bitmap_print_to_pagebuf(true, buf, &mask, nr_trig_max);
> - * }
> + *   }
> + *
>   * show entry of attribute has no offset and count parameters and this
>   * means the file is limited to one page only.
>   * bitmap_print_to_pagebuf() API works terribly well for this kind of
> - * normal attribute with buf parameter and without offset, count:
> - * bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
> + * normal attribute with buf parameter and without offset, count::
> + *
> + *   bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
>   *                        int nmaskbits)
> - * {
> - * }
> + *   {
> + *   }
> + *
>   * The problem is once we have a large bitmap, we have a chance to get a
>   * bitmask or list more than one page. Especially for list, it could be
>   * as complex as 0,3,5,7,9,... We have no simple way to know it exact size.
>   * It turns out bin_attribute is a way to break this limit. bin_attribute
> - * has show entry as below:
> - * static ssize_t
> - * example_bin_attribute_show(struct file *filp, struct kobject *kobj,
> + * has show entry as below::
> + *
> + *   static ssize_t
> + *   example_bin_attribute_show(struct file *filp, struct kobject *kobj,
>   *             struct bin_attribute *attr, char *buf,
>   *             loff_t offset, size_t count)
> - * {
> + *   {
>   *     ...
> - * }
> + *   }
> + *
>   * With the new offset and count parameters, this makes sysfs ABI be able
>   * to support file size more than one page. For example, offset could be
>   * >= 4096.
> @@ -577,6 +583,7 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
>   * This function is not a replacement for sprintf() or bitmap_print_to_pagebuf().
>   * It is intended to workaround sysfs limitations discussed above and should be
>   * used carefully in general case for the following reasons:
> + *
>   *  - Time complexity is O(nbits^2/count), comparing to O(nbits) for snprintf().
>   *  - Memory complexity is O(nbits), comparing to O(1) for snprintf().
>   *  - @off and @count are NOT offset and number of bits to print.
> --
> 2.35.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] lib/bitmap.c make bitmap_print_bitmask_to_buf parseable
  2022-03-27 20:04 ` Andy Shevchenko
@ 2022-03-28  1:11   ` Yury Norov
  0 siblings, 0 replies; 3+ messages in thread
From: Yury Norov @ 2022-03-28  1:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mauro Carvalho Chehab, Linux Doc Mailing List, Jonathan Corbet,
	Andy Shevchenko, Rasmus Villemoes, Linux Kernel Mailing List

On Sun, Mar 27, 2022 at 11:04:21PM +0300, Andy Shevchenko wrote:
> On Sat, Mar 26, 2022 at 8:39 PM Mauro Carvalho Chehab
> <mchehab@kernel.org> wrote:
> >
> > 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.
> 
> LGTM,
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Thanks!
> 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

Applied to bitmap branch
https://github.com/norov/linux/tree/bitmap

Thanks,
Yury

> > ---
> >  lib/bitmap.c | 33 ++++++++++++++++++++-------------
> >  1 file changed, 20 insertions(+), 13 deletions(-)
> >
> > diff --git a/lib/bitmap.c b/lib/bitmap.c
> > index 0d5c2ece0bcb..8ebe508580ea 100644
> > --- a/lib/bitmap.c
> > +++ b/lib/bitmap.c
> > @@ -527,33 +527,39 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
> >   * cpumap_print_to_pagebuf() or directly by drivers to export hexadecimal
> >   * bitmask and decimal list to userspace by sysfs ABI.
> >   * Drivers might be using a normal attribute for this kind of ABIs. A
> > - * normal attribute typically has show entry as below:
> > - * static ssize_t example_attribute_show(struct device *dev,
> > + * normal attribute typically has show entry as below::
> > + *
> > + *   static ssize_t example_attribute_show(struct device *dev,
> >   *             struct device_attribute *attr, char *buf)
> > - * {
> > + *   {
> >   *     ...
> >   *     return bitmap_print_to_pagebuf(true, buf, &mask, nr_trig_max);
> > - * }
> > + *   }
> > + *
> >   * show entry of attribute has no offset and count parameters and this
> >   * means the file is limited to one page only.
> >   * bitmap_print_to_pagebuf() API works terribly well for this kind of
> > - * normal attribute with buf parameter and without offset, count:
> > - * bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
> > + * normal attribute with buf parameter and without offset, count::
> > + *
> > + *   bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
> >   *                        int nmaskbits)
> > - * {
> > - * }
> > + *   {
> > + *   }
> > + *
> >   * The problem is once we have a large bitmap, we have a chance to get a
> >   * bitmask or list more than one page. Especially for list, it could be
> >   * as complex as 0,3,5,7,9,... We have no simple way to know it exact size.
> >   * It turns out bin_attribute is a way to break this limit. bin_attribute
> > - * has show entry as below:
> > - * static ssize_t
> > - * example_bin_attribute_show(struct file *filp, struct kobject *kobj,
> > + * has show entry as below::
> > + *
> > + *   static ssize_t
> > + *   example_bin_attribute_show(struct file *filp, struct kobject *kobj,
> >   *             struct bin_attribute *attr, char *buf,
> >   *             loff_t offset, size_t count)
> > - * {
> > + *   {
> >   *     ...
> > - * }
> > + *   }
> > + *
> >   * With the new offset and count parameters, this makes sysfs ABI be able
> >   * to support file size more than one page. For example, offset could be
> >   * >= 4096.
> > @@ -577,6 +583,7 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
> >   * This function is not a replacement for sprintf() or bitmap_print_to_pagebuf().
> >   * It is intended to workaround sysfs limitations discussed above and should be
> >   * used carefully in general case for the following reasons:
> > + *
> >   *  - Time complexity is O(nbits^2/count), comparing to O(nbits) for snprintf().
> >   *  - Memory complexity is O(nbits), comparing to O(1) for snprintf().
> >   *  - @off and @count are NOT offset and number of bits to print.
> > --
> > 2.35.1
> >
> 
> 
> -- 
> With Best Regards,
> Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-28  1:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-26 10:41 [PATCH] lib/bitmap.c make bitmap_print_bitmask_to_buf parseable Mauro Carvalho Chehab
2022-03-27 20:04 ` Andy Shevchenko
2022-03-28  1:11   ` Yury Norov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.