qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/32] kernel-doc: update from Linux 5.10
@ 2020-12-01 10:34 Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 01/32] docs: temporarily disable the kernel-doc extension Paolo Bonzini
                   ` (32 more replies)
  0 siblings, 33 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

v1->v2: fix bisectability (by disabling kernel-doc altogether)
	pass Sphinx version from docs/sphinx/kerneldoc.py
	remove unnecessary s/atomic_/qatomic_/ difference

Alexander A. Klimov (1):
  Replace HTTP links with HTTPS ones: documentation

André Almeida (2):
  kernel-doc: fix processing nested structs with attributes
  kernel-doc: add support for ____cacheline_aligned_in_smp attribute

Jonathan Cameron (1):
  kernel-doc: add support for ____cacheline_aligned attribute

Jonathan Neuschäfer (1):
  scripts/kernel-doc: Add support for named variable macro arguments

Mauro Carvalho Chehab (19):
  scripts: kernel-doc: proper handle @foo->bar()
  scripts: kernel-doc: accept negation like !@var
  scripts: kernel-doc: accept blank lines on parameter description
  scripts/kernel-doc: parse __ETHTOOL_DECLARE_LINK_MODE_MASK
  scripts/kernel-doc: handle function pointer prototypes
  kernel-doc: include line numbers for function prototypes
  scripts: kernel-doc: add support for typedef enum
  scripts: kernel-doc: make it more compatible with Sphinx 3.x
  scripts: kernel-doc: use a less pedantic markup for funcs on Sphinx
    3.x
  scripts: kernel-doc: fix troubles with line counts
  scripts: kernel-doc: reimplement -nofunction argument
  scripts: kernel-doc: fix typedef identification
  scripts: kernel-doc: don't mangle with parameter list
  scripts: kernel-doc: allow passing desired Sphinx C domain dialect
  scripts: kernel-doc: fix line number handling
  scripts: kernel-doc: try to use c:function if possible
  scripts: kernel-doc: fix typedef parsing
  scripts: kernel-doc: split typedef complex regex
  scripts: kernel-doc: use :c:union when needed

Paolo Bonzini (7):
  docs: temporarily disable the kernel-doc extension
  Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with
    arguments"
  Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later"
  Revert "kernel-doc: Handle function typedefs without asterisks"
  Revert "kernel-doc: Handle function typedefs that return pointers"
  Revert "docs: temporarily disable the kernel-doc extension"
  scripts: kernel-doc: remove unnecesssary change wrt Linux

Pierre-Louis Bossart (1):
  scripts/kernel-doc: optionally treat warnings as errors

 docs/sphinx/kerneldoc.py |   6 +-
 scripts/kernel-doc       | 455 +++++++++++++++++++++++++++------------
 2 files changed, 324 insertions(+), 137 deletions(-)

-- 
2.26.2



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

* [PATCH v2 01/32] docs: temporarily disable the kernel-doc extension
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 11:01   ` Peter Maydell
  2020-12-01 10:34 ` [PATCH v2 02/32] kernel-doc: fix processing nested structs with attributes Paolo Bonzini
                   ` (31 subsequent siblings)
  32 siblings, 1 reply; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

Preserve bisectability while we update scripts/kernel-doc from Linux.
Without this patch, building with Sphinx 3 would break while we
revert our own Sphinx 3 support and replace it with Linux's.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 docs/sphinx/kerneldoc.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index 3ac277d162..9124fcbff1 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -75,6 +75,9 @@ class KernelDocDirective(Directive):
         # Tell sphinx of the dependency
         env.note_dependency(os.path.abspath(filename))
 
+        # Disabled temporarily while scripts/kernel-doc is updated
+        return []
+
         tab_width = self.options.get('tab-width', self.state.document.settings.tab_width)
 
         # FIXME: make this nicer and more robust against errors
-- 
2.26.2




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

* [PATCH v2 02/32] kernel-doc: fix processing nested structs with attributes
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 01/32] docs: temporarily disable the kernel-doc extension Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 03/32] kernel-doc: add support for ____cacheline_aligned_in_smp attribute Paolo Bonzini
                   ` (30 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: André Almeida <andrealmeid@collabora.com>

The current regular expression for strip attributes of structs (and
for nested ones as well) also removes all whitespaces that may
surround the attribute. After that, the code will split structs and
iterate for each symbol separated by comma at the end of struct
definition (e.g. "} alias1, alias2;"). However, if the nested struct
does not have any alias and has an attribute, it will result in a
empty string at the closing bracket (e.g "};"). This will make the
split return nothing and $newmember will keep uninitialized. Fix
that, by ensuring that the attribute substitution will leave at least
one whitespace.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-2-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 4fbaaa05e3..d6bdb77ceb 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1103,10 +1103,10 @@ sub dump_struct($$) {
 	# strip comments:
 	$members =~ s/\/\*.*?\*\///gos;
 	# strip attributes
-	$members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)//gi;
-	$members =~ s/\s*__aligned\s*\([^;]*\)//gos;
-	$members =~ s/\s*__packed\s*//gos;
-	$members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos;
+	$members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)/ /gi;
+	$members =~ s/\s*__aligned\s*\([^;]*\)/ /gos;
+	$members =~ s/\s*__packed\s*/ /gos;
+	$members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos;
 	# replace DECLARE_BITMAP
 	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
 	# replace DECLARE_HASHTABLE
-- 
2.26.2




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

* [PATCH v2 03/32] kernel-doc: add support for ____cacheline_aligned_in_smp attribute
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 01/32] docs: temporarily disable the kernel-doc extension Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 02/32] kernel-doc: fix processing nested structs with attributes Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 04/32] scripts/kernel-doc: Add support for named variable macro arguments Paolo Bonzini
                   ` (29 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: André Almeida <andrealmeid@collabora.com>

Subroutine dump_struct uses type attributes to check if the struct
syntax is valid. Then, it removes all attributes before using it for
output. `____cacheline_aligned_in_smp` is an attribute that is
not included in both steps. Add it, since it is used by kernel structs.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-3-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index d6bdb77ceb..2f421b7313 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1092,7 +1092,7 @@ sub dump_struct($$) {
     my $x = shift;
     my $file = shift;
 
-    if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) {
+    if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|____cacheline_aligned_in_smp|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) {
 	my $decl_type = $1;
 	$declaration_name = $2;
 	my $members = $3;
@@ -1107,6 +1107,7 @@ sub dump_struct($$) {
 	$members =~ s/\s*__aligned\s*\([^;]*\)/ /gos;
 	$members =~ s/\s*__packed\s*/ /gos;
 	$members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos;
+	$members =~ s/\s*____cacheline_aligned_in_smp/ /gos;
 	# replace DECLARE_BITMAP
 	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
 	# replace DECLARE_HASHTABLE
-- 
2.26.2




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

* [PATCH v2 04/32] scripts/kernel-doc: Add support for named variable macro arguments
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (2 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 03/32] kernel-doc: add support for ____cacheline_aligned_in_smp attribute Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 05/32] scripts: kernel-doc: proper handle @foo->bar() Paolo Bonzini
                   ` (28 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

Currently, when kernel-doc encounters a macro with a named variable
argument[1], such as this:

   #define hlist_for_each_entry_rcu(pos, head, member, cond...)

... it expects the variable argument to be documented as `cond...`,
rather than `cond`. This is semantically wrong, because the name (as
used in the macro body) is actually `cond`.

With this patch, kernel-doc will accept the name without dots (`cond`
in the example above) in doc comments, and warn if the name with dots
(`cond...`) is used and verbose mode[2] is enabled.

The support for the `cond...` syntax can be removed later, when the
documentation of all such macros has been switched to the new syntax.

Testing this patch on top of v5.4-rc6, `make htmldocs` shows a few
changes in log output and HTML output:

 1) The following warnings[3] are eliminated:

   ./include/linux/rculist.h:374: warning:
        Excess function parameter 'cond' description in 'list_for_each_entry_rcu'
   ./include/linux/rculist.h:651: warning:
        Excess function parameter 'cond' description in 'hlist_for_each_entry_rcu'

 2) For list_for_each_entry_rcu and hlist_for_each_entry_rcu, the
    correct description is shown

 3) Named variable arguments are shown without dots

[1]: https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
[2]: scripts/kernel-doc -v
[3]: See also https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?h=dev&id=5bc4bc0d6153617eabde275285b7b5a8137fdf3c

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-4-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 2f421b7313..0f67664165 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1480,6 +1480,10 @@ sub push_parameter($$$$) {
 	      # handles unnamed variable parameters
 	      $param = "...";
 	    }
+	    elsif ($param =~ /\w\.\.\.$/) {
+	      # for named variable parameters of the form `x...`, remove the dots
+	      $param =~ s/\.\.\.$//;
+	    }
 	    if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") {
 		$parameterdescs{$param} = "variable arguments";
 	    }
@@ -1967,6 +1971,18 @@ sub process_name($$) {
 sub process_body($$) {
     my $file = shift;
 
+    # Until all named variable macro parameters are
+    # documented using the bare name (`x`) rather than with
+    # dots (`x...`), strip the dots:
+    if ($section =~ /\w\.\.\.$/) {
+	$section =~ s/\.\.\.$//;
+
+	if ($verbose) {
+	    print STDERR "${file}:$.: warning: Variable macro arguments should be documented without dots\n";
+	    ++$warnings;
+	}
+    }
+
     if (/$doc_sect/i) { # case insensitive for supported section names
 	$newsection = $1;
 	$newcontents = $2;
-- 
2.26.2




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

* [PATCH v2 05/32] scripts: kernel-doc: proper handle @foo->bar()
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (3 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 04/32] scripts/kernel-doc: Add support for named variable macro arguments Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 06/32] scripts: kernel-doc: accept negation like !@var Paolo Bonzini
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

The pattern @foo->bar() is valid, as it can be used by a
function pointer inside a struct passed as a parameter.

Right now, it causes a warning:

	./drivers/firewire/core-transaction.c:606: WARNING: Inline strong start-string without end-string.

In this specific case, the kernel-doc markup is:

	/**
	 * fw_core_remove_address_handler() - unregister an address handler
	 * @handler: callback
	 *
	 * To be called in process context.
	 *
	 * When fw_core_remove_address_handler() returns, @handler->callback() is
	 * guaranteed to not run on any CPU anymore.
	 */

With seems valid on my eyes. So, instead of trying to hack
the kernel-doc markup, let's teach it about how to handle
such things. This should likely remove lots of other similar
warnings as well.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/48b46426d7bf6ff7529f20e5718fbf4e9758e62c.1586881715.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-5-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 0f67664165..99530fb08b 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -216,6 +216,7 @@ my $type_constant2 = '\%([-_\w]+)';
 my $type_func = '(\w+)\(\)';
 my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
 my $type_fp_param = '\@(\w+)\(\)';  # Special RST handling for func ptr params
+my $type_fp_param2 = '\@(\w+->\S+)\(\)';  # Special RST handling for structs with func ptr params
 my $type_env = '(\$\w+)';
 my $type_enum = '#(enum\s*([_\w]+))';
 my $type_struct = '#(struct\s*([_\w]+))';
@@ -251,6 +252,7 @@ my @highlights_rst = (
                        [$type_member_func, "\\:c\\:type\\:`\$1\$2\$3\\\\(\\\\) <\$1>`"],
                        [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"],
 		       [$type_fp_param, "**\$1\\\\(\\\\)**"],
+		       [$type_fp_param2, "**\$1\\\\(\\\\)**"],
                        [$type_func, "\$1()"],
                        [$type_enum, "\\:c\\:type\\:`\$1 <\$2>`"],
                        [$type_struct, "\\:c\\:type\\:`\$1 <\$2>`"],
-- 
2.26.2




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

* [PATCH v2 06/32] scripts: kernel-doc: accept negation like !@var
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (4 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 05/32] scripts: kernel-doc: proper handle @foo->bar() Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 07/32] scripts: kernel-doc: accept blank lines on parameter description Paolo Bonzini
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

On a few places, it sometimes need to indicate a negation of a
parameter, like:

	!@fshared

This pattern happens, for example, at:

	kernel/futex.c

and it is perfectly valid. However, kernel-doc currently
transforms it into:

	!**fshared**

This won't do what it would be expected.

Fortunately, fixing the script is a simple matter of storing
the "!" before "@" and adding it after the bold markup, like:

	**!fshared**

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/0314b47f8c3e1f9db00d5375a73dc3cddd8a21f2.1586881715.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-6-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 99530fb08b..e4b3cd486f 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -215,6 +215,7 @@ my $type_constant = '\b``([^\`]+)``\b';
 my $type_constant2 = '\%([-_\w]+)';
 my $type_func = '(\w+)\(\)';
 my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
+my $type_param_ref = '([\!]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
 my $type_fp_param = '\@(\w+)\(\)';  # Special RST handling for func ptr params
 my $type_fp_param2 = '\@(\w+->\S+)\(\)';  # Special RST handling for structs with func ptr params
 my $type_env = '(\$\w+)';
@@ -239,6 +240,7 @@ my @highlights_man = (
                       [$type_typedef, "\\\\fI\$1\\\\fP"],
                       [$type_union, "\\\\fI\$1\\\\fP"],
                       [$type_param, "\\\\fI\$1\\\\fP"],
+                      [$type_param_ref, "\\\\fI\$1\$2\\\\fP"],
                       [$type_member, "\\\\fI\$1\$2\$3\\\\fP"],
                       [$type_fallback, "\\\\fI\$1\\\\fP"]
 		     );
@@ -260,7 +262,7 @@ my @highlights_rst = (
                        [$type_union, "\\:c\\:type\\:`\$1 <\$2>`"],
                        # in rst this can refer to any type
                        [$type_fallback, "\\:c\\:type\\:`\$1`"],
-                       [$type_param, "**\$1**"]
+                       [$type_param_ref, "**\$1\$2**"]
 		      );
 my $blankline_rst = "\n";
 
-- 
2.26.2




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

* [PATCH v2 07/32] scripts: kernel-doc: accept blank lines on parameter description
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (5 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 06/32] scripts: kernel-doc: accept negation like !@var Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 08/32] Replace HTTP links with HTTPS ones: documentation Paolo Bonzini
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Sphinx is very pedantic with respect to blank lines. Sometimes,
in order to make it to properly handle something, we need to
add a blank line. However, currently, any blank line inside a
kernel-doc comment like:

	/*
	 * @foo: bar
         *
	 *       foobar
	 *
	 * some description

will be considered as if "foobar" was part of the description.

This patch changes kernel-doc behavior. After it, foobar will
be considered as part of the parameter text. The description
will only be considered as such if it starts with:

zero spaces after asterisk:

	*foo

one space after asterisk:
	* foo

or have a explicit Description section:

	*   Description:

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/c07d2862792d75a2691d69c9eceb7b89a0164cc0.1586881715.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-7-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e4b3cd486f..95f2d7adcf 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -334,13 +334,14 @@ my $lineprefix="";
 
 # Parser states
 use constant {
-    STATE_NORMAL        => 0, # normal code
-    STATE_NAME          => 1, # looking for function name
-    STATE_BODY_MAYBE    => 2, # body - or maybe more description
-    STATE_BODY          => 3, # the body of the comment
-    STATE_PROTO         => 4, # scanning prototype
-    STATE_DOCBLOCK      => 5, # documentation block
-    STATE_INLINE        => 6, # gathering documentation outside main block
+    STATE_NORMAL        => 0,        # normal code
+    STATE_NAME          => 1,        # looking for function name
+    STATE_BODY_MAYBE    => 2,        # body - or maybe more description
+    STATE_BODY          => 3,        # the body of the comment
+    STATE_BODY_WITH_BLANK_LINE => 4, # the body, which has a blank line
+    STATE_PROTO         => 5,        # scanning prototype
+    STATE_DOCBLOCK      => 6,        # documentation block
+    STATE_INLINE        => 7,        # gathering doc outside main block
 };
 my $state;
 my $in_doc_sect;
@@ -1987,6 +1988,12 @@ sub process_body($$) {
 	}
     }
 
+    if ($state == STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) {
+	dump_section($file, $section, $contents);
+	$section = $section_default;
+	$contents = "";
+    }
+
     if (/$doc_sect/i) { # case insensitive for supported section names
 	$newsection = $1;
 	$newcontents = $2;
@@ -2040,18 +2047,21 @@ sub process_body($$) {
 	$state = STATE_PROTO;
 	$brcount = 0;
     } elsif (/$doc_content/) {
-	# miguel-style comment kludge, look for blank lines after
-	# @parameter line to signify start of description
 	if ($1 eq "") {
-	    if ($section =~ m/^@/ || $section eq $section_context) {
+	    if ($section eq $section_context) {
 		dump_section($file, $section, $contents);
 		$section = $section_default;
 		$contents = "";
 		$new_start_line = $.;
+		$state = STATE_BODY;
 	    } else {
+		if ($section ne $section_default) {
+		    $state = STATE_BODY_WITH_BLANK_LINE;
+		} else {
+		    $state = STATE_BODY;
+		}
 		$contents .= "\n";
 	    }
-	    $state = STATE_BODY;
 	} elsif ($state == STATE_BODY_MAYBE) {
 	    # Continued declaration purpose
 	    chomp($declaration_purpose);
@@ -2203,7 +2213,8 @@ sub process_file($) {
 	    process_normal();
 	} elsif ($state == STATE_NAME) {
 	    process_name($file, $_);
-	} elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) {
+	} elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE ||
+		 $state == STATE_BODY_WITH_BLANK_LINE) {
 	    process_body($file, $_);
 	} elsif ($state == STATE_INLINE) { # scanning for inline parameters
 	    process_inline($file, $_);
-- 
2.26.2




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

* [PATCH v2 08/32] Replace HTTP links with HTTPS ones: documentation
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (6 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 07/32] scripts: kernel-doc: accept blank lines on parameter description Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 09/32] scripts/kernel-doc: parse __ETHTOOL_DECLARE_LINK_MODE_MASK Paolo Bonzini
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: "Alexander A. Klimov" <grandmaster@al2klimov.de>

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  For each line:
    If doesn't contain `\bxmlns\b`:
      For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
        If both the HTTP and HTTPS versions
        return 200 OK and serve the same content:
          Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Link: https://lore.kernel.org/r/20200526060544.25127-1-grandmaster@al2klimov.de
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-8-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 95f2d7adcf..fadc2f5b86 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -324,7 +324,7 @@ if (defined($ENV{'KBUILD_VERBOSE'})) {
 
 # Generated docbook code is inserted in a template at a point where
 # docbook v3.1 requires a non-zero sequence of RefEntry's; see:
-# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
+# https://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
 # We keep track of number of generated entries and generate a dummy
 # if needs be to ensure the expanded template can be postprocessed
 # into html.
-- 
2.26.2




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

* [PATCH v2 09/32] scripts/kernel-doc: parse __ETHTOOL_DECLARE_LINK_MODE_MASK
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (7 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 08/32] Replace HTTP links with HTTPS ones: documentation Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 10/32] scripts/kernel-doc: handle function pointer prototypes Paolo Bonzini
                   ` (23 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

The __ETHTOOL_DECLARE_LINK_MODE_MASK macro is a variant of
DECLARE_BITMAP(), used by phylink.h. As we have already a
parser for DECLARE_BITMAP(), let's add one for this macro,
in order to avoid such warnings:

	./include/linux/phylink.h:54: warning: Function parameter or member '__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising' not described in 'phylink_link_state'
	./include/linux/phylink.h:54: warning: Function parameter or member '__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising' not described in 'phylink_link_state'

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/d1d1dea67a28117c0b0c33271b139c4455fef287.1592895969.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-9-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index fadc2f5b86..e8fff6a525 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1113,7 +1113,9 @@ sub dump_struct($$) {
 	$members =~ s/\s*__packed\s*/ /gos;
 	$members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos;
 	$members =~ s/\s*____cacheline_aligned_in_smp/ /gos;
+
 	# replace DECLARE_BITMAP
+	$members =~ s/__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)/DECLARE_BITMAP($1, __ETHTOOL_LINK_MODE_MASK_NBITS)/gos;
 	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
 	# replace DECLARE_HASHTABLE
 	$members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
-- 
2.26.2




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

* [PATCH v2 10/32] scripts/kernel-doc: handle function pointer prototypes
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (8 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 09/32] scripts/kernel-doc: parse __ETHTOOL_DECLARE_LINK_MODE_MASK Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 11/32] scripts/kernel-doc: optionally treat warnings as errors Paolo Bonzini
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

There are some function pointer prototypes inside the net
includes, like this one:

	int (*pcs_config)(struct phylink_config *config, unsigned int mode,
			  phy_interface_t interface, const unsigned long *advertising);

There's nothing wrong using it with kernel-doc, but we need to
add a rule for it to parse such kind of prototype.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/fec520dd731a273013ae06b7653a19c7d15b9562.1592895969.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-10-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e8fff6a525..1cdece23fb 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1801,6 +1801,11 @@ sub process_proto_function($$) {
 	$prototype =~ s@/\*.*?\*/@@gos;	# strip comments.
 	$prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
 	$prototype =~ s@^\s+@@gos; # strip leading spaces
+
+	 # Handle prototypes for function pointers like:
+	 # int (*pcs_config)(struct foo)
+	$prototype =~ s@^(\S+\s+)\(\s*\*(\S+)\)@$1$2@gos;
+
 	if ($prototype =~ /SYSCALL_DEFINE/) {
 		syscall_munge();
 	}
-- 
2.26.2




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

* [PATCH v2 11/32] scripts/kernel-doc: optionally treat warnings as errors
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (9 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 10/32] scripts/kernel-doc: handle function pointer prototypes Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 12/32] kernel-doc: include line numbers for function prototypes Paolo Bonzini
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

The kbuild bot recently added the W=1 option, which triggered
documentation cleanups to squelch hundreds of kernel-doc warnings.

To make sure new kernel contributions don't add regressions to
kernel-doc descriptors, this patch suggests an option to treat
warnings as errors in CI/automated tests.

A -Werror command-line option is added to the kernel-doc script. When
this option is set, the script will return the number of warnings
found. The caller can then treat this positive return value as an
error and stop the build.

Using this command line option is however not straightforward when the
kernel-doc script is called from other scripts. To align with typical
kernel compilation or documentation generation, the Werror option is
also set by checking the KCFLAGS environment variable, or if
KDOC_WERROR is defined, as in the following examples:

KCFLAGS="-Wall -Werror" make W=1 sound/
KCFLAGS="-Wall -Werror" make W=1 drivers/soundwire/
KDOC_WERROR=1 make htmldocs

Note that in the last example the documentation build does not stop,
only an additional log is provided.

Credits to Randy Dunlap for suggesting the use of environment variables.

Suggested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200728162040.92467-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-11-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 1cdece23fb..eb635eb94c 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -83,6 +83,7 @@ Output selection modifiers:
 Other parameters:
   -v			Verbose output, more warnings and other information.
   -h			Print this help.
+  -Werror		Treat warnings as errors.
 
 EOF
     print $message;
@@ -275,6 +276,7 @@ my $kernelversion;
 my $dohighlight = "";
 
 my $verbose = 0;
+my $Werror = 0;
 my $output_mode = "rst";
 my $output_preformatted = 0;
 my $no_doc_sections = 0;
@@ -322,6 +324,18 @@ if (defined($ENV{'KBUILD_VERBOSE'})) {
 	$verbose = "$ENV{'KBUILD_VERBOSE'}";
 }
 
+if (defined($ENV{'KDOC_WERROR'})) {
+	$Werror = "$ENV{'KDOC_WERROR'}";
+}
+
+if (defined($ENV{'KCFLAGS'})) {
+	my $kcflags = "$ENV{'KCFLAGS'}";
+
+	if ($kcflags =~ /Werror/) {
+		$Werror = 1;
+	}
+}
+
 # Generated docbook code is inserted in a template at a point where
 # docbook v3.1 requires a non-zero sequence of RefEntry's; see:
 # https://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
@@ -436,6 +450,8 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
 	push(@export_file_list, $file);
     } elsif ($cmd eq "v") {
 	$verbose = 1;
+    } elsif ($cmd eq "Werror") {
+	$Werror = 1;
     } elsif (($cmd eq "h") || ($cmd eq "help")) {
 	usage();
     } elsif ($cmd eq 'no-doc-sections') {
@@ -2292,4 +2308,9 @@ if ($verbose && $warnings) {
   print STDERR "$warnings warnings\n";
 }
 
-exit($output_mode eq "none" ? 0 : $errors);
+if ($Werror && $warnings) {
+    print STDERR "$warnings warnings as Errors\n";
+    exit($warnings);
+} else {
+    exit($output_mode eq "none" ? 0 : $errors)
+}
-- 
2.26.2




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

* [PATCH v2 12/32] kernel-doc: include line numbers for function prototypes
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (10 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 11/32] scripts/kernel-doc: optionally treat warnings as errors Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 13/32] kernel-doc: add support for ____cacheline_aligned attribute Paolo Bonzini
                   ` (20 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

This should solve bad error reports like this one:

	./include/linux/iio/iio.h:0: WARNING: Unknown target name: "devm".

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/56eed0ba50cd726236acd12b11b55ce54854c5ea.1599660067.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-12-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index eb635eb94c..3fd6f3925e 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1624,6 +1624,8 @@ sub dump_function($$) {
     my $file = shift;
     my $noret = 0;
 
+    print_lineno($.);
+
     $prototype =~ s/^static +//;
     $prototype =~ s/^extern +//;
     $prototype =~ s/^asmlinkage +//;
-- 
2.26.2




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

* [PATCH v2 13/32] kernel-doc: add support for ____cacheline_aligned attribute
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (11 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 12/32] kernel-doc: include line numbers for function prototypes Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 14/32] scripts: kernel-doc: add support for typedef enum Paolo Bonzini
                   ` (19 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Subroutine dump_struct uses type attributes to check if the struct
syntax is valid. Then, it removes all attributes before using it for
output. `____cacheline_aligned` is an attribute that is
not included in both steps. Add it, since it is used by kernel structs.

Based on previous patch to add ____cacheline_aligned_in_smp.
Motivated by patches to reorder this attribute to before the
variable name.   Whilst we could do that in all cases, that would
be a massive change and it is more common in the kernel to place
this particular attribute after the variable name. A quick grep
suggests approximately 400 instances of which 341 have this
attribute just before a semicolon and hence after the variable name.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20200910185415.653139-1-jic23@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-13-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 3fd6f3925e..c4c5640ded 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1113,7 +1113,7 @@ sub dump_struct($$) {
     my $x = shift;
     my $file = shift;
 
-    if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|____cacheline_aligned_in_smp|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) {
+    if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|____cacheline_aligned_in_smp|____cacheline_aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) {
 	my $decl_type = $1;
 	$declaration_name = $2;
 	my $members = $3;
@@ -1129,6 +1129,7 @@ sub dump_struct($$) {
 	$members =~ s/\s*__packed\s*/ /gos;
 	$members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos;
 	$members =~ s/\s*____cacheline_aligned_in_smp/ /gos;
+	$members =~ s/\s*____cacheline_aligned/ /gos;
 
 	# replace DECLARE_BITMAP
 	$members =~ s/__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)/DECLARE_BITMAP($1, __ETHTOOL_LINK_MODE_MASK_NBITS)/gos;
-- 
2.26.2




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

* [PATCH v2 14/32] scripts: kernel-doc: add support for typedef enum
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (12 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 13/32] kernel-doc: add support for ____cacheline_aligned attribute Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 15/32] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments" Paolo Bonzini
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

The PHY kernel-doc markup has gained support for documenting
a typedef enum.

However, right now the parser was not prepared for it.

So, add support for parsing it.

Fixes: 4069a572d423 ("net: phy: Document core PHY structures")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-14-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index c4c5640ded..073f72c7da 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1295,14 +1295,22 @@ sub show_warnings($$) {
 sub dump_enum($$) {
     my $x = shift;
     my $file = shift;
+    my $members;
+
 
     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
     # strip #define macros inside enums
     $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
 
-    if ($x =~ /enum\s+(\w*)\s*\{(.*)\}/) {
+    if ($x =~ /typedef\s+enum\s*\{(.*)\}\s*(\w*)\s*;/) {
+	$declaration_name = $2;
+	$members = $1;
+    } elsif ($x =~ /enum\s+(\w*)\s*\{(.*)\}/) {
 	$declaration_name = $1;
-	my $members = $2;
+	$members = $2;
+    }
+
+    if ($declaration_name) {
 	my %_members;
 
 	$members =~ s/\s+$//;
@@ -1337,8 +1345,7 @@ sub dump_enum($$) {
 			    'sections' => \%sections,
 			    'purpose' => $declaration_purpose
 			   });
-    }
-    else {
+    } else {
 	print STDERR "${file}:$.: error: Cannot parse enum!\n";
 	++$errors;
     }
-- 
2.26.2




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

* [PATCH v2 15/32] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments"
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (13 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 14/32] scripts: kernel-doc: add support for typedef enum Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 16/32] Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later" Paolo Bonzini
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

This reverts commit 92bb29f9b2c3d4a98eef5f0db935d4be291eec72.
We will replace the commit with the fix from Linux.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-15-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 073f72c7da..cb603532ed 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -860,23 +860,7 @@ sub output_function_rst(%) {
 	output_highlight_rst($args{'purpose'});
 	$start = "\n\n**Syntax**\n\n  ``";
     } else {
-        if ((split(/\./, $sphinx_version))[0] >= 3) {
-            # Sphinx 3 and later distinguish macros and functions and
-            # complain if you use c:function with something that's not
-            # syntactically valid as a function declaration.
-            # We assume that anything with a return type is a function
-            # and anything without is a macro.
-            if ($args{'functiontype'} ne "") {
-                print ".. c:function:: ";
-            } else {
-                print ".. c:macro:: ";
-            }
-        } else {
-            # Older Sphinx don't support documenting macros that take
-            # arguments with c:macro, and don't complain about the use
-            # of c:function for this.
-            print ".. c:function:: ";
-        }
+	print ".. c:function:: ";
     }
     if ($args{'functiontype'} ne "") {
 	$start .= $args{'functiontype'} . " " . $args{'function'} . " (";
-- 
2.26.2




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

* [PATCH v2 16/32] Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later"
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (14 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 15/32] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments" Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 17/32] scripts: kernel-doc: make it more compatible with Sphinx 3.x Paolo Bonzini
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

This reverts commit 152d1967f650f67b7ece3a5dda77d48069d72647.
We will replace the commit with the fix from Linux.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-16-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 docs/sphinx/kerneldoc.py |  1 -
 scripts/kernel-doc       | 16 +---------------
 2 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index 9124fcbff1..c0180e02a2 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -102,7 +102,6 @@ class KernelDocDirective(Directive):
                 env.note_dependency(os.path.abspath(f))
                 cmd += ['-export-file', f]
 
-        cmd += ['-sphinx-version', sphinx.__version__]
         cmd += [filename]
 
         try:
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index cb603532ed..60f75cd176 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -71,8 +71,6 @@ Output selection (mutually exclusive):
 			DOC: sections. May be specified multiple times.
 
 Output selection modifiers:
-  -sphinx-version VER   Generate rST syntax for the specified Sphinx version.
-                        Only works with reStructuredTextFormat.
   -no-doc-sections	Do not output DOC: sections.
   -enable-lineno        Enable output of #define LINENO lines. Only works with
                         reStructuredText format.
@@ -294,7 +292,6 @@ use constant {
 };
 my $output_selection = OUTPUT_ALL;
 my $show_not_found = 0;	# No longer used
-my $sphinx_version = "0.0"; # if not specified, assume old
 
 my @export_file_list;
 
@@ -460,8 +457,6 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
 	    $enable_lineno = 1;
     } elsif ($cmd eq 'show-not-found') {
 	$show_not_found = 1;  # A no-op but don't fail
-    } elsif ($cmd eq 'sphinx-version') {
-        $sphinx_version = shift @ARGV;
     } else {
 	# Unknown argument
         usage();
@@ -989,16 +984,7 @@ sub output_struct_rst(%) {
     my $oldprefix = $lineprefix;
     my $name = $args{'type'} . " " . $args{'struct'};
 
-    # Sphinx 3.0 and up will emit warnings for "c:type:: struct Foo".
-    # It wants to see "c:struct:: Foo" (and will add the word 'struct' in
-    # the rendered output).
-    if ((split(/\./, $sphinx_version))[0] >= 3) {
-        my $sname = $name;
-        $sname =~ s/^struct //;
-        print "\n\n.. c:struct:: " . $sname . "\n\n";
-    } else {
-        print "\n\n.. c:type:: " . $name . "\n\n";
-    }
+    print "\n\n.. c:type:: " . $name . "\n\n";
     print_lineno($declaration_start_line);
     $lineprefix = "   ";
     output_highlight_rst($args{'purpose'});
-- 
2.26.2




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

* [PATCH v2 17/32] scripts: kernel-doc: make it more compatible with Sphinx 3.x
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (15 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 16/32] Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later" Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 18/32] scripts: kernel-doc: use a less pedantic markup for funcs on " Paolo Bonzini
                   ` (15 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

With Sphinx 3.x, the ".. c:type:" tag was changed to accept either:

	.. c:type:: typedef-like declaration
	.. c:type:: name

Using it for other types (including functions) don't work anymore.

So, there are newer tags for macro, enum, struct, union, and others,
which doesn't exist on older versions.

Add a check for the Sphinx version and change the produced tags
accordingly.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-17-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 71 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 65 insertions(+), 6 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 60f75cd176..771367a6ab 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -271,6 +271,8 @@ if ($#ARGV == -1) {
 }
 
 my $kernelversion;
+my $sphinx_major;
+
 my $dohighlight = "";
 
 my $verbose = 0;
@@ -465,6 +467,43 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
 
 # continue execution near EOF;
 
+# The C domain dialect changed on Sphinx 3. So, we need to check the
+# version in order to produce the right tags.
+sub findprog($)
+{
+	foreach(split(/:/, $ENV{PATH})) {
+		return "$_/$_[0]" if(-x "$_/$_[0]");
+	}
+}
+
+sub get_sphinx_version()
+{
+	my $ver;
+	my $major = 1;
+
+	my $cmd = "sphinx-build";
+	if (!findprog($cmd)) {
+		my $cmd = "sphinx-build3";
+		return $major if (!findprog($cmd));
+	}
+
+	open IN, "$cmd --version 2>&1 |";
+	while (<IN>) {
+		if (m/^\s*sphinx-build\s+([\d]+)\.([\d\.]+)(\+\/[\da-f]+)?$/) {
+			$major=$1;
+			last;
+		}
+		# Sphinx 1.2.x uses a different format
+		if (m/^\s*Sphinx.*\s+([\d]+)\.([\d\.]+)$/) {
+			$major=$1;
+			last;
+		}
+	}
+	close IN;
+
+	return $major;
+}
+
 # get kernel version from env
 sub get_kernel_version() {
     my $version = 'unknown kernel version';
@@ -848,7 +887,11 @@ sub output_function_rst(%) {
     my $start = "";
 
     if ($args{'typedef'}) {
-	print ".. c:type:: ". $args{'function'} . "\n\n";
+	if ($sphinx_major < 3) {
+	    print ".. c:type:: ". $args{'function'} . "\n\n";
+	} else {
+	    print ".. c:function:: ". $args{'function'} . "\n\n";
+	}
 	print_lineno($declaration_start_line);
 	print "   **Typedef**: ";
 	$lineprefix = "";
@@ -938,9 +981,14 @@ sub output_enum_rst(%) {
     my ($parameter);
     my $oldprefix = $lineprefix;
     my $count;
-    my $name = "enum " . $args{'enum'};
 
-    print "\n\n.. c:type:: " . $name . "\n\n";
+    if ($sphinx_major < 3) {
+	my $name = "enum " . $args{'enum'};
+	print "\n\n.. c:type:: " . $name . "\n\n";
+    } else {
+	my $name = $args{'enum'};
+	print "\n\n.. c:enum:: " . $name . "\n\n";
+    }
     print_lineno($declaration_start_line);
     $lineprefix = "   ";
     output_highlight_rst($args{'purpose'});
@@ -966,8 +1014,13 @@ sub output_typedef_rst(%) {
     my %args = %{$_[0]};
     my ($parameter);
     my $oldprefix = $lineprefix;
-    my $name = "typedef " . $args{'typedef'};
+    my $name;
 
+    if ($sphinx_major < 3) {
+	$name = "typedef " . $args{'typedef'};
+    } else {
+	$name = $args{'typedef'};
+    }
     print "\n\n.. c:type:: " . $name . "\n\n";
     print_lineno($declaration_start_line);
     $lineprefix = "   ";
@@ -982,9 +1035,14 @@ sub output_struct_rst(%) {
     my %args = %{$_[0]};
     my ($parameter);
     my $oldprefix = $lineprefix;
-    my $name = $args{'type'} . " " . $args{'struct'};
 
-    print "\n\n.. c:type:: " . $name . "\n\n";
+    if ($sphinx_major < 3) {
+	my $name = $args{'type'} . " " . $args{'struct'};
+	print "\n\n.. c:type:: " . $name . "\n\n";
+    } else {
+	my $name = $args{'struct'};
+	print "\n\n.. c:struct:: " . $name . "\n\n";
+    }
     print_lineno($declaration_start_line);
     $lineprefix = "   ";
     output_highlight_rst($args{'purpose'});
@@ -2242,6 +2300,7 @@ sub process_file($) {
 }
 
 
+$sphinx_major = get_sphinx_version();
 $kernelversion = get_kernel_version();
 
 # generate a sequence of code that will splice in highlighting information
-- 
2.26.2




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

* [PATCH v2 18/32] scripts: kernel-doc: use a less pedantic markup for funcs on Sphinx 3.x
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (16 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 17/32] scripts: kernel-doc: make it more compatible with Sphinx 3.x Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 19/32] scripts: kernel-doc: fix troubles with line counts Paolo Bonzini
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Unfortunately, Sphinx 3.x parser for c functions is too pedantic:

	https://github.com/sphinx-doc/sphinx/issues/8241

While it could be relaxed with some configurations, there are
several corner cases that it would make it hard to maintain,
and will require teaching conf.py about several macros.

So, let's instead use the :c:macro notation. This will
produce an output that it is not as nice as currently, but it
should still be acceptable, and will provide cross-references,
removing thousands of warnings when building with newer
versions of Sphinx.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-18-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 771367a6ab..75ddd3b5e6 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -886,19 +886,29 @@ sub output_function_rst(%) {
     my $oldprefix = $lineprefix;
     my $start = "";
 
-    if ($args{'typedef'}) {
-	if ($sphinx_major < 3) {
+    if ($sphinx_major < 3) {
+	if ($args{'typedef'}) {
 	    print ".. c:type:: ". $args{'function'} . "\n\n";
+	    print_lineno($declaration_start_line);
+	    print "   **Typedef**: ";
+	    $lineprefix = "";
+	    output_highlight_rst($args{'purpose'});
+	    $start = "\n\n**Syntax**\n\n  ``";
 	} else {
-	    print ".. c:function:: ". $args{'function'} . "\n\n";
+	    print ".. c:function:: ";
 	}
-	print_lineno($declaration_start_line);
-	print "   **Typedef**: ";
-	$lineprefix = "";
-	output_highlight_rst($args{'purpose'});
-	$start = "\n\n**Syntax**\n\n  ``";
     } else {
-	print ".. c:function:: ";
+	print ".. c:macro:: ". $args{'function'} . "\n\n";
+
+	if ($args{'typedef'}) {
+	    print_lineno($declaration_start_line);
+	    print "   **Typedef**: ";
+	    $lineprefix = "";
+	    output_highlight_rst($args{'purpose'});
+	    $start = "\n\n**Syntax**\n\n  ``";
+	} else {
+	    print "``";
+	}
     }
     if ($args{'functiontype'} ne "") {
 	$start .= $args{'functiontype'} . " " . $args{'function'} . " (";
@@ -925,7 +935,11 @@ sub output_function_rst(%) {
     if ($args{'typedef'}) {
 	print ");``\n\n";
     } else {
-	print ")\n\n";
+	if ($sphinx_major < 3) {
+	    print ")\n\n";
+	} else {
+	    print ")``\n";
+	}
 	print_lineno($declaration_start_line);
 	$lineprefix = "   ";
 	output_highlight_rst($args{'purpose'});
-- 
2.26.2




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

* [PATCH v2 19/32] scripts: kernel-doc: fix troubles with line counts
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (17 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 18/32] scripts: kernel-doc: use a less pedantic markup for funcs on " Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 20/32] scripts: kernel-doc: reimplement -nofunction argument Paolo Bonzini
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

There's currently a bug with the way kernel-doc script
counts line numbers that can be seen with:

	$ ./scripts/kernel-doc -rst  -enable-lineno include/linux/math64.h >all && ./scripts/kernel-doc -rst -internal -enable-lineno include/linux/math64.h >int && diff -U0 int all

	--- int	2020-09-28 12:58:08.927486808 +0200
	+++ all	2020-09-28 12:58:08.905486845 +0200
	@@ -1 +1 @@
	-#define LINENO 27
	+#define LINENO 26
	@@ -3 +3 @@
	-#define LINENO 16
	+#define LINENO 15
	@@ -9 +9 @@
	-#define LINENO 17
	+#define LINENO 16
	...

This is happening with perl version 5.30.3, but I'm not
so sure if this is a perl bug, or if this is due to something
else.

In any case, fixing it is easy. Basically, when "-internal"
parameter is used, the process_export_file() function opens the
handle "IN". This makes the line number to be incremented, as the
handler for the main open is also "IN".

Fix the problem by using a different handler for the
main open().

While here, add a missing close for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-19-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 75ddd3b5e6..f33a4b1cc7 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2268,7 +2268,7 @@ sub process_file($) {
 
     $file = map_filename($orig_file);
 
-    if (!open(IN,"<$file")) {
+    if (!open(IN_FILE,"<$file")) {
 	print STDERR "Error: Cannot open file $file\n";
 	++$errors;
 	return;
@@ -2277,9 +2277,9 @@ sub process_file($) {
     $. = 1;
 
     $section_counter = 0;
-    while (<IN>) {
+    while (<IN_FILE>) {
 	while (s/\\\s*$//) {
-	    $_ .= <IN>;
+	    $_ .= <IN_FILE>;
 	}
 	# Replace tabs by spaces
         while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
@@ -2311,6 +2311,7 @@ sub process_file($) {
 	    print STDERR "${file}:1: warning: no structured comments found\n";
 	}
     }
+    close IN_FILE;
 }
 
 
-- 
2.26.2




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

* [PATCH v2 20/32] scripts: kernel-doc: reimplement -nofunction argument
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (18 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 19/32] scripts: kernel-doc: fix troubles with line counts Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 21/32] scripts: kernel-doc: fix typedef identification Paolo Bonzini
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Right now, the build system doesn't use -nofunction, as
it is pretty much useless, because it doesn't consider
the other output modes (extern, internal), working only
with all.

Also, it is limited to exclude functions.

Re-implement it in order to allow excluding any symbols from
the document output, no matter what mode is used.

The parameter was also renamed to "-nosymbol", as it express
better its meaning.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-20-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 44 +++++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index f33a4b1cc7..35d60af834 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -66,9 +66,8 @@ Output selection (mutually exclusive):
   -function NAME	Only output documentation for the given function(s)
 			or DOC: section title(s). All other functions and DOC:
 			sections are ignored. May be specified multiple times.
-  -nofunction NAME	Do NOT output documentation for the given function(s);
-			only output documentation for the other functions and
-			DOC: sections. May be specified multiple times.
+  -nosymbol NAME	Exclude the specified symbols from the output
+		        documentation. May be specified multiple times.
 
 Output selection modifiers:
   -no-doc-sections	Do not output DOC: sections.
@@ -288,9 +287,8 @@ my $modulename = "Kernel API";
 use constant {
     OUTPUT_ALL          => 0, # output all symbols and doc sections
     OUTPUT_INCLUDE      => 1, # output only specified symbols
-    OUTPUT_EXCLUDE      => 2, # output everything except specified symbols
-    OUTPUT_EXPORTED     => 3, # output exported symbols
-    OUTPUT_INTERNAL     => 4, # output non-exported symbols
+    OUTPUT_EXPORTED     => 2, # output exported symbols
+    OUTPUT_INTERNAL     => 3, # output non-exported symbols
 };
 my $output_selection = OUTPUT_ALL;
 my $show_not_found = 0;	# No longer used
@@ -315,6 +313,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
 # CAVEAT EMPTOR!  Some of the others I localised may not want to be, which
 # could cause "use of undefined value" or other bugs.
 my ($function, %function_table, %parametertypes, $declaration_purpose);
+my %nosymbol_table = ();
 my $declaration_start_line;
 my ($type, $declaration_name, $return_type);
 my ($newsection, $newcontents, $prototype, $brcount, %source_map);
@@ -434,10 +433,9 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
 	$output_selection = OUTPUT_INCLUDE;
 	$function = shift @ARGV;
 	$function_table{$function} = 1;
-    } elsif ($cmd eq "nofunction") { # output all except specific functions
-	$output_selection = OUTPUT_EXCLUDE;
-	$function = shift @ARGV;
-	$function_table{$function} = 1;
+    } elsif ($cmd eq "nosymbol") { # Exclude specific symbols
+	my $symbol = shift @ARGV;
+	$nosymbol_table{$symbol} = 1;
     } elsif ($cmd eq "export") { # only exported symbols
 	$output_selection = OUTPUT_EXPORTED;
 	%function_table = ();
@@ -570,11 +568,11 @@ sub dump_doc_section {
         return;
     }
 
+    return if (defined($nosymbol_table{$name}));
+
     if (($output_selection == OUTPUT_ALL) ||
-	($output_selection == OUTPUT_INCLUDE &&
-	 defined($function_table{$name})) ||
-	($output_selection == OUTPUT_EXCLUDE &&
-	 !defined($function_table{$name})))
+	(($output_selection == OUTPUT_INCLUDE) &&
+	 defined($function_table{$name})))
     {
 	dump_section($file, $name, $contents);
 	output_blockhead({'sectionlist' => \@sectionlist,
@@ -800,6 +798,8 @@ sub output_blockhead_rst(%) {
     my ($parameter, $section);
 
     foreach $section (@{$args{'sectionlist'}}) {
+	next if (defined($nosymbol_table{$section}));
+
 	if ($output_selection != OUTPUT_INCLUDE) {
 	    print "**$section**\n\n";
 	}
@@ -1115,12 +1115,14 @@ sub output_declaration {
     my $name = shift;
     my $functype = shift;
     my $func = "output_${functype}_$output_mode";
+
+    return if (defined($nosymbol_table{$name}));
+
     if (($output_selection == OUTPUT_ALL) ||
 	(($output_selection == OUTPUT_INCLUDE ||
 	  $output_selection == OUTPUT_EXPORTED) &&
 	 defined($function_table{$name})) ||
-	(($output_selection == OUTPUT_EXCLUDE ||
-	  $output_selection == OUTPUT_INTERNAL) &&
+	($output_selection == OUTPUT_INTERNAL &&
 	 !($functype eq "function" && defined($function_table{$name}))))
     {
 	&$func(@_);
@@ -1301,6 +1303,8 @@ sub show_warnings($$) {
 	my $functype = shift;
 	my $name = shift;
 
+	return 0 if (defined($nosymbol_table{$name}));
+
 	return 1 if ($output_selection == OUTPUT_ALL);
 
 	if ($output_selection == OUTPUT_EXPORTED) {
@@ -1324,13 +1328,6 @@ sub show_warnings($$) {
 			return 0;
 		}
 	}
-	if ($output_selection == OUTPUT_EXCLUDE) {
-		if (!defined($function_table{$name})) {
-			return 1;
-		} else {
-			return 0;
-		}
-	}
 	die("Please add the new output type at show_warnings()");
 }
 
@@ -1952,6 +1949,7 @@ sub process_export_file($) {
 
     while (<IN>) {
 	if (/$export_symbol/) {
+	    next if (defined($nosymbol_table{$2}));
 	    $function_table{$2} = 1;
 	}
     }
-- 
2.26.2




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

* [PATCH v2 21/32] scripts: kernel-doc: fix typedef identification
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (19 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 20/32] scripts: kernel-doc: reimplement -nofunction argument Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 22/32] scripts: kernel-doc: don't mangle with parameter list Paolo Bonzini
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Some typedef expressions are output as normal functions.

As we need to be clearer about the type with Sphinx 3.x,
detect such cases.

While here, fix a wrongly-indented block.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-21-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 64 +++++++++++++++++++++++++++++-----------------
 1 file changed, 41 insertions(+), 23 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 35d60af834..0c31e9ad66 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1748,30 +1748,48 @@ sub dump_function($$) {
 	return;
     }
 
-	my $prms = join " ", @parameterlist;
-	check_sections($file, $declaration_name, "function", $sectcheck, $prms);
-
-        # This check emits a lot of warnings at the moment, because many
-        # functions don't have a 'Return' doc section. So until the number
-        # of warnings goes sufficiently down, the check is only performed in
-        # verbose mode.
-        # TODO: always perform the check.
-        if ($verbose && !$noret) {
-                check_return_section($file, $declaration_name, $return_type);
-        }
+    my $prms = join " ", @parameterlist;
+    check_sections($file, $declaration_name, "function", $sectcheck, $prms);
+
+    # This check emits a lot of warnings at the moment, because many
+    # functions don't have a 'Return' doc section. So until the number
+    # of warnings goes sufficiently down, the check is only performed in
+    # verbose mode.
+    # TODO: always perform the check.
+    if ($verbose && !$noret) {
+	    check_return_section($file, $declaration_name, $return_type);
+    }
 
-    output_declaration($declaration_name,
-		       'function',
-		       {'function' => $declaration_name,
-			'module' => $modulename,
-			'functiontype' => $return_type,
-			'parameterlist' => \@parameterlist,
-			'parameterdescs' => \%parameterdescs,
-			'parametertypes' => \%parametertypes,
-			'sectionlist' => \@sectionlist,
-			'sections' => \%sections,
-			'purpose' => $declaration_purpose
-		       });
+    # The function parser can be called with a typedef parameter.
+    # Handle it.
+    if ($return_type =~ /typedef/) {
+	output_declaration($declaration_name,
+			   'function',
+			   {'function' => $declaration_name,
+			    'typedef' => 1,
+			    'module' => $modulename,
+			    'functiontype' => $return_type,
+			    'parameterlist' => \@parameterlist,
+			    'parameterdescs' => \%parameterdescs,
+			    'parametertypes' => \%parametertypes,
+			    'sectionlist' => \@sectionlist,
+			    'sections' => \%sections,
+			    'purpose' => $declaration_purpose
+			   });
+    } else {
+	output_declaration($declaration_name,
+			   'function',
+			   {'function' => $declaration_name,
+			    'module' => $modulename,
+			    'functiontype' => $return_type,
+			    'parameterlist' => \@parameterlist,
+			    'parameterdescs' => \%parameterdescs,
+			    'parametertypes' => \%parametertypes,
+			    'sectionlist' => \@sectionlist,
+			    'sections' => \%sections,
+			    'purpose' => $declaration_purpose
+			   });
+    }
 }
 
 sub reset_state {
-- 
2.26.2




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

* [PATCH v2 22/32] scripts: kernel-doc: don't mangle with parameter list
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (20 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 21/32] scripts: kernel-doc: fix typedef identification Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 23/32] scripts: kernel-doc: allow passing desired Sphinx C domain dialect Paolo Bonzini
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

While kernel-doc needs to parse parameters in order to
identify its name, it shouldn't be touching the type,
as parsing it is very difficult, and errors happen.

One current error is when parsing this parameter:

	const u32 (*tab)[256]

Found at ./lib/crc32.c, on this function:

	u32 __pure crc32_be_generic (u32 crc, unsigned char const *p, size_t len, const u32 (*tab)[256], u32 polynomial);

The current logic mangles it, producing this output:

	const u32 ( *tab

That's something that it is not recognizeable.

So, instead, let's push the argument as-is, and use it
when printing the function prototype and when describing
each argument.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-22-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 0c31e9ad66..478037f736 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -655,10 +655,10 @@ sub output_function_man(%) {
 	$type = $args{'parametertypes'}{$parameter};
 	if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
 	    # pointer-to-function
-	    print ".BI \"" . $parenth . $1 . "\" " . $parameter . " \") (" . $2 . ")" . $post . "\"\n";
+	    print ".BI \"" . $parenth . $1 . "\" " . " \") (" . $2 . ")" . $post . "\"\n";
 	} else {
 	    $type =~ s/([^\*])$/$1 /;
-	    print ".BI \"" . $parenth . $type . "\" " . $parameter . " \"" . $post . "\"\n";
+	    print ".BI \"" . $parenth . $type . "\" " . " \"" . $post . "\"\n";
 	}
 	$count++;
 	$parenth = "";
@@ -929,7 +929,7 @@ sub output_function_rst(%) {
 	    # pointer-to-function
 	    print $1 . $parameter . ") (" . $2 . ")";
 	} else {
-	    print $type . " " . $parameter;
+	    print $type;
 	}
     }
     if ($args{'typedef'}) {
@@ -954,7 +954,7 @@ sub output_function_rst(%) {
 	$type = $args{'parametertypes'}{$parameter};
 
 	if ($type ne "") {
-	    print "``$type $parameter``\n";
+	    print "``$type``\n";
 	} else {
 	    print "``$parameter``\n";
 	}
@@ -1479,7 +1479,7 @@ sub create_parameterlist($$$$) {
 	    # Treat preprocessor directive as a typeless variable just to fill
 	    # corresponding data structures "correctly". Catch it later in
 	    # output_* subs.
-	    push_parameter($arg, "", $file);
+	    push_parameter($arg, "", "", $file);
 	} elsif ($arg =~ m/\(.+\)\s*\(/) {
 	    # pointer-to-function
 	    $arg =~ tr/#/,/;
@@ -1488,7 +1488,7 @@ sub create_parameterlist($$$$) {
 	    $type = $arg;
 	    $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
 	    save_struct_actual($param);
-	    push_parameter($param, $type, $file, $declaration_name);
+	    push_parameter($param, $type, $arg, $file, $declaration_name);
 	} elsif ($arg) {
 	    $arg =~ s/\s*:\s*/:/g;
 	    $arg =~ s/\s*\[/\[/g;
@@ -1513,26 +1513,28 @@ sub create_parameterlist($$$$) {
 	    foreach $param (@args) {
 		if ($param =~ m/^(\*+)\s*(.*)/) {
 		    save_struct_actual($2);
-		    push_parameter($2, "$type $1", $file, $declaration_name);
+
+		    push_parameter($2, "$type $1", $arg, $file, $declaration_name);
 		}
 		elsif ($param =~ m/(.*?):(\d+)/) {
 		    if ($type ne "") { # skip unnamed bit-fields
 			save_struct_actual($1);
-			push_parameter($1, "$type:$2", $file, $declaration_name)
+			push_parameter($1, "$type:$2", $arg, $file, $declaration_name)
 		    }
 		}
 		else {
 		    save_struct_actual($param);
-		    push_parameter($param, $type, $file, $declaration_name);
+		    push_parameter($param, $type, $arg, $file, $declaration_name);
 		}
 	    }
 	}
     }
 }
 
-sub push_parameter($$$$) {
+sub push_parameter($$$$$) {
 	my $param = shift;
 	my $type = shift;
+	my $org_arg = shift;
 	my $file = shift;
 	my $declaration_name = shift;
 
@@ -1596,8 +1598,8 @@ sub push_parameter($$$$) {
 	# "[blah" in a parameter string;
 	###$param =~ s/\s*//g;
 	push @parameterlist, $param;
-	$type =~ s/\s\s+/ /g;
-	$parametertypes{$param} = $type;
+	$org_arg =~ s/\s\s+/ /g;
+	$parametertypes{$param} = $org_arg;
 }
 
 sub check_sections($$$$$) {
-- 
2.26.2




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

* [PATCH v2 23/32] scripts: kernel-doc: allow passing desired Sphinx C domain dialect
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (21 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 22/32] scripts: kernel-doc: don't mangle with parameter list Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 24/32] scripts: kernel-doc: fix line number handling Paolo Bonzini
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

When kernel-doc is called via kerneldoc.py, there's no need to
auto-detect the Sphinx version, as the Sphinx module already
knows it. So, add an optional parameter to allow changing the
Sphinx dialect.

As kernel-doc can also be manually called, keep the auto-detection
logic if the parameter was not specified. On such case, emit
a warning if sphinx-build can't be found at PATH.

I ended using a suggestion from Joe for using a more readable
regex, instead of using a complex one with a hidden group like:

	m/^(\d+)\.(\d+)(?:\.?(\d+)?)/

in order to get the optional <patch> argument.

Thanks-to: Joe Perches <joe@perches.com>
Suggested-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-23-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 docs/sphinx/kerneldoc.py |  5 ++++
 scripts/kernel-doc       | 51 +++++++++++++++++++++++++++++++++-------
 2 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index c0180e02a2..079aadced3 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -69,6 +69,11 @@ class KernelDocDirective(Directive):
         env = self.state.document.settings.env
         cmd = env.config.kerneldoc_bin + ['-rst', '-enable-lineno']
 
+        # Pass the version string to kernel-doc, as it needs to use a different
+        # dialect, depending what the C domain supports for each specific
+        # Sphinx versions
+        cmd += ['-sphinx-version', sphinx.__version__]
+
         filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
         export_file_patterns = []
 
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 478037f736..667ad3169c 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -56,6 +56,13 @@ Output format selection (mutually exclusive):
   -rst			Output reStructuredText format.
   -none			Do not output documentation, only warnings.
 
+Output format selection modifier (affects only ReST output):
+
+  -sphinx-version	Use the ReST C domain dialect compatible with an
+			specific Sphinx Version.
+			If not specified, kernel-doc will auto-detect using
+			the sphinx-build version found on PATH.
+
 Output selection (mutually exclusive):
   -export		Only output documentation for symbols that have been
 			exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL()
@@ -270,7 +277,7 @@ if ($#ARGV == -1) {
 }
 
 my $kernelversion;
-my $sphinx_major;
+my ($sphinx_major, $sphinx_minor, $sphinx_patch);
 
 my $dohighlight = "";
 
@@ -457,6 +464,23 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
 	    $enable_lineno = 1;
     } elsif ($cmd eq 'show-not-found') {
 	$show_not_found = 1;  # A no-op but don't fail
+    } elsif ($cmd eq "sphinx-version") {
+	my $ver_string = shift @ARGV;
+	if ($ver_string =~ m/^(\d+)(\.\d+)?(\.\d+)?/) {
+	    $sphinx_major = $1;
+	    if (defined($2)) {
+		$sphinx_minor = substr($2,1);
+	    } else {
+		$sphinx_minor = 0;
+	    }
+	    if (defined($3)) {
+		$sphinx_patch = substr($3,1)
+	    } else {
+		$sphinx_patch = 0;
+	    }
+	} else {
+	    die "Sphinx version should either major.minor or major.minor.patch format\n";
+	}
     } else {
 	# Unknown argument
         usage();
@@ -477,29 +501,37 @@ sub findprog($)
 sub get_sphinx_version()
 {
 	my $ver;
-	my $major = 1;
 
 	my $cmd = "sphinx-build";
 	if (!findprog($cmd)) {
 		my $cmd = "sphinx-build3";
-		return $major if (!findprog($cmd));
+		if (!findprog($cmd)) {
+			$sphinx_major = 1;
+			$sphinx_minor = 2;
+			$sphinx_patch = 0;
+			printf STDERR "Warning: Sphinx version not found. Using default (Sphinx version %d.%d.%d)\n",
+			       $sphinx_major, $sphinx_minor, $sphinx_patch;
+			return;
+		}
 	}
 
 	open IN, "$cmd --version 2>&1 |";
 	while (<IN>) {
 		if (m/^\s*sphinx-build\s+([\d]+)\.([\d\.]+)(\+\/[\da-f]+)?$/) {
-			$major=$1;
+			$sphinx_major = $1;
+			$sphinx_minor = $2;
+			$sphinx_patch = $3;
 			last;
 		}
 		# Sphinx 1.2.x uses a different format
 		if (m/^\s*Sphinx.*\s+([\d]+)\.([\d\.]+)$/) {
-			$major=$1;
+			$sphinx_major = $1;
+			$sphinx_minor = $2;
+			$sphinx_patch = $3;
 			last;
 		}
 	}
 	close IN;
-
-	return $major;
 }
 
 # get kernel version from env
@@ -2333,7 +2365,10 @@ sub process_file($) {
 }
 
 
-$sphinx_major = get_sphinx_version();
+if ($output_mode eq "rst") {
+	get_sphinx_version() if (!$sphinx_major);
+}
+
 $kernelversion = get_kernel_version();
 
 # generate a sequence of code that will splice in highlighting information
-- 
2.26.2




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

* [PATCH v2 24/32] scripts: kernel-doc: fix line number handling
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (22 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 23/32] scripts: kernel-doc: allow passing desired Sphinx C domain dialect Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 25/32] scripts: kernel-doc: try to use c:function if possible Paolo Bonzini
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Address several issues related to pointing to the wrong line
number:

1) ensure that line numbers will always be initialized

   When section is the default (Description), the line number
   is not initializing, producing this:

	$ ./scripts/kernel-doc --enable-lineno ./drivers/media/v4l2-core/v4l2-mem2mem.c|less

	**Description**

	#define LINENO 0
	In case of streamoff or release called on any context,
	1] If the context is currently running, then abort job will be called
	2] If the context is queued, then the context will be removed from
	   the job_queue

  Which is not right. Ensure that the line number will always
  be there. After applied, the result now points to the right location:

	**Description**

	#define LINENO 410
	In case of streamoff or release called on any context,
	1] If the context is currently running, then abort job will be called
	2] If the context is queued, then the context will be removed from
	   the job_queue

2) The line numbers for function prototypes are always + 1,
   because it is taken at the line after handling the prototype.
   Change the logic to point to the next line after the /** */
   block;

3) The "DOC:" line number should point to the same line as this
   markup is found, and not to the next one.

Probably part of the issues were due to a but that was causing
the line number offset to be incremented by one, if --export
were used.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-24-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 667ad3169c..98752164eb 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1705,7 +1705,7 @@ sub dump_function($$) {
     my $file = shift;
     my $noret = 0;
 
-    print_lineno($.);
+    print_lineno($new_start_line);
 
     $prototype =~ s/^static +//;
     $prototype =~ s/^extern +//;
@@ -2033,7 +2033,7 @@ sub process_name($$) {
     if (/$doc_block/o) {
 	$state = STATE_DOCBLOCK;
 	$contents = "";
-	$new_start_line = $. + 1;
+	$new_start_line = $.;
 
 	if ( $1 eq "" ) {
 	    $section = $section_intro;
@@ -2116,6 +2116,7 @@ sub process_body($$) {
     if ($state == STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) {
 	dump_section($file, $section, $contents);
 	$section = $section_default;
+	$new_start_line = $.;
 	$contents = "";
     }
 
@@ -2171,6 +2172,7 @@ sub process_body($$) {
 	$prototype = "";
 	$state = STATE_PROTO;
 	$brcount = 0;
+        $new_start_line = $. + 1;
     } elsif (/$doc_content/) {
 	if ($1 eq "") {
 	    if ($section eq $section_context) {
-- 
2.26.2




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

* [PATCH v2 25/32] scripts: kernel-doc: try to use c:function if possible
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (23 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 24/32] scripts: kernel-doc: fix line number handling Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 26/32] Revert "kernel-doc: Handle function typedefs without asterisks" Paolo Bonzini
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

There are a few namespace clashes by using c:macro everywhere:

basically, when using it, we can't have something like:

	.. c:struct:: pwm_capture

	.. c:macro:: pwm_capture

So, we need to use, instead:

	.. c:function:: int pwm_capture (struct pwm_device * pwm, struct pwm_capture * result, unsigned long timeout)

for the function declaration.

The kernel-doc change was proposed by Jakob Lykke Andersen here:

	https://github.com/jakobandersen/linux_docs/commit/6fd2076ec001cca7466857493cd678df4dfe4a65

Although I did a different implementation.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-25-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 98752164eb..2d56c46933 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -917,6 +917,7 @@ sub output_function_rst(%) {
     my ($parameter, $section);
     my $oldprefix = $lineprefix;
     my $start = "";
+    my $is_macro = 0;
 
     if ($sphinx_major < 3) {
 	if ($args{'typedef'}) {
@@ -926,11 +927,17 @@ sub output_function_rst(%) {
 	    $lineprefix = "";
 	    output_highlight_rst($args{'purpose'});
 	    $start = "\n\n**Syntax**\n\n  ``";
+	    $is_macro = 1;
 	} else {
 	    print ".. c:function:: ";
 	}
     } else {
-	print ".. c:macro:: ". $args{'function'} . "\n\n";
+	if ($args{'typedef'} || $args{'functiontype'} eq "") {
+	    $is_macro = 1;
+	    print ".. c:macro:: ". $args{'function'} . "\n\n";
+	} else {
+	    print ".. c:function:: ";
+	}
 
 	if ($args{'typedef'}) {
 	    print_lineno($declaration_start_line);
@@ -939,7 +946,7 @@ sub output_function_rst(%) {
 	    output_highlight_rst($args{'purpose'});
 	    $start = "\n\n**Syntax**\n\n  ``";
 	} else {
-	    print "``";
+	    print "``" if ($is_macro);
 	}
     }
     if ($args{'functiontype'} ne "") {
@@ -964,14 +971,12 @@ sub output_function_rst(%) {
 	    print $type;
 	}
     }
-    if ($args{'typedef'}) {
-	print ");``\n\n";
+    if ($is_macro) {
+	print ")``\n\n";
     } else {
-	if ($sphinx_major < 3) {
-	    print ")\n\n";
-	} else {
-	    print ")``\n";
-	}
+	print ")\n\n";
+    }
+    if (!$args{'typedef'}) {
 	print_lineno($declaration_start_line);
 	$lineprefix = "   ";
 	output_highlight_rst($args{'purpose'});
-- 
2.26.2




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

* [PATCH v2 26/32] Revert "kernel-doc: Handle function typedefs without asterisks"
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (24 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 25/32] scripts: kernel-doc: try to use c:function if possible Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 27/32] Revert "kernel-doc: Handle function typedefs that return pointers" Paolo Bonzini
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

This reverts commit 3cd3c5193cde5242e243c25759f85802e267994f.
We will replace the commit with the fix from Linux.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-26-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 2d56c46933..780aee4e92 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1434,7 +1434,7 @@ sub dump_typedef($$) {
     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
 
     # Parse function prototypes
-    if ($x =~ /typedef\s+(\w+\s*\**)\s*\(\*?\s*(\w\S+)\s*\)\s*\((.*)\);/ ||
+    if ($x =~ /typedef\s+(\w+\s*\**)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ ||
 	$x =~ /typedef\s+(\w+\s*\**)\s*(\w\S+)\s*\s*\((.*)\);/) {
 
 	# Function typedefs
-- 
2.26.2




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

* [PATCH v2 27/32] Revert "kernel-doc: Handle function typedefs that return pointers"
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (25 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 26/32] Revert "kernel-doc: Handle function typedefs without asterisks" Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 28/32] scripts: kernel-doc: fix typedef parsing Paolo Bonzini
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

This reverts commit 19ab6044be0c55d529e875e3ee16fdd5c3b54d33.
We will replace the commit with the fix from Linux.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-27-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 780aee4e92..d3a289628c 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1434,8 +1434,8 @@ sub dump_typedef($$) {
     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
 
     # Parse function prototypes
-    if ($x =~ /typedef\s+(\w+\s*\**)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ ||
-	$x =~ /typedef\s+(\w+\s*\**)\s*(\w\S+)\s*\s*\((.*)\);/) {
+    if ($x =~ /typedef\s+(\w+)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ ||
+	$x =~ /typedef\s+(\w+)\s*(\w\S+)\s*\s*\((.*)\);/) {
 
 	# Function typedefs
 	$return_type = $1;
-- 
2.26.2




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

* [PATCH v2 28/32] scripts: kernel-doc: fix typedef parsing
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (26 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 27/32] Revert "kernel-doc: Handle function typedefs that return pointers" Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:34 ` [PATCH v2 29/32] scripts: kernel-doc: split typedef complex regex Paolo Bonzini
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

The include/linux/genalloc.h file defined this typedef:

	typedef unsigned long (*genpool_algo_t)(unsigned long *map,unsigned long size,unsigned long start,unsigned int nr,void *data, struct gen_pool *pool, unsigned long start_addr);

Because it has a type composite of two words (unsigned long),
the parser gets the typedef name wrong:

.. c:macro:: long

   **Typedef**: Allocation callback function type definition

Fix the regex in order to accept composite types when
defining a typedef for a function pointer.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/328e8018041cc44f7a1684e57f8d111230761c4f.1603792384.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-28-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index d3a289628c..862b77686e 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1434,13 +1434,14 @@ sub dump_typedef($$) {
     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
 
     # Parse function prototypes
-    if ($x =~ /typedef\s+(\w+)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ ||
-	$x =~ /typedef\s+(\w+)\s*(\w\S+)\s*\s*\((.*)\);/) {
+    if ($x =~ /typedef((?:\s+[\w\*]+){1,8})\s*\(\*?\s*(\w\S+)\s*\)\s*\((.*)\);/ ||
+	$x =~ /typedef((?:\s+[\w\*]+\s+){1,8})\s*\*?(\w\S+)\s*\s*\((.*)\);/) {
 
 	# Function typedefs
 	$return_type = $1;
 	$declaration_name = $2;
 	my $args = $3;
+	$return_type =~ s/^\s+//;
 
 	create_parameterlist($args, ',', $file, $declaration_name);
 
-- 
2.26.2




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

* [PATCH v2 29/32] scripts: kernel-doc: split typedef complex regex
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (27 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 28/32] scripts: kernel-doc: fix typedef parsing Paolo Bonzini
@ 2020-12-01 10:34 ` Paolo Bonzini
  2020-12-01 10:35 ` [PATCH v2 30/32] scripts: kernel-doc: use :c:union when needed Paolo Bonzini
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

The typedef regex for function prototypes are very complex.
Split them into 3 separate regex and then join them using
qr.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/3a4af999a0d62d4ab9dfae1cdefdfcad93383356.1603792384.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-29-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 862b77686e..524fc626ed 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1427,17 +1427,21 @@ sub dump_enum($$) {
     }
 }
 
+my $typedef_type = qr { ((?:\s+[\w\*]+){1,8})\s* }x;
+my $typedef_ident = qr { \*?\s*(\w\S+)\s* }x;
+my $typedef_args = qr { \s*\((.*)\); }x;
+
+my $typedef1 = qr { typedef$typedef_type\($typedef_ident\)$typedef_args }x;
+my $typedef2 = qr { typedef$typedef_type$typedef_ident$typedef_args }x;
+
 sub dump_typedef($$) {
     my $x = shift;
     my $file = shift;
 
     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
 
-    # Parse function prototypes
-    if ($x =~ /typedef((?:\s+[\w\*]+){1,8})\s*\(\*?\s*(\w\S+)\s*\)\s*\((.*)\);/ ||
-	$x =~ /typedef((?:\s+[\w\*]+\s+){1,8})\s*\*?(\w\S+)\s*\s*\((.*)\);/) {
-
-	# Function typedefs
+    # Parse function typedef prototypes
+    if ($x =~ $typedef1 || $x =~ $typedef2) {
 	$return_type = $1;
 	$declaration_name = $2;
 	my $args = $3;
-- 
2.26.2




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

* [PATCH v2 30/32] scripts: kernel-doc: use :c:union when needed
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (28 preceding siblings ...)
  2020-12-01 10:34 ` [PATCH v2 29/32] scripts: kernel-doc: split typedef complex regex Paolo Bonzini
@ 2020-12-01 10:35 ` Paolo Bonzini
  2020-12-01 10:35 ` [PATCH v2 31/32] Revert "docs: temporarily disable the kernel-doc extension" Paolo Bonzini
                   ` (2 subsequent siblings)
  32 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Sphinx C domain code after 3.2.1 will start complaning if :c:struct
would be used for an union type:

	.../Documentation/gpu/drm-kms-helpers:352: ../drivers/video/hdmi.c:851: WARNING: C 'identifier' cross-reference uses wrong tag: reference name is 'union hdmi_infoframe' but found name is 'struct hdmi_infoframe'. Full reference name is 'union hdmi_infoframe'. Full found name is 'struct hdmi_infoframe'.

So, let's address this issue too in advance, in order to
avoid future issues.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/6e4ec3eec914df62389a299797a3880ae4490f35.1603791716.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-30-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 524fc626ed..b95bae3654 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1092,7 +1092,11 @@ sub output_struct_rst(%) {
 	print "\n\n.. c:type:: " . $name . "\n\n";
     } else {
 	my $name = $args{'struct'};
-	print "\n\n.. c:struct:: " . $name . "\n\n";
+	if ($args{'type'} eq 'union') {
+	    print "\n\n.. c:union:: " . $name . "\n\n";
+	} else {
+	    print "\n\n.. c:struct:: " . $name . "\n\n";
+	}
     }
     print_lineno($declaration_start_line);
     $lineprefix = "   ";
-- 
2.26.2




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

* [PATCH v2 31/32] Revert "docs: temporarily disable the kernel-doc extension"
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (29 preceding siblings ...)
  2020-12-01 10:35 ` [PATCH v2 30/32] scripts: kernel-doc: use :c:union when needed Paolo Bonzini
@ 2020-12-01 10:35 ` Paolo Bonzini
  2020-12-01 11:02   ` Peter Maydell
  2020-12-01 10:35 ` [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux Paolo Bonzini
  2020-12-01 11:07 ` [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Peter Maydell
  32 siblings, 1 reply; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

This reverts commit fd68a72875cf318f4310726f842139119c5f45d5.  We're
done with the update of kernel-doc and we can restore kernel-doc's
functionality.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 docs/sphinx/kerneldoc.py | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index 079aadced3..bf44215016 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -80,9 +80,6 @@ class KernelDocDirective(Directive):
         # Tell sphinx of the dependency
         env.note_dependency(os.path.abspath(filename))
 
-        # Disabled temporarily while scripts/kernel-doc is updated
-        return []
-
         tab_width = self.options.get('tab-width', self.state.document.settings.tab_width)
 
         # FIXME: make this nicer and more robust against errors
-- 
2.26.2




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

* [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (30 preceding siblings ...)
  2020-12-01 10:35 ` [PATCH v2 31/32] Revert "docs: temporarily disable the kernel-doc extension" Paolo Bonzini
@ 2020-12-01 10:35 ` Paolo Bonzini
  2020-12-01 10:46   ` Peter Maydell
  2020-12-02  9:03   ` Philippe Mathieu-Daudé
  2020-12-01 11:07 ` [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Peter Maydell
  32 siblings, 2 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-01 10:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

A comment in kernel-doc mentions QEMU's qatomic_set macro, but since
this code originated in Linux we should just revert it and stay as close
to the kernel's copy of the script as possible.

The change was introduced (more or less unintentionally) in QEMU commit
commit d73415a31547, which did a global search-and-replace of QEMU's
atomic access macros.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index b95bae3654..4b19851b2d 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1758,7 +1758,7 @@ sub dump_function($$) {
     # If you mess with these regexps, it's a good idea to check that
     # the following functions' documentation still comes out right:
     # - parport_register_device (function pointer parameters)
-    # - qatomic_set (macro)
+    # - atomic_set (macro)
     # - pci_match_device, __copy_to_user (long return type)
 
     if ($define && $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s+/) {
-- 
2.26.2



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

* Re: [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux
  2020-12-01 10:35 ` [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux Paolo Bonzini
@ 2020-12-01 10:46   ` Peter Maydell
  2020-12-02  9:03   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 39+ messages in thread
From: Peter Maydell @ 2020-12-01 10:46 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On Tue, 1 Dec 2020 at 10:35, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> A comment in kernel-doc mentions QEMU's qatomic_set macro, but since
> this code originated in Linux we should just revert it and stay as close
> to the kernel's copy of the script as possible.
>
> The change was introduced (more or less unintentionally) in QEMU commit
> commit d73415a31547, which did a global search-and-replace of QEMU's
> atomic access macros.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/kernel-doc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 01/32] docs: temporarily disable the kernel-doc extension
  2020-12-01 10:34 ` [PATCH v2 01/32] docs: temporarily disable the kernel-doc extension Paolo Bonzini
@ 2020-12-01 11:01   ` Peter Maydell
  0 siblings, 0 replies; 39+ messages in thread
From: Peter Maydell @ 2020-12-01 11:01 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On Tue, 1 Dec 2020 at 10:35, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Preserve bisectability while we update scripts/kernel-doc from Linux.
> Without this patch, building with Sphinx 3 would break while we
> revert our own Sphinx 3 support and replace it with Linux's.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  docs/sphinx/kerneldoc.py | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
> index 3ac277d162..9124fcbff1 100644
> --- a/docs/sphinx/kerneldoc.py
> +++ b/docs/sphinx/kerneldoc.py
> @@ -75,6 +75,9 @@ class KernelDocDirective(Directive):
>          # Tell sphinx of the dependency
>          env.note_dependency(os.path.abspath(filename))
>
> +        # Disabled temporarily while scripts/kernel-doc is updated
> +        return []
> +
>          tab_width = self.options.get('tab-width', self.state.document.settings.tab_width)
>
>          # FIXME: make this nicer and more robust against errors

Oh, this is nicer than having to comment out every use of the extension :-)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 31/32] Revert "docs: temporarily disable the kernel-doc extension"
  2020-12-01 10:35 ` [PATCH v2 31/32] Revert "docs: temporarily disable the kernel-doc extension" Paolo Bonzini
@ 2020-12-01 11:02   ` Peter Maydell
  0 siblings, 0 replies; 39+ messages in thread
From: Peter Maydell @ 2020-12-01 11:02 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On Tue, 1 Dec 2020 at 10:35, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> This reverts commit fd68a72875cf318f4310726f842139119c5f45d5.  We're
> done with the update of kernel-doc and we can restore kernel-doc's
> functionality.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  docs/sphinx/kerneldoc.py | 3 ---
>  1 file changed, 3 deletions(-)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 00/32] kernel-doc: update from Linux 5.10
  2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
                   ` (31 preceding siblings ...)
  2020-12-01 10:35 ` [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux Paolo Bonzini
@ 2020-12-01 11:07 ` Peter Maydell
  32 siblings, 0 replies; 39+ messages in thread
From: Peter Maydell @ 2020-12-01 11:07 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On Tue, 1 Dec 2020 at 10:35, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> v1->v2: fix bisectability (by disabling kernel-doc altogether)
>         pass Sphinx version from docs/sphinx/kerneldoc.py
>         remove unnecessary s/atomic_/qatomic_/ difference

Tested-by: Peter Maydell <peter.maydell@linaro.org>
(build-tested on sphinx 1.6, 2.0, 2.4, 3.0, 3.2).
It doesn't seem sensible to "review" the upstream kernel
changes, but I think this is good to apply.

(We can update docs/sphinx/kerneldoc.py later I guess.)

thanks
-- PMM


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

* Re: [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux
  2020-12-01 10:35 ` [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux Paolo Bonzini
  2020-12-01 10:46   ` Peter Maydell
@ 2020-12-02  9:03   ` Philippe Mathieu-Daudé
  2020-12-02  9:08     ` Paolo Bonzini
  1 sibling, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-12-02  9:03 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: peter.maydell

On 12/1/20 11:35 AM, Paolo Bonzini wrote:
> A comment in kernel-doc mentions QEMU's qatomic_set macro, but since
> this code originated in Linux we should just revert it and stay as close
> to the kernel's copy of the script as possible.
> 
> The change was introduced (more or less unintentionally) in QEMU commit
> commit d73415a31547, which did a global search-and-replace of QEMU's
> atomic access macros.
> 
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/kernel-doc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Typo "unneces[s]sary" in subject.



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

* Re: [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux
  2020-12-02  9:03   ` Philippe Mathieu-Daudé
@ 2020-12-02  9:08     ` Paolo Bonzini
  0 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2020-12-02  9:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: peter.maydell

On 02/12/20 10:03, Philippe Mathieu-Daudé wrote:
> On 12/1/20 11:35 AM, Paolo Bonzini wrote:
>> A comment in kernel-doc mentions QEMU's qatomic_set macro, but since
>> this code originated in Linux we should just revert it and stay as close
>> to the kernel's copy of the script as possible.
>>
>> The change was introduced (more or less unintentionally) in QEMU commit
>> commit d73415a31547, which did a global search-and-replace of QEMU's
>> atomic access macros.
>>
>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   scripts/kernel-doc | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Typo "unneces[s]sary" in subject.

Oops...  I have already sent a pull request, but I'll fix it if a respin 
is needed.

Paolo



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

end of thread, other threads:[~2020-12-02 10:28 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01 10:34 [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 01/32] docs: temporarily disable the kernel-doc extension Paolo Bonzini
2020-12-01 11:01   ` Peter Maydell
2020-12-01 10:34 ` [PATCH v2 02/32] kernel-doc: fix processing nested structs with attributes Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 03/32] kernel-doc: add support for ____cacheline_aligned_in_smp attribute Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 04/32] scripts/kernel-doc: Add support for named variable macro arguments Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 05/32] scripts: kernel-doc: proper handle @foo->bar() Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 06/32] scripts: kernel-doc: accept negation like !@var Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 07/32] scripts: kernel-doc: accept blank lines on parameter description Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 08/32] Replace HTTP links with HTTPS ones: documentation Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 09/32] scripts/kernel-doc: parse __ETHTOOL_DECLARE_LINK_MODE_MASK Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 10/32] scripts/kernel-doc: handle function pointer prototypes Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 11/32] scripts/kernel-doc: optionally treat warnings as errors Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 12/32] kernel-doc: include line numbers for function prototypes Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 13/32] kernel-doc: add support for ____cacheline_aligned attribute Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 14/32] scripts: kernel-doc: add support for typedef enum Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 15/32] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments" Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 16/32] Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later" Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 17/32] scripts: kernel-doc: make it more compatible with Sphinx 3.x Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 18/32] scripts: kernel-doc: use a less pedantic markup for funcs on " Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 19/32] scripts: kernel-doc: fix troubles with line counts Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 20/32] scripts: kernel-doc: reimplement -nofunction argument Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 21/32] scripts: kernel-doc: fix typedef identification Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 22/32] scripts: kernel-doc: don't mangle with parameter list Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 23/32] scripts: kernel-doc: allow passing desired Sphinx C domain dialect Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 24/32] scripts: kernel-doc: fix line number handling Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 25/32] scripts: kernel-doc: try to use c:function if possible Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 26/32] Revert "kernel-doc: Handle function typedefs without asterisks" Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 27/32] Revert "kernel-doc: Handle function typedefs that return pointers" Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 28/32] scripts: kernel-doc: fix typedef parsing Paolo Bonzini
2020-12-01 10:34 ` [PATCH v2 29/32] scripts: kernel-doc: split typedef complex regex Paolo Bonzini
2020-12-01 10:35 ` [PATCH v2 30/32] scripts: kernel-doc: use :c:union when needed Paolo Bonzini
2020-12-01 10:35 ` [PATCH v2 31/32] Revert "docs: temporarily disable the kernel-doc extension" Paolo Bonzini
2020-12-01 11:02   ` Peter Maydell
2020-12-01 10:35 ` [PATCH v2 32/32] scripts: kernel-doc: remove unnecesssary change wrt Linux Paolo Bonzini
2020-12-01 10:46   ` Peter Maydell
2020-12-02  9:03   ` Philippe Mathieu-Daudé
2020-12-02  9:08     ` Paolo Bonzini
2020-12-01 11:07 ` [PATCH v2 00/32] kernel-doc: update from Linux 5.10 Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).