VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
cb77f0d623ff3 (Kamil Rytarowski            2017-05-07 23:25:26 +0200    1) #!/usr/bin/env perl
3847637840def (Jonathan Corbet             2018-02-20 12:24:23 -0700    2) # SPDX-License-Identifier: GPL-2.0
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700    3) 
cb77f0d623ff3 (Kamil Rytarowski            2017-05-07 23:25:26 +0200    4) use warnings;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700    5) use strict;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700    6) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700    7) ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved        ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700    8) ## Copyright (C) 2000, 1  Tim Waugh <twaugh@redhat.com>          ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700    9) ## Copyright (C) 2001  Simon Huggins                             ##
70c95b00b87f8 (Randy Dunlap                2012-01-21 10:31:54 -0800   10) ## Copyright (C) 2005-2012  Randy Dunlap                         ##
1b40c1944db44 (Dan Luedtke                 2012-08-12 10:46:15 +0200   11) ## Copyright (C) 2012  Dan Luedtke                               ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   12) ## 								 ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   13) ## #define enhancements by Armin Kuster <akuster@mvista.com>	 ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   14) ## Copyright (c) 2000 MontaVista Software, Inc.			 ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   15) ## 								 ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   16) ## This software falls under the GNU General Public License.     ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   17) ## Please read the COPYING file for more information             ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   18) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   19) # 18/01/2001 - 	Cleanups
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   20) # 		Functions prototyped as foo(void) same as foo()
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   21) # 		Stop eval'ing where we don't need to.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   22) # -- huggie@earth.li
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   23) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   24) # 27/06/2001 -  Allowed whitespace after initial "/**" and
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   25) #               allowed comments before function declarations.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   26) # -- Christian Kreibich <ck@whoop.org>
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   27) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   28) # Still to do:
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   29) # 	- add perldoc documentation
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   30) # 	- Look more closely at some of the scarier bits :)
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   31) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   32) # 26/05/2001 - 	Support for separate source and object trees.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   33) #		Return error code.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   34) # 		Keith Owens <kaos@ocs.com.au>
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   35) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   36) # 23/09/2001 - Added support for typedefs, structs, enums and unions
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   37) #              Support for Context section; can be terminated using empty line
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   38) #              Small fixes (like spaces vs. \s in regex)
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   39) # -- Tim Jansen <tim@tjansen.de>
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   40) 
1b40c1944db44 (Dan Luedtke                 2012-08-12 10:46:15 +0200   41) # 25/07/2012 - Added support for HTML5
1b40c1944db44 (Dan Luedtke                 2012-08-12 10:46:15 +0200   42) # -- Dan Luedtke <mail@danrl.de>
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   43) 
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   44) sub usage {
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   45)     my $message = <<"EOF";
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   46) Usage: $0 [OPTION ...] FILE ...
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   47) 
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   48) Read C language source or header FILEs, extract embedded documentation comments,
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   49) and print formatted documentation to standard output.
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   50) 
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   51) The documentation comments are identified by "/**" opening comment mark. See
857af3b775940 (Mauro Carvalho Chehab       2017-12-18 10:30:08 -0200   52) Documentation/doc-guide/kernel-doc.rst for the documentation comment syntax.
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   53) 
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   54) Output format selection (mutually exclusive):
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   55)   -man			Output troff manual page format. This is the default.
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300   56)   -rst			Output reStructuredText format.
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800   57)   -none			Do not output documentation, only warnings.
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   58) 
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200   59) Output format selection modifier (affects only ReST output):
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200   60) 
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200   61)   -sphinx-version	Use the ReST C domain dialect compatible with an
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200   62) 			specific Sphinx Version.
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200   63) 			If not specified, kernel-doc will auto-detect using
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200   64) 			the sphinx-build version found on PATH.
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200   65) 
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   66) Output selection (mutually exclusive):
86ae2e38d40ed (Jani Nikula                 2016-01-21 13:05:22 +0200   67)   -export		Only output documentation for symbols that have been
86ae2e38d40ed (Jani Nikula                 2016-01-21 13:05:22 +0200   68) 			exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL()
c9b2cfb3faece (Jani Nikula                 2016-06-07 11:05:53 +0300   69)                         in any input FILE or -export-file FILE.
86ae2e38d40ed (Jani Nikula                 2016-01-21 13:05:22 +0200   70)   -internal		Only output documentation for symbols that have NOT been
86ae2e38d40ed (Jani Nikula                 2016-01-21 13:05:22 +0200   71) 			exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL()
c9b2cfb3faece (Jani Nikula                 2016-06-07 11:05:53 +0300   72)                         in any input FILE or -export-file FILE.
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   73)   -function NAME	Only output documentation for the given function(s)
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   74) 			or DOC: section title(s). All other functions and DOC:
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   75) 			sections are ignored. May be specified multiple times.
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200   76)   -nosymbol NAME	Exclude the specified symbols from the output
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200   77) 		        documentation. May be specified multiple times.
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   78) 
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   79) Output selection modifiers:
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   80)   -no-doc-sections	Do not output DOC: sections.
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200   81)   -enable-lineno        Enable output of #define LINENO lines. Only works with
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200   82)                         reStructuredText format.
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300   83)   -export-file FILE     Specify an additional FILE in which to look for
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300   84)                         EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL(). To be used with
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300   85)                         -export or -internal. May be specified multiple times.
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   86) 
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   87) Other parameters:
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   88)   -v			Verbose output, more warnings and other information.
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   89)   -h			Print this help.
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500   90)   -Werror		Treat warnings as errors.
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   91) 
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   92) EOF
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   93)     print $message;
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   94)     exit 1;
fadc0b31cba0b (Jani Nikula                 2016-05-12 16:15:36 +0300   95) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   96) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   97) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   98) # format of comments.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700   99) # In the following table, (...)? signifies optional structure.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  100) #                         (...)* signifies 0 or more structure elements
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  101) # /**
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  102) #  * function_name(:)? (- short description)?
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  103) # (* @parameterx: (description of parameter x)?)*
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  104) # (* a blank line)?
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  105) #  * (Description:)? (Description of function)?
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  106) #  * (section header: (section description)? )*
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  107) #  (*)?*/
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  108) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  109) # So .. the trivial example would be:
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  110) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  111) # /**
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  112) #  * my_function
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  113) #  */
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  114) #
891dcd2f7ab15 (Randy Dunlap                2007-02-10 01:45:53 -0800  115) # If the Description: header tag is omitted, then there must be a blank line
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  116) # after the last parameter specification.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  117) # e.g.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  118) # /**
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  119) #  * my_function - does my stuff
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  120) #  * @my_arg: its mine damnit
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  121) #  *
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  122) #  * Does my stuff explained.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  123) #  */
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  124) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  125) #  or, could also use:
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  126) # /**
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  127) #  * my_function - does my stuff
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  128) #  * @my_arg: its mine damnit
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  129) #  * Description: Does my stuff explained.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  130) #  */
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  131) # etc.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  132) #
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  133) # Besides functions you can also write documentation for structs, unions,
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  134) # enums and typedefs. Instead of the function name you must write the name
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  135) # of the declaration;  the struct/union/enum/typedef must always precede
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  136) # the name. Nesting of declarations is not supported.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  137) # Use the argument mechanism to document members or constants.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  138) # e.g.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  139) # /**
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  140) #  * struct my_struct - short description
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  141) #  * @a: first member
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  142) #  * @b: second member
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  143) #  *
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  144) #  * Longer description
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  145) #  */
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  146) # struct my_struct {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  147) #     int a;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  148) #     int b;
aeec46b97a797 (Martin Waitz                2005-11-13 16:08:13 -0800  149) # /* private: */
aeec46b97a797 (Martin Waitz                2005-11-13 16:08:13 -0800  150) #     int c;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  151) # };
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  152) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  153) # All descriptions can be multiline, except the short function description.
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  154) #
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  155) # For really longs structs, you can also describe arguments inside the
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  156) # body of the struct.
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  157) # eg.
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  158) # /**
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  159) #  * struct my_struct - short description
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  160) #  * @a: first member
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  161) #  * @b: second member
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  162) #  *
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  163) #  * Longer description
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  164) #  */
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  165) # struct my_struct {
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  166) #     int a;
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  167) #     int b;
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  168) #     /**
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  169) #      * @c: This is longer description of C
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  170) #      *
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  171) #      * You can use paragraphs to describe arguments
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  172) #      * using this method.
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  173) #      */
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  174) #     int c;
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  175) # };
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  176) #
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  177) # This should be use only for struct/enum members.
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  178) #
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  179) # You can also add additional sections. When documenting kernel functions you
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  180) # should document the "Context:" of the function, e.g. whether the functions
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  181) # can be called form interrupts. Unlike other sections you can end it with an
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  182) # empty line.
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100  183) # A non-void function should have a "Return:" section describing the return
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100  184) # value(s).
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  185) # Example-sections should contain the string EXAMPLE so that they are marked
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  186) # appropriately in DocBook.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  187) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  188) # Example:
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  189) # /**
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  190) #  * user_function - function that can only be called in user context
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  191) #  * @a: some argument
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  192) #  * Context: !in_interrupt()
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  193) #  *
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  194) #  * Some description
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  195) #  * Example:
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  196) #  *    user_function(22);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  197) #  */
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  198) # ...
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  199) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  200) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  201) # All descriptive text is further processed, scanning for the following special
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  202) # patterns, which are highlighted appropriately.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  203) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  204) # 'funcname()' - function
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  205) # '$ENVVAR' - environmental variable
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  206) # '&struct_name' - name of a structure (up to two words including 'struct')
5267dd354bcd2 (Paolo Bonzini               2017-01-02 16:22:26 +0100  207) # '&struct_name.member' - name of a structure member
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  208) # '@parameter' - name of a parameter
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  209) # '%CONST' - name of a constant.
b97f193abf83e (Mauro Carvalho Chehab       2017-03-30 17:11:28 -0300  210) # '``LITERAL``' - literal string without any spaces on it.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  211) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800  212) ## init lots of data
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800  213) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  214) my $errors = 0;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  215) my $warnings = 0;
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700  216) my $anon_struct_union = 0;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  217) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  218) # match expressions used to find embedded type information
b97f193abf83e (Mauro Carvalho Chehab       2017-03-30 17:11:28 -0300  219) my $type_constant = '\b``([^\`]+)``\b';
b97f193abf83e (Mauro Carvalho Chehab       2017-03-30 17:11:28 -0300  220) my $type_constant2 = '\%([-_\w]+)';
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  221) my $type_func = '(\w+)\(\)';
bfd228c73090e (Mike Rapoport               2018-11-07 18:47:13 +0200  222) my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
ee2aa7590398e (Mauro Carvalho Chehab       2020-04-14 18:48:28 +0200  223) my $type_param_ref = '([\!]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
5219f18aaf00f (Jonathan Corbet             2016-08-24 16:31:15 -0600  224) my $type_fp_param = '\@(\w+)\(\)';  # Special RST handling for func ptr params
346282db9c6bc (Mauro Carvalho Chehab       2020-04-14 18:48:27 +0200  225) my $type_fp_param2 = '\@(\w+->\S+)\(\)';  # Special RST handling for structs with func ptr params
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  226) my $type_env = '(\$\w+)';
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  227) my $type_enum = '\&(enum\s*([_\w]+))';
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  228) my $type_struct = '\&(struct\s*([_\w]+))';
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  229) my $type_typedef = '\&(typedef\s*([_\w]+))';
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  230) my $type_union = '\&(union\s*([_\w]+))';
5267dd354bcd2 (Paolo Bonzini               2017-01-02 16:22:26 +0100  231) my $type_member = '\&([_\w]+)(\.|->)([_\w]+)';
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  232) my $type_fallback = '\&([_\w]+)';
f3341dcf3bdcd (Jani Nikula                 2016-05-26 16:35:02 +0300  233) my $type_member_func = $type_member . '\(\)';
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  234) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  235) # Output conversion substitutions.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  236) #  One for each output format
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  237) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  238) # these are pretty rough
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300  239) my @highlights_man = (
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300  240)                       [$type_constant, "\$1"],
b97f193abf83e (Mauro Carvalho Chehab       2017-03-30 17:11:28 -0300  241)                       [$type_constant2, "\$1"],
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300  242)                       [$type_func, "\\\\fB\$1\\\\fP"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  243)                       [$type_enum, "\\\\fI\$1\\\\fP"],
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300  244)                       [$type_struct, "\\\\fI\$1\\\\fP"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  245)                       [$type_typedef, "\\\\fI\$1\\\\fP"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  246)                       [$type_union, "\\\\fI\$1\\\\fP"],
5267dd354bcd2 (Paolo Bonzini               2017-01-02 16:22:26 +0100  247)                       [$type_param, "\\\\fI\$1\\\\fP"],
ee2aa7590398e (Mauro Carvalho Chehab       2020-04-14 18:48:28 +0200  248)                       [$type_param_ref, "\\\\fI\$1\$2\\\\fP"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  249)                       [$type_member, "\\\\fI\$1\$2\$3\\\\fP"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  250)                       [$type_fallback, "\\\\fI\$1\\\\fP"]
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300  251) 		     );
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  252) my $blankline_man = "";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  253) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  254) # rst-mode
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  255) my @highlights_rst = (
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  256)                        [$type_constant, "``\$1``"],
b97f193abf83e (Mauro Carvalho Chehab       2017-03-30 17:11:28 -0300  257)                        [$type_constant2, "``\$1``"],
f3341dcf3bdcd (Jani Nikula                 2016-05-26 16:35:02 +0300  258)                        # Note: need to escape () to avoid func matching later
5267dd354bcd2 (Paolo Bonzini               2017-01-02 16:22:26 +0100  259)                        [$type_member_func, "\\:c\\:type\\:`\$1\$2\$3\\\\(\\\\) <\$1>`"],
5267dd354bcd2 (Paolo Bonzini               2017-01-02 16:22:26 +0100  260)                        [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"],
5219f18aaf00f (Jonathan Corbet             2016-08-24 16:31:15 -0600  261) 		       [$type_fp_param, "**\$1\\\\(\\\\)**"],
346282db9c6bc (Mauro Carvalho Chehab       2020-04-14 18:48:27 +0200  262) 		       [$type_fp_param2, "**\$1\\\\(\\\\)**"],
344fdb28a0dfa (Jonathan Corbet             2019-06-21 17:34:30 -0600  263)                        [$type_func, "\$1()"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  264)                        [$type_enum, "\\:c\\:type\\:`\$1 <\$2>`"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  265)                        [$type_struct, "\\:c\\:type\\:`\$1 <\$2>`"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  266)                        [$type_typedef, "\\:c\\:type\\:`\$1 <\$2>`"],
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  267)                        [$type_union, "\\:c\\:type\\:`\$1 <\$2>`"],
a7291e7e03f8b (Jani Nikula                 2016-05-26 13:57:06 +0300  268)                        # in rst this can refer to any type
df31175bb4d37 (Paolo Bonzini               2017-01-02 16:22:27 +0100  269)                        [$type_fallback, "\\:c\\:type\\:`\$1`"],
ee2aa7590398e (Mauro Carvalho Chehab       2020-04-14 18:48:28 +0200  270)                        [$type_param_ref, "**\$1\$2**"]
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  271) 		      );
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  272) my $blankline_rst = "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  273) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  274) # read arguments
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  275) if ($#ARGV == -1) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  276)     usage();
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  277) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  278) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800  279) my $kernelversion;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  280) my ($sphinx_major, $sphinx_minor, $sphinx_patch);
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  281) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800  282) my $dohighlight = "";
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800  283) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  284) my $verbose = 0;
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  285) my $Werror = 0;
bdfe2be34b37d (Mauro Carvalho Chehab       2017-12-18 10:30:11 -0200  286) my $output_mode = "rst";
e314ba3130940 (Daniel Santos               2012-10-04 17:15:08 -0700  287) my $output_preformatted = 0;
4b44595a7b8e0 (Johannes Berg               2007-10-24 15:08:48 -0700  288) my $no_doc_sections = 0;
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  289) my $enable_lineno = 0;
bdfe2be34b37d (Mauro Carvalho Chehab       2017-12-18 10:30:11 -0200  290) my @highlights = @highlights_rst;
bdfe2be34b37d (Mauro Carvalho Chehab       2017-12-18 10:30:11 -0200  291) my $blankline = $blankline_rst;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  292) my $modulename = "Kernel API";
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  293) 
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  294) use constant {
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  295)     OUTPUT_ALL          => 0, # output all symbols and doc sections
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  296)     OUTPUT_INCLUDE      => 1, # output only specified symbols
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  297)     OUTPUT_EXPORTED     => 2, # output exported symbols
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  298)     OUTPUT_INTERNAL     => 3, # output non-exported symbols
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  299) };
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  300) my $output_selection = OUTPUT_ALL;
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600  301) my $show_not_found = 0;	# No longer used
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  302) 
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300  303) my @export_file_list;
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300  304) 
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  305) my @build_time;
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  306) if (defined($ENV{'KBUILD_BUILD_TIMESTAMP'}) &&
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  307)     (my $seconds = `date -d"${ENV{'KBUILD_BUILD_TIMESTAMP'}}" +%s`) ne '') {
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  308)     @build_time = gmtime($seconds);
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  309) } else {
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  310)     @build_time = localtime;
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  311) }
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  312) 
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  313) my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  314) 		'July', 'August', 'September', 'October',
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  315) 		'November', 'December')[$build_time[4]] .
b2c4105b080fb (Ben Hutchings               2015-07-08 20:07:16 +0100  316)   " " . ($build_time[5]+1900);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  317) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800  318) # Essentially these are globals.
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  319) # They probably want to be tidied up, made more localised or something.
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  320) # CAVEAT EMPTOR!  Some of the others I localised may not want to be, which
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  321) # could cause "use of undefined value" or other bugs.
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  322) my ($function, %function_table, %parametertypes, $declaration_purpose);
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  323) my %nosymbol_table = ();
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  324) my $declaration_start_line;
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  325) my ($type, $declaration_name, $return_type);
1c32fd0c5ac1c (Ilya Dryomov                2010-02-26 13:06:03 -0800  326) my ($newsection, $newcontents, $prototype, $brcount, %source_map);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  327) 
bd0e88e517403 (Randy Dunlap                2008-03-13 12:32:43 -0700  328) if (defined($ENV{'KBUILD_VERBOSE'})) {
bd0e88e517403 (Randy Dunlap                2008-03-13 12:32:43 -0700  329) 	$verbose = "$ENV{'KBUILD_VERBOSE'}";
bd0e88e517403 (Randy Dunlap                2008-03-13 12:32:43 -0700  330) }
bd0e88e517403 (Randy Dunlap                2008-03-13 12:32:43 -0700  331) 
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  332) if (defined($ENV{'KCFLAGS'})) {
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  333) 	my $kcflags = "$ENV{'KCFLAGS'}";
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  334) 
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  335) 	if ($kcflags =~ /Werror/) {
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  336) 		$Werror = 1;
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  337) 	}
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  338) }
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  339) 
bed4ed3057e49 (Laurent Pinchart            2021-07-31 01:54:01 +0300  340) if (defined($ENV{'KDOC_WERROR'})) {
bed4ed3057e49 (Laurent Pinchart            2021-07-31 01:54:01 +0300  341) 	$Werror = "$ENV{'KDOC_WERROR'}";
bed4ed3057e49 (Laurent Pinchart            2021-07-31 01:54:01 +0300  342) }
bed4ed3057e49 (Laurent Pinchart            2021-07-31 01:54:01 +0300  343) 
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  344) # Generated docbook code is inserted in a template at a point where
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  345) # docbook v3.1 requires a non-zero sequence of RefEntry's; see:
93431e0607e58 (Alexander A. Klimov         2020-05-26 08:05:44 +0200  346) # https://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  347) # We keep track of number of generated entries and generate a dummy
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  348) # if needs be to ensure the expanded template can be postprocessed
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  349) # into html.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  350) my $section_counter = 0;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  351) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  352) my $lineprefix="";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  353) 
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  354) # Parser states
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  355) use constant {
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200  356)     STATE_NORMAL        => 0,        # normal code
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200  357)     STATE_NAME          => 1,        # looking for function name
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200  358)     STATE_BODY_MAYBE    => 2,        # body - or maybe more description
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200  359)     STATE_BODY          => 3,        # the body of the comment
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200  360)     STATE_BODY_WITH_BLANK_LINE => 4, # the body, which has a blank line
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200  361)     STATE_PROTO         => 5,        # scanning prototype
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200  362)     STATE_DOCBLOCK      => 6,        # documentation block
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200  363)     STATE_INLINE        => 7,        # gathering doc outside main block
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  364) };
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  365) my $state;
850622dfaf3d6 (Randy Dunlap                2006-06-25 05:48:55 -0700  366) my $in_doc_sect;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700  367) my $leading_space;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  368) 
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  369) # Inline documentation state
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  370) use constant {
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  371)     STATE_INLINE_NA     => 0, # not applicable ($state != STATE_INLINE)
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  372)     STATE_INLINE_NAME   => 1, # looking for member name (@foo:)
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  373)     STATE_INLINE_TEXT   => 2, # looking for member documentation
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  374)     STATE_INLINE_END    => 3, # done
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  375)     STATE_INLINE_ERROR  => 4, # error - Comment without header was found.
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  376)                               # Spit a warning as it's not
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  377)                               # proper kernel-doc and ignore the rest.
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  378) };
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  379) my $inline_doc_state;
a4c6ebede2f99 (Danilo Cesar Lemes de Paula 2015-08-04 09:04:08 -0300  380) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  381) #declaration types: can be
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  382) # 'function', 'struct', 'union', 'enum', 'typedef'
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  383) my $decl_type;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  384) 
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100  385) # Name of the kernel-doc identifier for non-DOC markups
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100  386) my $identifier;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100  387) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  388) my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  389) my $doc_end = '\*/';
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  390) my $doc_com = '\s*\*\s*';
12ae677933218 (Daniel Santos               2012-10-04 17:15:10 -0700  391) my $doc_com_body = '\s*\* ?';
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  392) my $doc_decl = $doc_com . '(\w+)';
f624adef3d0b9 (Jani Nikula                 2016-05-29 11:35:28 +0300  393) # @params and a strictly limited set of supported section names
212209cff89fe (Jonathan Corbet             2021-03-26 13:16:35 -0600  394) # Specifically:
212209cff89fe (Jonathan Corbet             2021-03-26 13:16:35 -0600  395) #   Match @word:
212209cff89fe (Jonathan Corbet             2021-03-26 13:16:35 -0600  396) #	  @...:
212209cff89fe (Jonathan Corbet             2021-03-26 13:16:35 -0600  397) #         @{section-name}:
212209cff89fe (Jonathan Corbet             2021-03-26 13:16:35 -0600  398) # while trying to not match literal block starts like "example::"
212209cff89fe (Jonathan Corbet             2021-03-26 13:16:35 -0600  399) #
76dd3e7b6650b (Mike Rapoport               2018-11-07 18:47:12 +0200  400) my $doc_sect = $doc_com .
212209cff89fe (Jonathan Corbet             2021-03-26 13:16:35 -0600  401)     '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:([^:].*)?$';
12ae677933218 (Daniel Santos               2012-10-04 17:15:10 -0700  402) my $doc_content = $doc_com_body . '(.*)';
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  403) my $doc_block = $doc_com . 'DOC:\s*(.*)?';
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  404) my $doc_inline_start = '^\s*/\*\*\s*$';
fe7bc493d9795 (Mauro Carvalho Chehab       2018-02-16 11:48:18 -0200  405) my $doc_inline_sect = '\s*\*\s*(@\s*[\w][\w\.]*\s*):(.*)';
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300  406) my $doc_inline_end = '^\s*\*/\s*$';
0c9aa209579d4 (Jani Nikula                 2016-11-16 17:26:16 +0200  407) my $doc_inline_oneline = '^\s*/\*\*\s*(@[\w\s]+):\s*(.*)\s*\*/\s*$';
86ae2e38d40ed (Jani Nikula                 2016-01-21 13:05:22 +0200  408) my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;';
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530  409) my $function_pointer = qr{([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530  410) my $attribute = qr{__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)}i;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  411) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  412) my %parameterdescs;
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  413) my %parameterdesc_start_lines;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  414) my @parameterlist;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  415) my %sections;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  416) my @sectionlist;
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  417) my %section_start_lines;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800  418) my $sectcheck;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800  419) my $struct_actual;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  420) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  421) my $contents = "";
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  422) my $new_start_line = 0;
f624adef3d0b9 (Jani Nikula                 2016-05-29 11:35:28 +0300  423) 
f624adef3d0b9 (Jani Nikula                 2016-05-29 11:35:28 +0300  424) # the canonical section names. see also $doc_sect above.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  425) my $section_default = "Description";	# default section
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  426) my $section_intro = "Introduction";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  427) my $section = $section_default;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  428) my $section_context = "Context";
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100  429) my $section_return = "Return";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  430) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  431) my $undescribed = "-- undescribed --";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  432) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  433) reset_state();
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  434) 
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  435) while ($ARGV[0] =~ m/^--?(.*)/) {
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  436)     my $cmd = $1;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  437)     shift @ARGV;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  438)     if ($cmd eq "man") {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  439) 	$output_mode = "man";
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300  440) 	@highlights = @highlights_man;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  441) 	$blankline = $blankline_man;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  442)     } elsif ($cmd eq "rst") {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  443) 	$output_mode = "rst";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  444) 	@highlights = @highlights_rst;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  445) 	$blankline = $blankline_rst;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  446)     } elsif ($cmd eq "none") {
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800  447) 	$output_mode = "none";
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  448)     } elsif ($cmd eq "module") { # not needed for XML, inherits from calling document
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  449) 	$modulename = shift @ARGV;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  450)     } elsif ($cmd eq "function") { # to only output specific functions
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  451) 	$output_selection = OUTPUT_INCLUDE;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  452) 	$function = shift @ARGV;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  453) 	$function_table{$function} = 1;
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  454)     } elsif ($cmd eq "nosymbol") { # Exclude specific symbols
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  455) 	my $symbol = shift @ARGV;
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  456) 	$nosymbol_table{$symbol} = 1;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  457)     } elsif ($cmd eq "export") { # only exported symbols
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  458) 	$output_selection = OUTPUT_EXPORTED;
da9726ecfba20 (Jani Nikula                 2016-06-07 10:29:59 +0300  459) 	%function_table = ();
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  460)     } elsif ($cmd eq "internal") { # only non-exported symbols
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  461) 	$output_selection = OUTPUT_INTERNAL;
da9726ecfba20 (Jani Nikula                 2016-06-07 10:29:59 +0300  462) 	%function_table = ();
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  463)     } elsif ($cmd eq "export-file") {
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300  464) 	my $file = shift @ARGV;
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300  465) 	push(@export_file_list, $file);
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  466)     } elsif ($cmd eq "v") {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  467) 	$verbose = 1;
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  468)     } elsif ($cmd eq "Werror") {
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500  469) 	$Werror = 1;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  470)     } elsif (($cmd eq "h") || ($cmd eq "help")) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  471) 	usage();
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  472)     } elsif ($cmd eq 'no-doc-sections') {
4b44595a7b8e0 (Johannes Berg               2007-10-24 15:08:48 -0700  473) 	    $no_doc_sections = 1;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  474)     } elsif ($cmd eq 'enable-lineno') {
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  475) 	    $enable_lineno = 1;
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  476)     } elsif ($cmd eq 'show-not-found') {
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600  477) 	$show_not_found = 1;  # A no-op but don't fail
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  478)     } elsif ($cmd eq "sphinx-version") {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  479) 	my $ver_string = shift @ARGV;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  480) 	if ($ver_string =~ m/^(\d+)(\.\d+)?(\.\d+)?/) {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  481) 	    $sphinx_major = $1;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  482) 	    if (defined($2)) {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  483) 		$sphinx_minor = substr($2,1);
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  484) 	    } else {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  485) 		$sphinx_minor = 0;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  486) 	    }
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  487) 	    if (defined($3)) {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  488) 		$sphinx_patch = substr($3,1)
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  489) 	    } else {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  490) 		$sphinx_patch = 0;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  491) 	    }
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  492) 	} else {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  493) 	    die "Sphinx version should either major.minor or major.minor.patch format\n";
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  494) 	}
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  495)     } else {
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  496) 	# Unknown argument
b031ac4e7ddcd (Mauro Carvalho Chehab       2017-12-18 10:30:10 -0200  497)         usage();
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  498)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  499) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  500) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800  501) # continue execution near EOF;
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800  502) 
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  503) # The C domain dialect changed on Sphinx 3. So, we need to check the
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  504) # version in order to produce the right tags.
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  505) sub findprog($)
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  506) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  507) 	foreach(split(/:/, $ENV{PATH})) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  508) 		return "$_/$_[0]" if(-x "$_/$_[0]");
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  509) 	}
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  510) }
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  511) 
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  512) sub get_sphinx_version()
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  513) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  514) 	my $ver;
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  515) 
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  516) 	my $cmd = "sphinx-build";
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  517) 	if (!findprog($cmd)) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  518) 		my $cmd = "sphinx-build3";
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  519) 		if (!findprog($cmd)) {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  520) 			$sphinx_major = 1;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  521) 			$sphinx_minor = 2;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  522) 			$sphinx_patch = 0;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  523) 			printf STDERR "Warning: Sphinx version not found. Using default (Sphinx version %d.%d.%d)\n",
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  524) 			       $sphinx_major, $sphinx_minor, $sphinx_patch;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  525) 			return;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  526) 		}
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  527) 	}
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  528) 
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  529) 	open IN, "$cmd --version 2>&1 |";
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  530) 	while (<IN>) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  531) 		if (m/^\s*sphinx-build\s+([\d]+)\.([\d\.]+)(\+\/[\da-f]+)?$/) {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  532) 			$sphinx_major = $1;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  533) 			$sphinx_minor = $2;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  534) 			$sphinx_patch = $3;
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  535) 			last;
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  536) 		}
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  537) 		# Sphinx 1.2.x uses a different format
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  538) 		if (m/^\s*Sphinx.*\s+([\d]+)\.([\d\.]+)$/) {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  539) 			$sphinx_major = $1;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  540) 			$sphinx_minor = $2;
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200  541) 			$sphinx_patch = $3;
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  542) 			last;
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  543) 		}
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  544) 	}
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  545) 	close IN;
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  546) }
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  547) 
53f049fa5f187 (Borislav Petkov             2007-05-08 00:30:54 -0700  548) # get kernel version from env
53f049fa5f187 (Borislav Petkov             2007-05-08 00:30:54 -0700  549) sub get_kernel_version() {
1b9bc22d71c75 (Johannes Berg               2007-10-24 15:08:48 -0700  550)     my $version = 'unknown kernel version';
53f049fa5f187 (Borislav Petkov             2007-05-08 00:30:54 -0700  551) 
53f049fa5f187 (Borislav Petkov             2007-05-08 00:30:54 -0700  552)     if (defined($ENV{'KERNELVERSION'})) {
53f049fa5f187 (Borislav Petkov             2007-05-08 00:30:54 -0700  553) 	$version = $ENV{'KERNELVERSION'};
53f049fa5f187 (Borislav Petkov             2007-05-08 00:30:54 -0700  554)     }
53f049fa5f187 (Borislav Petkov             2007-05-08 00:30:54 -0700  555)     return $version;
53f049fa5f187 (Borislav Petkov             2007-05-08 00:30:54 -0700  556) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  557) 
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  558) #
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  559) sub print_lineno {
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  560)     my $lineno = shift;
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  561)     if ($enable_lineno && defined($lineno)) {
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  562)         print "#define LINENO " . $lineno . "\n";
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  563)     }
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  564) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  565) ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  566) # dumps section contents to arrays/hashes intended for that purpose.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  567) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  568) sub dump_section {
94dc7ad5502e7 (Randy Dunlap                2008-04-28 02:16:34 -0700  569)     my $file = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  570)     my $name = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  571)     my $contents = join "\n", @_;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  572) 
13901ef27c354 (Jani Nikula                 2016-05-26 08:57:29 +0300  573)     if ($name =~ m/$type_param/) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  574) 	$name = $1;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  575) 	$parameterdescs{$name} = $contents;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800  576) 	$sectcheck = $sectcheck . $name . " ";
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  577)         $parameterdesc_start_lines{$name} = $new_start_line;
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  578)         $new_start_line = 0;
ced69090c573f (Randy Dunlap                2008-12-01 13:14:03 -0800  579)     } elsif ($name eq "@\.\.\.") {
ced69090c573f (Randy Dunlap                2008-12-01 13:14:03 -0800  580) 	$name = "...";
ced69090c573f (Randy Dunlap                2008-12-01 13:14:03 -0800  581) 	$parameterdescs{$name} = $contents;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800  582) 	$sectcheck = $sectcheck . $name . " ";
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  583)         $parameterdesc_start_lines{$name} = $new_start_line;
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  584)         $new_start_line = 0;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  585)     } else {
94dc7ad5502e7 (Randy Dunlap                2008-04-28 02:16:34 -0700  586) 	if (defined($sections{$name}) && ($sections{$name} ne "")) {
95b6be9d198d9 (Jani Nikula                 2016-06-10 11:14:05 +0300  587) 	    # Only warn on user specified duplicate section names.
95b6be9d198d9 (Jani Nikula                 2016-06-10 11:14:05 +0300  588) 	    if ($name ne $section_default) {
95b6be9d198d9 (Jani Nikula                 2016-06-10 11:14:05 +0300  589) 		print STDERR "${file}:$.: warning: duplicate section name '$name'\n";
95b6be9d198d9 (Jani Nikula                 2016-06-10 11:14:05 +0300  590) 		++$warnings;
95b6be9d198d9 (Jani Nikula                 2016-06-10 11:14:05 +0300  591) 	    }
32217761ee9db (Jani Nikula                 2016-05-29 09:40:44 +0300  592) 	    $sections{$name} .= $contents;
32217761ee9db (Jani Nikula                 2016-05-29 09:40:44 +0300  593) 	} else {
32217761ee9db (Jani Nikula                 2016-05-29 09:40:44 +0300  594) 	    $sections{$name} = $contents;
32217761ee9db (Jani Nikula                 2016-05-29 09:40:44 +0300  595) 	    push @sectionlist, $name;
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  596)             $section_start_lines{$name} = $new_start_line;
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  597)             $new_start_line = 0;
94dc7ad5502e7 (Randy Dunlap                2008-04-28 02:16:34 -0700  598) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  599)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  600) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  601) 
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  602) ##
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  603) # dump DOC: section after checking that it should go out
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  604) #
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  605) sub dump_doc_section {
94dc7ad5502e7 (Randy Dunlap                2008-04-28 02:16:34 -0700  606)     my $file = shift;
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  607)     my $name = shift;
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  608)     my $contents = join "\n", @_;
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  609) 
4b44595a7b8e0 (Johannes Berg               2007-10-24 15:08:48 -0700  610)     if ($no_doc_sections) {
4b44595a7b8e0 (Johannes Berg               2007-10-24 15:08:48 -0700  611)         return;
4b44595a7b8e0 (Johannes Berg               2007-10-24 15:08:48 -0700  612)     }
4b44595a7b8e0 (Johannes Berg               2007-10-24 15:08:48 -0700  613) 
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  614)     return if (defined($nosymbol_table{$name}));
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  615) 
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  616)     if (($output_selection == OUTPUT_ALL) ||
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  617) 	(($output_selection == OUTPUT_INCLUDE) &&
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  618) 	 defined($function_table{$name})))
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  619)     {
94dc7ad5502e7 (Randy Dunlap                2008-04-28 02:16:34 -0700  620) 	dump_section($file, $name, $contents);
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  621) 	output_blockhead({'sectionlist' => \@sectionlist,
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  622) 			  'sections' => \%sections,
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  623) 			  'module' => $modulename,
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300  624) 			  'content-only' => ($output_selection != OUTPUT_ALL), });
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  625)     }
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  626) }
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  627) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  628) ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  629) # output function
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  630) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  631) # parameterdescs, a hash.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  632) #  function => "function name"
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  633) #  parameterlist => @list of parameters
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  634) #  parameterdescs => %parameter descriptions
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  635) #  sectionlist => @list of sections
a21217daae8ce (Randy Dunlap                2007-02-10 01:46:04 -0800  636) #  sections => %section descriptions
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800  637) #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  638) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  639) sub output_highlight {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  640)     my $contents = join "\n",@_;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  641)     my $line;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  642) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  643) #   DEBUG
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  644) #   if (!defined $contents) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  645) #	use Carp;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  646) #	confess "output_highlight got called with no args?\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  647) #   }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  648) 
3eb014a103701 (Randy Dunlap                2007-05-08 00:29:51 -0700  649) #   print STDERR "contents b4:$contents\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  650)     eval $dohighlight;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  651)     die $@ if $@;
3eb014a103701 (Randy Dunlap                2007-05-08 00:29:51 -0700  652) #   print STDERR "contents af:$contents\n";
3eb014a103701 (Randy Dunlap                2007-05-08 00:29:51 -0700  653) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  654)     foreach $line (split "\n", $contents) {
12ae677933218 (Daniel Santos               2012-10-04 17:15:10 -0700  655) 	if (! $output_preformatted) {
12ae677933218 (Daniel Santos               2012-10-04 17:15:10 -0700  656) 	    $line =~ s/^\s*//;
12ae677933218 (Daniel Santos               2012-10-04 17:15:10 -0700  657) 	}
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700  658) 	if ($line eq ""){
e314ba3130940 (Daniel Santos               2012-10-04 17:15:08 -0700  659) 	    if (! $output_preformatted) {
0bba924ce99aa (Jonathan Corbet             2018-02-05 12:40:15 -0700  660) 		print $lineprefix, $blankline;
e314ba3130940 (Daniel Santos               2012-10-04 17:15:08 -0700  661) 	    }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  662) 	} else {
cdccb316c0860 (Randy Dunlap                2007-07-19 01:48:25 -0700  663) 	    if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
cdccb316c0860 (Randy Dunlap                2007-07-19 01:48:25 -0700  664) 		print "\\&$line";
cdccb316c0860 (Randy Dunlap                2007-07-19 01:48:25 -0700  665) 	    } else {
cdccb316c0860 (Randy Dunlap                2007-07-19 01:48:25 -0700  666) 		print $lineprefix, $line;
cdccb316c0860 (Randy Dunlap                2007-07-19 01:48:25 -0700  667) 	    }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  668) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  669) 	print "\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  670)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  671) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  672) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  673) ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  674) # output function in man
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  675) sub output_function_man(%) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  676)     my %args = %{$_[0]};
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  677)     my ($parameter, $section);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  678)     my $count;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  679) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  680)     print ".TH \"$args{'function'}\" 9 \"$args{'function'}\" \"$man_date\" \"Kernel Hacker's Manual\" LINUX\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  681) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  682)     print ".SH NAME\n";
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  683)     print $args{'function'} . " \\- " . $args{'purpose'} . "\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  684) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  685)     print ".SH SYNOPSIS\n";
a21217daae8ce (Randy Dunlap                2007-02-10 01:46:04 -0800  686)     if ($args{'functiontype'} ne "") {
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  687) 	print ".B \"" . $args{'functiontype'} . "\" " . $args{'function'} . "\n";
a21217daae8ce (Randy Dunlap                2007-02-10 01:46:04 -0800  688)     } else {
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  689) 	print ".B \"" . $args{'function'} . "\n";
a21217daae8ce (Randy Dunlap                2007-02-10 01:46:04 -0800  690)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  691)     $count = 0;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  692)     my $parenth = "(";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  693)     my $post = ",";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  694)     foreach my $parameter (@{$args{'parameterlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  695) 	if ($count == $#{$args{'parameterlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  696) 	    $post = ");";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  697) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  698) 	$type = $args{'parametertypes'}{$parameter};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530  699) 	if ($type =~ m/$function_pointer/) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  700) 	    # pointer-to-function
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200  701) 	    print ".BI \"" . $parenth . $1 . "\" " . " \") (" . $2 . ")" . $post . "\"\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  702) 	} else {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  703) 	    $type =~ s/([^\*])$/$1 /;
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200  704) 	    print ".BI \"" . $parenth . $type . "\" " . " \"" . $post . "\"\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  705) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  706) 	$count++;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  707) 	$parenth = "";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  708)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  709) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  710)     print ".SH ARGUMENTS\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  711)     foreach $parameter (@{$args{'parameterlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  712) 	my $parameter_name = $parameter;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  713) 	$parameter_name =~ s/\[.*//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  714) 
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  715) 	print ".IP \"" . $parameter . "\" 12\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  716) 	output_highlight($args{'parameterdescs'}{$parameter_name});
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  717)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  718)     foreach $section (@{$args{'sectionlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  719) 	print ".SH \"", uc $section, "\"\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  720) 	output_highlight($args{'sections'}{$section});
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  721)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  722) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  723) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  724) ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  725) # output enum in man
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  726) sub output_enum_man(%) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  727)     my %args = %{$_[0]};
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  728)     my ($parameter, $section);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  729)     my $count;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  730) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  731)     print ".TH \"$args{'module'}\" 9 \"enum $args{'enum'}\" \"$man_date\" \"API Manual\" LINUX\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  732) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  733)     print ".SH NAME\n";
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  734)     print "enum " . $args{'enum'} . " \\- " . $args{'purpose'} . "\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  735) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  736)     print ".SH SYNOPSIS\n";
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  737)     print "enum " . $args{'enum'} . " {\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  738)     $count = 0;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  739)     foreach my $parameter (@{$args{'parameterlist'}}) {
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700  740) 	print ".br\n.BI \"    $parameter\"\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  741) 	if ($count == $#{$args{'parameterlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  742) 	    print "\n};\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  743) 	    last;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  744) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  745) 	else {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  746) 	    print ", \n.br\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  747) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  748) 	$count++;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  749)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  750) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  751)     print ".SH Constants\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  752)     foreach $parameter (@{$args{'parameterlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  753) 	my $parameter_name = $parameter;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  754) 	$parameter_name =~ s/\[.*//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  755) 
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  756) 	print ".IP \"" . $parameter . "\" 12\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  757) 	output_highlight($args{'parameterdescs'}{$parameter_name});
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  758)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  759)     foreach $section (@{$args{'sectionlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  760) 	print ".SH \"$section\"\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  761) 	output_highlight($args{'sections'}{$section});
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  762)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  763) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  764) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  765) ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  766) # output struct in man
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  767) sub output_struct_man(%) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  768)     my %args = %{$_[0]};
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  769)     my ($parameter, $section);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  770) 
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  771)     print ".TH \"$args{'module'}\" 9 \"" . $args{'type'} . " " . $args{'struct'} . "\" \"$man_date\" \"API Manual\" LINUX\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  772) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  773)     print ".SH NAME\n";
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  774)     print $args{'type'} . " " . $args{'struct'} . " \\- " . $args{'purpose'} . "\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  775) 
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200  776)     my $declaration = $args{'definition'};
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200  777)     $declaration =~ s/\t/  /g;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200  778)     $declaration =~ s/\n/"\n.br\n.BI \"/g;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  779)     print ".SH SYNOPSIS\n";
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  780)     print $args{'type'} . " " . $args{'struct'} . " {\n.br\n";
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200  781)     print ".BI \"$declaration\n};\n.br\n\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  782) 
c51d3dac321df (Randy Dunlap                2006-06-25 05:49:14 -0700  783)     print ".SH Members\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  784)     foreach $parameter (@{$args{'parameterlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  785) 	($parameter =~ /^#/) && next;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  786) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  787) 	my $parameter_name = $parameter;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  788) 	$parameter_name =~ s/\[.*//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  789) 
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700  790) 	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  791) 	print ".IP \"" . $parameter . "\" 12\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  792) 	output_highlight($args{'parameterdescs'}{$parameter_name});
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  793)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  794)     foreach $section (@{$args{'sectionlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  795) 	print ".SH \"$section\"\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  796) 	output_highlight($args{'sections'}{$section});
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  797)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  798) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  799) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  800) ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  801) # output typedef in man
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  802) sub output_typedef_man(%) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  803)     my %args = %{$_[0]};
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  804)     my ($parameter, $section);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  805) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  806)     print ".TH \"$args{'module'}\" 9 \"$args{'typedef'}\" \"$man_date\" \"API Manual\" LINUX\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  807) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  808)     print ".SH NAME\n";
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700  809)     print "typedef " . $args{'typedef'} . " \\- " . $args{'purpose'} . "\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  810) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  811)     foreach $section (@{$args{'sectionlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  812) 	print ".SH \"$section\"\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  813) 	output_highlight($args{'sections'}{$section});
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  814)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  815) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  816) 
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700  817) sub output_blockhead_man(%) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  818)     my %args = %{$_[0]};
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  819)     my ($parameter, $section);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  820)     my $count;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  821) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  822)     print ".TH \"$args{'module'}\" 9 \"$args{'module'}\" \"$man_date\" \"API Manual\" LINUX\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  823) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  824)     foreach $section (@{$args{'sectionlist'}}) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  825) 	print ".SH \"$section\"\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  826) 	output_highlight($args{'sections'}{$section});
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  827)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  828) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700  829) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  830) ##
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  831) # output in restructured text
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  832) #
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  833) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  834) #
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  835) # This could use some work; it's used to output the DOC: sections, and
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  836) # starts by putting out the name of the doc section itself, but that tends
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  837) # to duplicate a header already in the template file.
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  838) #
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  839) sub output_blockhead_rst(%) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  840)     my %args = %{$_[0]};
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  841)     my ($parameter, $section);
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  842) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  843)     foreach $section (@{$args{'sectionlist'}}) {
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  844) 	next if (defined($nosymbol_table{$section}));
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200  845) 
9e72184b55df2 (Jani Nikula                 2016-05-29 22:27:35 +0300  846) 	if ($output_selection != OUTPUT_INCLUDE) {
06a755d6269c0 (Michal Wajdeczko            2021-01-18 12:08:13 +0100  847) 	    print ".. _$section:\n\n";
9e72184b55df2 (Jani Nikula                 2016-05-29 22:27:35 +0300  848) 	    print "**$section**\n\n";
9e72184b55df2 (Jani Nikula                 2016-05-29 22:27:35 +0300  849) 	}
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200  850)         print_lineno($section_start_lines{$section});
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  851) 	output_highlight_rst($args{'sections'}{$section});
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  852) 	print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  853)     }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  854) }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  855) 
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  856) #
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  857) # Apply the RST highlights to a sub-block of text.
76dd3e7b6650b (Mike Rapoport               2018-11-07 18:47:12 +0200  858) #
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  859) sub highlight_block($) {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  860)     # The dohighlight kludge requires the text be called $contents
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  861)     my $contents = shift;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  862)     eval $dohighlight;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  863)     die $@ if $@;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  864)     return $contents;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  865) }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  866) 
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  867) #
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  868) # Regexes used only here.
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  869) #
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  870) my $sphinx_literal = '^[^.].*::$';
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  871) my $sphinx_cblock = '^\.\.\ +code-block::';
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  872) 
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  873) sub output_highlight_rst {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  874)     my $input = join "\n",@_;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  875)     my $output = "";
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  876)     my $line;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  877)     my $in_literal = 0;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  878)     my $litprefix;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  879)     my $block = "";
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  880) 
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  881)     foreach $line (split "\n",$input) {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  882) 	#
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  883) 	# If we're in a literal block, see if we should drop out
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  884) 	# of it.  Otherwise pass the line straight through unmunged.
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  885) 	#
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  886) 	if ($in_literal) {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  887) 	    if (! ($line =~ /^\s*$/)) {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  888) 		#
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  889) 		# If this is the first non-blank line in a literal
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  890) 		# block we need to figure out what the proper indent is.
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  891) 		#
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  892) 		if ($litprefix eq "") {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  893) 		    $line =~ /^(\s*)/;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  894) 		    $litprefix = '^' . $1;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  895) 		    $output .= $line . "\n";
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  896) 		} elsif (! ($line =~ /$litprefix/)) {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  897) 		    $in_literal = 0;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  898) 		} else {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  899) 		    $output .= $line . "\n";
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  900) 		}
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  901) 	    } else {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  902) 		$output .= $line . "\n";
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  903) 	    }
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  904) 	}
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  905) 	#
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  906) 	# Not in a literal block (or just dropped out)
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  907) 	#
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  908) 	if (! $in_literal) {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  909) 	    $block .= $line . "\n";
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  910) 	    if (($line =~ /$sphinx_literal/) || ($line =~ /$sphinx_cblock/)) {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  911) 		$in_literal = 1;
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  912) 		$litprefix = "";
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  913) 		$output .= highlight_block($block);
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  914) 		$block = ""
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  915) 	    }
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  916) 	}
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  917)     }
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  918) 
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  919)     if ($block) {
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  920) 	$output .= highlight_block($block);
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  921)     }
af250290430e1 (Jonathan Corbet             2018-02-06 15:58:45 -0700  922)     foreach $line (split "\n", $output) {
830066a7a317e (Jani Nikula                 2016-05-26 22:04:33 +0300  923) 	print $lineprefix . $line . "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  924)     }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  925) }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  926) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  927) sub output_function_rst(%) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  928)     my %args = %{$_[0]};
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  929)     my ($parameter, $section);
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300  930)     my $oldprefix = $lineprefix;
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  931)     my $start = "";
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  932)     my $is_macro = 0;
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  933) 
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  934)     if ($sphinx_major < 3) {
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  935) 	if ($args{'typedef'}) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  936) 	    print ".. c:type:: ". $args{'function'} . "\n\n";
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  937) 	    print_lineno($declaration_start_line);
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  938) 	    print "   **Typedef**: ";
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  939) 	    $lineprefix = "";
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  940) 	    output_highlight_rst($args{'purpose'});
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  941) 	    $start = "\n\n**Syntax**\n\n  ``";
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  942) 	    $is_macro = 1;
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  943) 	} else {
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  944) 	    print ".. c:function:: ";
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200  945) 	}
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  946)     } else {
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  947) 	if ($args{'typedef'} || $args{'functiontype'} eq "") {
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  948) 	    $is_macro = 1;
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  949) 	    print ".. c:macro:: ". $args{'function'} . "\n\n";
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  950) 	} else {
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  951) 	    print ".. c:function:: ";
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  952) 	}
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  953) 
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  954) 	if ($args{'typedef'}) {
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  955) 	    print_lineno($declaration_start_line);
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  956) 	    print "   **Typedef**: ";
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  957) 	    $lineprefix = "";
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  958) 	    output_highlight_rst($args{'purpose'});
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  959) 	    $start = "\n\n**Syntax**\n\n  ``";
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  960) 	} else {
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  961) 	    print "``" if ($is_macro);
e3ad05fe6e6ff (Mauro Carvalho Chehab       2020-09-25 10:05:40 +0200  962) 	}
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  963)     }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  964)     if ($args{'functiontype'} ne "") {
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  965) 	$start .= $args{'functiontype'} . " " . $args{'function'} . " (";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  966)     } else {
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  967) 	$start .= $args{'function'} . " (";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  968)     }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  969)     print $start;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  970) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  971)     my $count = 0;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  972)     foreach my $parameter (@{$args{'parameterlist'}}) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  973) 	if ($count ne 0) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  974) 	    print ", ";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  975) 	}
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  976) 	$count++;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  977) 	$type = $args{'parametertypes'}{$parameter};
a88b1672d4ddf (Mauro Carvalho Chehab       2016-07-22 11:46:36 -0300  978) 
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530  979) 	if ($type =~ m/$function_pointer/) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  980) 	    # pointer-to-function
e8f4ba833166d (Peter Maydell               2020-04-14 15:37:43 +0100  981) 	    print $1 . $parameter . ") (" . $2 . ")";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  982) 	} else {
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200  983) 	    print $type;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  984) 	}
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  985)     }
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  986)     if ($is_macro) {
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  987) 	print ")``\n\n";
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  988)     } else {
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  989) 	print ")\n\n";
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  990)     }
6e9e415854c15 (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200  991)     if (!$args{'typedef'}) {
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  992) 	print_lineno($declaration_start_line);
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  993) 	$lineprefix = "   ";
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  994) 	output_highlight_rst($args{'purpose'});
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  995) 	print "\n";
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300  996)     }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300  997) 
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300  998)     print "**Parameters**\n\n";
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300  999)     $lineprefix = "  ";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1000)     foreach $parameter (@{$args{'parameterlist'}}) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1001) 	my $parameter_name = $parameter;
ada5f446bbe50 (Gabriel Krisman Bertazi     2017-01-09 18:11:57 -0200 1002) 	$parameter_name =~ s/\[.*//;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1003) 	$type = $args{'parametertypes'}{$parameter};
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1004) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1005) 	if ($type ne "") {
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1006) 	    print "``$type``\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1007) 	} else {
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1008) 	    print "``$parameter``\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1009) 	}
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200 1010) 
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200 1011)         print_lineno($parameterdesc_start_lines{$parameter_name});
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200 1012) 
5e64fa9c441ff (Jani Nikula                 2016-05-19 20:32:48 +0300 1013) 	if (defined($args{'parameterdescs'}{$parameter_name}) &&
5e64fa9c441ff (Jani Nikula                 2016-05-19 20:32:48 +0300 1014) 	    $args{'parameterdescs'}{$parameter_name} ne $undescribed) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1015) 	    output_highlight_rst($args{'parameterdescs'}{$parameter_name});
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1016) 	} else {
d4b08e0cd2d74 (Jani Nikula                 2016-05-28 00:48:17 +0300 1017) 	    print "  *undescribed*\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1018) 	}
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1019) 	print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1020)     }
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1021) 
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1022)     $lineprefix = $oldprefix;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1023)     output_section_rst(@_);
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1024) }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1025) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1026) sub output_section_rst(%) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1027)     my %args = %{$_[0]};
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1028)     my $section;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1029)     my $oldprefix = $lineprefix;
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1030)     $lineprefix = "";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1031) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1032)     foreach $section (@{$args{'sectionlist'}}) {
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1033) 	print "**$section**\n\n";
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200 1034)         print_lineno($section_start_lines{$section});
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1035) 	output_highlight_rst($args{'sections'}{$section});
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1036) 	print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1037)     }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1038)     print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1039)     $lineprefix = $oldprefix;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1040) }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1041) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1042) sub output_enum_rst(%) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1043)     my %args = %{$_[0]};
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1044)     my ($parameter);
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1045)     my $oldprefix = $lineprefix;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1046)     my $count;
6285097654725 (Jani Nikula                 2016-05-12 16:15:38 +0300 1047) 
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1048)     if ($sphinx_major < 3) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1049) 	my $name = "enum " . $args{'enum'};
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1050) 	print "\n\n.. c:type:: " . $name . "\n\n";
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1051)     } else {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1052) 	my $name = $args{'enum'};
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1053) 	print "\n\n.. c:enum:: " . $name . "\n\n";
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1054)     }
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200 1055)     print_lineno($declaration_start_line);
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1056)     $lineprefix = "   ";
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1057)     output_highlight_rst($args{'purpose'});
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1058)     print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1059) 
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1060)     print "**Constants**\n\n";
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1061)     $lineprefix = "  ";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1062)     foreach $parameter (@{$args{'parameterlist'}}) {
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1063) 	print "``$parameter``\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1064) 	if ($args{'parameterdescs'}{$parameter} ne $undescribed) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1065) 	    output_highlight_rst($args{'parameterdescs'}{$parameter});
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1066) 	} else {
d4b08e0cd2d74 (Jani Nikula                 2016-05-28 00:48:17 +0300 1067) 	    print "  *undescribed*\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1068) 	}
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1069) 	print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1070)     }
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1071) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1072)     $lineprefix = $oldprefix;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1073)     output_section_rst(@_);
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1074) }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1075) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1076) sub output_typedef_rst(%) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1077)     my %args = %{$_[0]};
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1078)     my ($parameter);
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1079)     my $oldprefix = $lineprefix;
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1080)     my $name;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1081) 
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1082)     if ($sphinx_major < 3) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1083) 	$name = "typedef " . $args{'typedef'};
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1084)     } else {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1085) 	$name = $args{'typedef'};
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1086)     }
6285097654725 (Jani Nikula                 2016-05-12 16:15:38 +0300 1087)     print "\n\n.. c:type:: " . $name . "\n\n";
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200 1088)     print_lineno($declaration_start_line);
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1089)     $lineprefix = "   ";
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1090)     output_highlight_rst($args{'purpose'});
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1091)     print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1092) 
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1093)     $lineprefix = $oldprefix;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1094)     output_section_rst(@_);
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1095) }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1096) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1097) sub output_struct_rst(%) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1098)     my %args = %{$_[0]};
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1099)     my ($parameter);
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1100)     my $oldprefix = $lineprefix;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1101) 
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1102)     if ($sphinx_major < 3) {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1103) 	my $name = $args{'type'} . " " . $args{'struct'};
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1104) 	print "\n\n.. c:type:: " . $name . "\n\n";
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1105)     } else {
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1106) 	my $name = $args{'struct'};
72b97d0b91187 (Mauro Carvalho Chehab       2020-10-27 10:51:05 +0100 1107) 	if ($args{'type'} eq 'union') {
72b97d0b91187 (Mauro Carvalho Chehab       2020-10-27 10:51:05 +0100 1108) 	    print "\n\n.. c:union:: " . $name . "\n\n";
72b97d0b91187 (Mauro Carvalho Chehab       2020-10-27 10:51:05 +0100 1109) 	} else {
72b97d0b91187 (Mauro Carvalho Chehab       2020-10-27 10:51:05 +0100 1110) 	    print "\n\n.. c:struct:: " . $name . "\n\n";
72b97d0b91187 (Mauro Carvalho Chehab       2020-10-27 10:51:05 +0100 1111) 	}
efa44475b8f5c (Mauro Carvalho Chehab       2020-09-24 15:30:37 +0200 1112)     }
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200 1113)     print_lineno($declaration_start_line);
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1114)     $lineprefix = "   ";
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1115)     output_highlight_rst($args{'purpose'});
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1116)     print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1117) 
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1118)     print "**Definition**\n\n";
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1119)     print "::\n\n";
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1120)     my $declaration = $args{'definition'};
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1121)     $declaration =~ s/\t/  /g;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1122)     print "  " . $args{'type'} . " " . $args{'struct'} . " {\n$declaration  };\n\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1123) 
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1124)     print "**Members**\n\n";
ecbcfba126e85 (Jani Nikula                 2016-05-26 18:30:27 +0300 1125)     $lineprefix = "  ";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1126)     foreach $parameter (@{$args{'parameterlist'}}) {
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1127) 	($parameter =~ /^#/) && next;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1128) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1129) 	my $parameter_name = $parameter;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1130) 	$parameter_name =~ s/\[.*//;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1131) 
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1132) 	($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1133) 	$type = $args{'parametertypes'}{$parameter};
0b0f5f29b282b (Daniel Vetter               2016-06-03 22:21:34 +0200 1134)         print_lineno($parameterdesc_start_lines{$parameter_name});
6d232c80158ae (Mauro Carvalho Chehab       2016-08-22 22:02:57 -0300 1135) 	print "``" . $parameter . "``\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1136) 	output_highlight_rst($args{'parameterdescs'}{$parameter_name});
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1137) 	print "\n";
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1138)     }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1139)     print "\n";
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1140) 
c099ff6989baf (Jani Nikula                 2016-05-26 17:18:17 +0300 1141)     $lineprefix = $oldprefix;
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1142)     output_section_rst(@_);
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1143) }
c0d1b6ee780ab (Jonathan Corbet             2016-05-12 16:15:37 +0300 1144) 
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1145) ## none mode output functions
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1146) 
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1147) sub output_function_none(%) {
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1148) }
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1149) 
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1150) sub output_enum_none(%) {
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1151) }
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1152) 
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1153) sub output_typedef_none(%) {
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1154) }
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1155) 
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1156) sub output_struct_none(%) {
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1157) }
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1158) 
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1159) sub output_blockhead_none(%) {
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1160) }
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 1161) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1162) ##
272057447f646 (Randy Dunlap                2006-10-11 01:22:12 -0700 1163) # generic output function for all types (function, struct/union, typedef, enum);
272057447f646 (Randy Dunlap                2006-10-11 01:22:12 -0700 1164) # calls the generated, variable output_ function name based on
272057447f646 (Randy Dunlap                2006-10-11 01:22:12 -0700 1165) # functype and output_mode
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1166) sub output_declaration {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1167)     no strict 'refs';
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1168)     my $name = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1169)     my $functype = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1170)     my $func = "output_${functype}_$output_mode";
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200 1171) 
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200 1172)     return if (defined($nosymbol_table{$name}));
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200 1173) 
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300 1174)     if (($output_selection == OUTPUT_ALL) ||
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300 1175) 	(($output_selection == OUTPUT_INCLUDE ||
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300 1176) 	  $output_selection == OUTPUT_EXPORTED) &&
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300 1177) 	 defined($function_table{$name})) ||
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200 1178) 	($output_selection == OUTPUT_INTERNAL &&
b6c3f456cfed5 (Jani Nikula                 2016-05-29 22:19:35 +0300 1179) 	 !($functype eq "function" && defined($function_table{$name}))))
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1180)     {
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1181) 	&$func(@_);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1182) 	$section_counter++;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1183)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1184) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1185) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1186) ##
272057447f646 (Randy Dunlap                2006-10-11 01:22:12 -0700 1187) # generic output function - calls the right one based on current output mode.
b112e0f73fe8e (Johannes Berg               2007-10-24 15:08:48 -0700 1188) sub output_blockhead {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1189)     no strict 'refs';
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700 1190)     my $func = "output_blockhead_" . $output_mode;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1191)     &$func(@_);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1192)     $section_counter++;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1193) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1194) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1195) ##
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800 1196) # takes a declaration (struct, union, enum, typedef) and
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1197) # invokes the right handler. NOT called for functions.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1198) sub dump_declaration($$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1199)     no strict 'refs';
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1200)     my ($prototype, $file) = @_;
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700 1201)     my $func = "dump_" . $decl_type;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1202)     &$func(@_);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1203) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1204) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1205) sub dump_union($$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1206)     dump_struct(@_);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1207) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1208) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1209) sub dump_struct($$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1210)     my $x = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1211)     my $file = shift;
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1212)     my $decl_type;
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1213)     my $members;
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1214)     my $type = qr{struct|union};
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1215)     # For capturing struct/union definition body, i.e. "{members*}qualifiers*"
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1216)     my $qualifiers = qr{$attribute|__packed|__aligned|____cacheline_aligned_in_smp|____cacheline_aligned};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1217)     my $definition_body = qr{\{(.*)\}\s*$qualifiers*};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1218)     my $struct_members = qr{($type)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*)\;};
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1219) 
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1220)     if ($x =~ /($type)\s+(\w+)\s*$definition_body/) {
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1221) 	$decl_type = $1;
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1222) 	$declaration_name = $2;
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1223) 	$members = $3;
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1224)     } elsif ($x =~ /typedef\s+($type)\s*$definition_body\s*(\w+)\s*;/) {
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1225) 	$decl_type = $1;
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1226) 	$declaration_name = $3;
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1227) 	$members = $2;
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1228)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1229) 
a746fe32cd362 (Aditya Srivastava           2021-02-25 20:20:33 +0530 1230)     if ($members) {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1231) 	if ($identifier ne $declaration_name) {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1232) 	    print STDERR "${file}:$.: warning: expecting prototype for $decl_type $identifier. Prototype was for $decl_type $declaration_name instead\n";
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1233) 	    return;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1234) 	}
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1235) 
aeec46b97a797 (Martin Waitz                2005-11-13 16:08:13 -0800 1236) 	# ignore members marked private:
0d8c39e6c6dd9 (Mauro Carvalho Chehab       2015-10-05 09:03:48 -0300 1237) 	$members =~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gosi;
0d8c39e6c6dd9 (Mauro Carvalho Chehab       2015-10-05 09:03:48 -0300 1238) 	$members =~ s/\/\*\s*private:.*//gosi;
aeec46b97a797 (Martin Waitz                2005-11-13 16:08:13 -0800 1239) 	# strip comments:
aeec46b97a797 (Martin Waitz                2005-11-13 16:08:13 -0800 1240) 	$members =~ s/\/\*.*?\*\///gos;
ef5da59f12602 (Randy Dunlap                2010-03-23 13:35:14 -0700 1241) 	# strip attributes
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1242) 	$members =~ s/\s*$attribute/ /gi;
2b5f78e5e942d (André Almeida               2019-09-17 16:41:45 -0300 1243) 	$members =~ s/\s*__aligned\s*\([^;]*\)/ /gos;
2b5f78e5e942d (André Almeida               2019-09-17 16:41:45 -0300 1244) 	$members =~ s/\s*__packed\s*/ /gos;
2b5f78e5e942d (André Almeida               2019-09-17 16:41:45 -0300 1245) 	$members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos;
f861537d5f856 (André Almeida               2019-09-17 16:41:46 -0300 1246) 	$members =~ s/\s*____cacheline_aligned_in_smp/ /gos;
a070991fe9d1b (Jonathan Cameron            2020-09-10 19:54:15 +0100 1247) 	$members =~ s/\s*____cacheline_aligned/ /gos;
3556108eb40a3 (Mauro Carvalho Chehab       2020-06-23 09:09:00 +0200 1248) 
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1249) 	my $args = qr{([^,)]+)};
b22b5a9ef5309 (Conchúr Navid               2015-11-08 10:52:00 +0100 1250) 	# replace DECLARE_BITMAP
3556108eb40a3 (Mauro Carvalho Chehab       2020-06-23 09:09:00 +0200 1251) 	$members =~ s/__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)/DECLARE_BITMAP($1, __ETHTOOL_LINK_MODE_MASK_NBITS)/gos;
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1252) 	$members =~ s/DECLARE_BITMAP\s*\($args,\s*$args\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
1cb566ba5634d (Jakub Kicinski              2017-06-30 19:09:59 -0700 1253) 	# replace DECLARE_HASHTABLE
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1254) 	$members =~ s/DECLARE_HASHTABLE\s*\($args,\s*$args\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
45005b27c1918 (Mauro Carvalho Chehab       2017-12-08 09:05:12 -0500 1255) 	# replace DECLARE_KFIFO
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1256) 	$members =~ s/DECLARE_KFIFO\s*\($args,\s*$args,\s*$args\)/$2 \*$1/gos;
45005b27c1918 (Mauro Carvalho Chehab       2017-12-08 09:05:12 -0500 1257) 	# replace DECLARE_KFIFO_PTR
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1258) 	$members =~ s/DECLARE_KFIFO_PTR\s*\($args,\s*$args\)/$2 \*$1/gos;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1259) 	my $declaration = $members;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1260) 
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1261) 	# Split nested struct/union elements as newer ones
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1262) 	while ($members =~ m/$struct_members/) {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1263) 		my $newmember;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1264) 		my $maintype = $1;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1265) 		my $ids = $4;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1266) 		my $content = $3;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1267) 		foreach my $id(split /,/, $ids) {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1268) 			$newmember .= "$maintype $id; ";
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1269) 
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1270) 			$id =~ s/[:\[].*//;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1271) 			$id =~ s/^\s*\**(\S+)\s*/$1/;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1272) 			foreach my $arg (split /;/, $content) {
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1273) 				next if ($arg =~ m/^\s*$/);
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1274) 				if ($arg =~ m/^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)/) {
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1275) 					# pointer-to-function
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1276) 					my $type = $1;
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1277) 					my $name = $2;
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1278) 					my $extra = $3;
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1279) 					next if (!$name);
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1280) 					if ($id =~ m/^\s*$/) {
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1281) 						# anonymous struct/union
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1282) 						$newmember .= "$type$name$extra; ";
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1283) 					} else {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1284) 						$newmember .= "$type$id.$name$extra; ";
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1285) 					}
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1286) 				} else {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1287) 					my $type;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1288) 					my $names;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1289) 					$arg =~ s/^\s+//;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1290) 					$arg =~ s/\s+$//;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1291) 					# Handle bitmaps
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1292) 					$arg =~ s/:\s*\d+\s*//g;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1293) 					# Handle arrays
d404d57955a6f (Mauro Carvalho Chehab       2018-03-29 10:58:59 -0400 1294) 					$arg =~ s/\[.*\]//g;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1295) 					# The type may have multiple words,
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1296) 					# and multiple IDs can be defined, like:
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1297) 					#	const struct foo, *bar, foobar
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1298) 					# So, we remove spaces when parsing the
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1299) 					# names, in order to match just names
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1300) 					# and commas for the names
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1301) 					$arg =~ s/\s*,\s*/,/g;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1302) 					if ($arg =~ m/(.*)\s+([\S+,]+)/) {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1303) 						$type = $1;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1304) 						$names = $2;
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1305) 					} else {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1306) 						$newmember .= "$arg; ";
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1307) 						next;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1308) 					}
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1309) 					foreach my $name (split /,/, $names) {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1310) 						$name =~ s/^\s*\**(\S+)\s*/$1/;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1311) 						next if (($name =~ m/^\s*$/));
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1312) 						if ($id =~ m/^\s*$/) {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1313) 							# anonymous struct/union
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1314) 							$newmember .= "$type $name; ";
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1315) 						} else {
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1316) 							$newmember .= "$type $id.$name; ";
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1317) 						}
7c0d7e87a16fe (Mauro Carvalho Chehab       2017-12-18 10:30:16 -0200 1318) 					}
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1319) 				}
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1320) 			}
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1321) 		}
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1322) 		$members =~ s/$struct_members/$newmember/;
84ce5b987783d (Mauro Carvalho Chehab       2017-12-18 10:30:17 -0200 1323) 	}
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1324) 
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1325) 	# Ignore other nested elements, like enums
673bb2dfc3648 (Ben Hutchings               2018-08-05 17:41:09 +0100 1326) 	$members =~ s/(\{[^\{\}]*\})//g;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1327) 
151c468b44a89 (Mauro Carvalho Chehab       2017-12-18 10:30:15 -0200 1328) 	create_parameterlist($members, ';', $file, $declaration_name);
1081de2d2f917 (Mauro Carvalho Chehab       2017-12-18 10:30:14 -0200 1329) 	check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1330) 
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1331) 	# Adjust declaration for better display
673bb2dfc3648 (Ben Hutchings               2018-08-05 17:41:09 +0100 1332) 	$declaration =~ s/([\{;])/$1\n/g;
673bb2dfc3648 (Ben Hutchings               2018-08-05 17:41:09 +0100 1333) 	$declaration =~ s/\}\s+;/};/g;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1334) 	# Better handle inlined enums
673bb2dfc3648 (Ben Hutchings               2018-08-05 17:41:09 +0100 1335) 	do {} while ($declaration =~ s/(enum\s+\{[^\}]+),([^\n])/$1,\n$2/);
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1336) 
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1337) 	my @def_args = split /\n/, $declaration;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1338) 	my $level = 1;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1339) 	$declaration = "";
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1340) 	foreach my $clause (@def_args) {
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1341) 		$clause =~ s/^\s+//;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1342) 		$clause =~ s/\s+$//;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1343) 		$clause =~ s/\s+/ /;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1344) 		next if (!$clause);
673bb2dfc3648 (Ben Hutchings               2018-08-05 17:41:09 +0100 1345) 		$level-- if ($clause =~ m/(\})/ && $level > 1);
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1346) 		if (!($clause =~ m/^\s*#/)) {
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1347) 			$declaration .= "\t" x $level;
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1348) 		}
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1349) 		$declaration .= "\t" . $clause . "\n";
673bb2dfc3648 (Ben Hutchings               2018-08-05 17:41:09 +0100 1350) 		$level++ if ($clause =~ m/(\{)/ && !($clause =~m/\}/));
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1351) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1352) 	output_declaration($declaration_name,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1353) 			   'struct',
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1354) 			   {'struct' => $declaration_name,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1355) 			    'module' => $modulename,
8ad7216316526 (Mauro Carvalho Chehab       2017-12-18 10:30:13 -0200 1356) 			    'definition' => $declaration,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1357) 			    'parameterlist' => \@parameterlist,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1358) 			    'parameterdescs' => \%parameterdescs,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1359) 			    'parametertypes' => \%parametertypes,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1360) 			    'sectionlist' => \@sectionlist,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1361) 			    'sections' => \%sections,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1362) 			    'purpose' => $declaration_purpose,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1363) 			    'type' => $decl_type
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1364) 			   });
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1365)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1366)     else {
d40e1e6532efb (Bart Van Assche             2015-09-04 15:43:21 -0700 1367) 	print STDERR "${file}:$.: error: Cannot parse struct or union!\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1368) 	++$errors;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1369)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1370) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1371) 
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1372) 
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1373) sub show_warnings($$) {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1374) 	my $functype = shift;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1375) 	my $name = shift;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1376) 
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200 1377) 	return 0 if (defined($nosymbol_table{$name}));
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200 1378) 
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1379) 	return 1 if ($output_selection == OUTPUT_ALL);
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1380) 
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1381) 	if ($output_selection == OUTPUT_EXPORTED) {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1382) 		if (defined($function_table{$name})) {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1383) 			return 1;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1384) 		} else {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1385) 			return 0;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1386) 		}
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1387) 	}
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1388)         if ($output_selection == OUTPUT_INTERNAL) {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1389) 		if (!($functype eq "function" && defined($function_table{$name}))) {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1390) 			return 1;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1391) 		} else {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1392) 			return 0;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1393) 		}
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1394) 	}
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1395) 	if ($output_selection == OUTPUT_INCLUDE) {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1396) 		if (defined($function_table{$name})) {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1397) 			return 1;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1398) 		} else {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1399) 			return 0;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1400) 		}
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1401) 	}
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1402) 	die("Please add the new output type at show_warnings()");
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1403) }
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1404) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1405) sub dump_enum($$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1406)     my $x = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1407)     my $file = shift;
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1408)     my $members;
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1409) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1410) 
aeec46b97a797 (Martin Waitz                2005-11-13 16:08:13 -0800 1411)     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
4468e21eed2dd (Conchúr Navid               2015-11-08 10:48:05 +0100 1412)     # strip #define macros inside enums
4468e21eed2dd (Conchúr Navid               2015-11-08 10:48:05 +0100 1413)     $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
b6d676db35ca6 (Randy Dunlap                2010-08-10 18:02:50 -0700 1414) 
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1415)     if ($x =~ /typedef\s+enum\s*\{(.*)\}\s*(\w*)\s*;/) {
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1416) 	$declaration_name = $2;
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1417) 	$members = $1;
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1418)     } elsif ($x =~ /enum\s+(\w*)\s*\{(.*)\}/) {
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1419) 	$declaration_name = $1;
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1420) 	$members = $2;
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1421)     }
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1422) 
ae5b17e464146 (Andy Shevchenko             2020-11-02 19:06:37 +0200 1423)     if ($members) {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1424) 	if ($identifier ne $declaration_name) {
0b54c2e34be79 (Mauro Carvalho Chehab       2021-03-03 09:42:14 +0100 1425) 	    if ($identifier eq "") {
0b54c2e34be79 (Mauro Carvalho Chehab       2021-03-03 09:42:14 +0100 1426) 		print STDERR "${file}:$.: warning: wrong kernel-doc identifier on line:\n";
0b54c2e34be79 (Mauro Carvalho Chehab       2021-03-03 09:42:14 +0100 1427) 	    } else {
0b54c2e34be79 (Mauro Carvalho Chehab       2021-03-03 09:42:14 +0100 1428) 		print STDERR "${file}:$.: warning: expecting prototype for enum $identifier. Prototype was for enum $declaration_name instead\n";
0b54c2e34be79 (Mauro Carvalho Chehab       2021-03-03 09:42:14 +0100 1429) 	    }
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1430) 	    return;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1431) 	}
0b54c2e34be79 (Mauro Carvalho Chehab       2021-03-03 09:42:14 +0100 1432) 	$declaration_name = "(anonymous)" if ($declaration_name eq "");
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1433) 
5cb5c31cdf246 (Johannes Berg               2017-09-19 13:08:13 +0200 1434) 	my %_members;
5cb5c31cdf246 (Johannes Berg               2017-09-19 13:08:13 +0200 1435) 
463a0fdc3e800 (Markus Heiser               2017-06-16 21:27:48 +0200 1436) 	$members =~ s/\s+$//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1437) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1438) 	foreach my $arg (split ',', $members) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1439) 	    $arg =~ s/^\s*(\w+).*/$1/;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1440) 	    push @parameterlist, $arg;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1441) 	    if (!$parameterdescs{$arg}) {
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1442) 		$parameterdescs{$arg} = $undescribed;
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1443) 	        if (show_warnings("enum", $declaration_name)) {
2defb27292176 (Mauro Carvalho Chehab       2017-12-18 10:30:18 -0200 1444) 			print STDERR "${file}:$.: warning: Enum value '$arg' not described in enum '$declaration_name'\n";
2defb27292176 (Mauro Carvalho Chehab       2017-12-18 10:30:18 -0200 1445) 		}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1446) 	    }
5cb5c31cdf246 (Johannes Berg               2017-09-19 13:08:13 +0200 1447) 	    $_members{$arg} = 1;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1448) 	}
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800 1449) 
5cb5c31cdf246 (Johannes Berg               2017-09-19 13:08:13 +0200 1450) 	while (my ($k, $v) = each %parameterdescs) {
5cb5c31cdf246 (Johannes Berg               2017-09-19 13:08:13 +0200 1451) 	    if (!exists($_members{$k})) {
85afe608f5f3c (Mauro Carvalho Chehab       2017-12-30 22:32:55 -0200 1452) 	        if (show_warnings("enum", $declaration_name)) {
2defb27292176 (Mauro Carvalho Chehab       2017-12-18 10:30:18 -0200 1453) 		     print STDERR "${file}:$.: warning: Excess enum value '$k' description in '$declaration_name'\n";
2defb27292176 (Mauro Carvalho Chehab       2017-12-18 10:30:18 -0200 1454) 		}
5cb5c31cdf246 (Johannes Berg               2017-09-19 13:08:13 +0200 1455) 	    }
5cb5c31cdf246 (Johannes Berg               2017-09-19 13:08:13 +0200 1456)         }
5cb5c31cdf246 (Johannes Berg               2017-09-19 13:08:13 +0200 1457) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1458) 	output_declaration($declaration_name,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1459) 			   'enum',
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1460) 			   {'enum' => $declaration_name,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1461) 			    'module' => $modulename,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1462) 			    'parameterlist' => \@parameterlist,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1463) 			    'parameterdescs' => \%parameterdescs,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1464) 			    'sectionlist' => \@sectionlist,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1465) 			    'sections' => \%sections,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1466) 			    'purpose' => $declaration_purpose
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1467) 			   });
d38c8cfb05718 (Mauro Carvalho Chehab       2020-10-01 08:23:52 +0200 1468)     } else {
d40e1e6532efb (Bart Van Assche             2015-09-04 15:43:21 -0700 1469) 	print STDERR "${file}:$.: error: Cannot parse enum!\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1470) 	++$errors;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1471)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1472) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1473) 
7d2c6b1edf790 (Mauro Carvalho Chehab       2020-12-02 09:17:32 +0100 1474) my $typedef_type = qr { ((?:\s+[\w\*]+\b){1,8})\s* }x;
7efc6c4295f54 (Mauro Carvalho Chehab       2020-10-27 11:20:37 +0100 1475) my $typedef_ident = qr { \*?\s*(\w\S+)\s* }x;
7efc6c4295f54 (Mauro Carvalho Chehab       2020-10-27 11:20:37 +0100 1476) my $typedef_args = qr { \s*\((.*)\); }x;
7efc6c4295f54 (Mauro Carvalho Chehab       2020-10-27 11:20:37 +0100 1477) 
7efc6c4295f54 (Mauro Carvalho Chehab       2020-10-27 11:20:37 +0100 1478) my $typedef1 = qr { typedef$typedef_type\($typedef_ident\)$typedef_args }x;
7efc6c4295f54 (Mauro Carvalho Chehab       2020-10-27 11:20:37 +0100 1479) my $typedef2 = qr { typedef$typedef_type$typedef_ident$typedef_args }x;
7efc6c4295f54 (Mauro Carvalho Chehab       2020-10-27 11:20:37 +0100 1480) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1481) sub dump_typedef($$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1482)     my $x = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1483)     my $file = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1484) 
aeec46b97a797 (Martin Waitz                2005-11-13 16:08:13 -0800 1485)     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1486) 
7efc6c4295f54 (Mauro Carvalho Chehab       2020-10-27 11:20:37 +0100 1487)     # Parse function typedef prototypes
7efc6c4295f54 (Mauro Carvalho Chehab       2020-10-27 11:20:37 +0100 1488)     if ($x =~ $typedef1 || $x =~ $typedef2) {
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1489) 	$return_type = $1;
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1490) 	$declaration_name = $2;
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1491) 	my $args = $3;
6b80975c6308b (Mauro Carvalho Chehab       2020-10-27 11:20:36 +0100 1492) 	$return_type =~ s/^\s+//;
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1493) 
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1494) 	if ($identifier ne $declaration_name) {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1495) 	    print STDERR "${file}:$.: warning: expecting prototype for typedef $identifier. Prototype was for typedef $declaration_name instead\n";
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1496) 	    return;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1497) 	}
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1498) 
151c468b44a89 (Mauro Carvalho Chehab       2017-12-18 10:30:15 -0200 1499) 	create_parameterlist($args, ',', $file, $declaration_name);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1500) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1501) 	output_declaration($declaration_name,
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1502) 			   'function',
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1503) 			   {'function' => $declaration_name,
82801d065b491 (Mauro Carvalho Chehab       2016-08-30 20:20:58 -0300 1504) 			    'typedef' => 1,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1505) 			    'module' => $modulename,
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1506) 			    'functiontype' => $return_type,
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1507) 			    'parameterlist' => \@parameterlist,
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1508) 			    'parameterdescs' => \%parameterdescs,
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1509) 			    'parametertypes' => \%parametertypes,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1510) 			    'sectionlist' => \@sectionlist,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1511) 			    'sections' => \%sections,
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1512) 			    'purpose' => $declaration_purpose
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1513) 			   });
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1514) 	return;
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1515)     }
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1516) 
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1517)     while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1518) 	$x =~ s/\(*.\)\s*;$/;/;
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1519) 	$x =~ s/\[*.\]\s*;$/;/;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1520)     }
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1521) 
837664528e173 (Mauro Carvalho Chehab       2015-10-08 16:14:45 -0300 1522)     if ($x =~ /typedef.*\s+(\w+)\s*;/) {
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1523) 	$declaration_name = $1;
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1524) 
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1525) 	if ($identifier ne $declaration_name) {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1526) 	    print STDERR "${file}:$.: warning: expecting prototype for typedef $identifier. Prototype was for typedef $declaration_name instead\n";
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1527) 	    return;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1528) 	}
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1529) 
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1530) 	output_declaration($declaration_name,
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1531) 			   'typedef',
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1532) 			   {'typedef' => $declaration_name,
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1533) 			    'module' => $modulename,
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1534) 			    'sectionlist' => \@sectionlist,
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1535) 			    'sections' => \%sections,
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1536) 			    'purpose' => $declaration_purpose
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1537) 			   });
3a80a766328fe (Mauro Carvalho Chehab       2015-10-08 15:21:44 -0300 1538)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1539)     else {
d40e1e6532efb (Bart Van Assche             2015-09-04 15:43:21 -0700 1540) 	print STDERR "${file}:$.: error: Cannot parse typedef!\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1541) 	++$errors;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1542)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1543) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1544) 
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1545) sub save_struct_actual($) {
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1546)     my $actual = shift;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1547) 
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1548)     # strip all spaces from the actual param so that it looks like one string item
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1549)     $actual =~ s/\s*//g;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1550)     $struct_actual = $struct_actual . $actual . " ";
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1551) }
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1552) 
151c468b44a89 (Mauro Carvalho Chehab       2017-12-18 10:30:15 -0200 1553) sub create_parameterlist($$$$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1554)     my $args = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1555)     my $splitter = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1556)     my $file = shift;
151c468b44a89 (Mauro Carvalho Chehab       2017-12-18 10:30:15 -0200 1557)     my $declaration_name = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1558)     my $type;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1559)     my $param;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1560) 
a6d3fe77dace2 (Martin Waitz                2006-01-09 20:53:55 -0800 1561)     # temporarily replace commas inside function pointer definition
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1562)     my $arg_expr = qr{\([^\),]+};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1563)     while ($args =~ /$arg_expr,/) {
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1564) 	$args =~ s/($arg_expr),/$1#/g;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1565)     }
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800 1566) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1567)     foreach my $arg (split($splitter, $args)) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1568) 	# strip comments
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1569) 	$arg =~ s/\/\*.*\*\///;
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1570) 	# strip leading/trailing spaces
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1571) 	$arg =~ s/^\s*//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1572) 	$arg =~ s/\s*$//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1573) 	$arg =~ s/\s+/ /;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1574) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1575) 	if ($arg =~ /^#/) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1576) 	    # Treat preprocessor directive as a typeless variable just to fill
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1577) 	    # corresponding data structures "correctly". Catch it later in
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1578) 	    # output_* subs.
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1579) 	    push_parameter($arg, "", "", $file);
00d6296145c6b (Richard Kennedy             2008-02-23 15:24:01 -0800 1580) 	} elsif ($arg =~ m/\(.+\)\s*\(/) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1581) 	    # pointer-to-function
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1582) 	    $arg =~ tr/#/,/;
336ced2de62d2 (Aditya Srivastava           2021-02-17 20:26:25 +0530 1583) 	    $arg =~ m/[^\(]+\(\*?\s*([\w\[\]\.]*)\s*\)/;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1584) 	    $param = $1;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1585) 	    $type = $arg;
00d6296145c6b (Richard Kennedy             2008-02-23 15:24:01 -0800 1586) 	    $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1587) 	    save_struct_actual($param);
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1588) 	    push_parameter($param, $type, $arg, $file, $declaration_name);
aeec46b97a797 (Martin Waitz                2005-11-13 16:08:13 -0800 1589) 	} elsif ($arg) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1590) 	    $arg =~ s/\s*:\s*/:/g;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1591) 	    $arg =~ s/\s*\[/\[/g;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1592) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1593) 	    my @args = split('\s*,\s*', $arg);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1594) 	    if ($args[0] =~ m/\*/) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1595) 		$args[0] =~ s/(\*+)\s*/ $1/;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1596) 	    }
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1597) 
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1598) 	    my @first_arg;
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1599) 	    if ($args[0] =~ /^(.*\s+)(.*?\[.*\].*)$/) {
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1600) 		    shift @args;
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1601) 		    push(@first_arg, split('\s+', $1));
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1602) 		    push(@first_arg, $2);
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1603) 	    } else {
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1604) 		    @first_arg = split('\s+', shift @args);
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1605) 	    }
884f2810b15b6 (Borislav Petkov             2007-05-08 00:29:05 -0700 1606) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1607) 	    unshift(@args, pop @first_arg);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1608) 	    $type = join " ", @first_arg;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1609) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1610) 	    foreach $param (@args) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1611) 		if ($param =~ m/^(\*+)\s*(.*)/) {
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1612) 		    save_struct_actual($2);
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1613) 
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1614) 		    push_parameter($2, "$type $1", $arg, $file, $declaration_name);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1615) 		}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1616) 		elsif ($param =~ m/(.*?):(\d+)/) {
7b97887eab6c3 (Randy Dunlap                2008-05-16 15:45:52 -0700 1617) 		    if ($type ne "") { # skip unnamed bit-fields
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1618) 			save_struct_actual($1);
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1619) 			push_parameter($1, "$type:$2", $arg, $file, $declaration_name)
7b97887eab6c3 (Randy Dunlap                2008-05-16 15:45:52 -0700 1620) 		    }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1621) 		}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1622) 		else {
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1623) 		    save_struct_actual($param);
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1624) 		    push_parameter($param, $type, $arg, $file, $declaration_name);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1625) 		}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1626) 	    }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1627) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1628)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1629) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1630) 
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1631) sub push_parameter($$$$$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1632) 	my $param = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1633) 	my $type = shift;
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1634) 	my $org_arg = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1635) 	my $file = shift;
151c468b44a89 (Mauro Carvalho Chehab       2017-12-18 10:30:15 -0200 1636) 	my $declaration_name = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1637) 
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700 1638) 	if (($anon_struct_union == 1) && ($type eq "") &&
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700 1639) 	    ($param eq "}")) {
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700 1640) 		return;		# ignore the ending }; from anon. struct/union
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700 1641) 	}
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700 1642) 
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700 1643) 	$anon_struct_union = 0;
f9b5c5304ce21 (Mauro Carvalho Chehab       2017-03-30 17:11:29 -0300 1644) 	$param =~ s/[\[\)].*//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1645) 
a6d3fe77dace2 (Martin Waitz                2006-01-09 20:53:55 -0800 1646) 	if ($type eq "" && $param =~ /\.\.\.$/)
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1647) 	{
c950a1739eaef (Silvio Fricke               2016-10-28 10:14:08 +0200 1648) 	    if (!$param =~ /\w\.\.\.$/) {
c950a1739eaef (Silvio Fricke               2016-10-28 10:14:08 +0200 1649) 	      # handles unnamed variable parameters
c950a1739eaef (Silvio Fricke               2016-10-28 10:14:08 +0200 1650) 	      $param = "...";
c950a1739eaef (Silvio Fricke               2016-10-28 10:14:08 +0200 1651) 	    }
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 1652) 	    elsif ($param =~ /\w\.\.\.$/) {
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 1653) 	      # for named variable parameters of the form `x...`, remove the dots
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 1654) 	      $param =~ s/\.\.\.$//;
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 1655) 	    }
ced69090c573f (Randy Dunlap                2008-12-01 13:14:03 -0800 1656) 	    if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") {
ced69090c573f (Randy Dunlap                2008-12-01 13:14:03 -0800 1657) 		$parameterdescs{$param} = "variable arguments";
ced69090c573f (Randy Dunlap                2008-12-01 13:14:03 -0800 1658) 	    }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1659) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1660) 	elsif ($type eq "" && ($param eq "" or $param eq "void"))
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1661) 	{
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1662) 	    $param="void";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1663) 	    $parameterdescs{void} = "no arguments";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1664) 	}
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1665) 	elsif ($type eq "" && ($param eq "struct" or $param eq "union"))
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1666) 	# handle unnamed (anonymous) union or struct:
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1667) 	{
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1668) 		$type = $param;
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700 1669) 		$param = "{unnamed_" . $param . "}";
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1670) 		$parameterdescs{$param} = "anonymous\n";
5f8c7c98ae388 (Randy Dunlap                2007-07-19 01:48:24 -0700 1671) 		$anon_struct_union = 1;
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1672) 	}
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1673) 
a6d3fe77dace2 (Martin Waitz                2006-01-09 20:53:55 -0800 1674) 	# warn if parameter has no description
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1675) 	# (but ignore ones starting with # as these are not parameters
134fe01bfafa7 (Randy Dunlap                2006-12-22 01:10:50 -0800 1676) 	# but inline preprocessor statements);
151c468b44a89 (Mauro Carvalho Chehab       2017-12-18 10:30:15 -0200 1677) 	# Note: It will also ignore void params and unnamed structs/unions
f9b5c5304ce21 (Mauro Carvalho Chehab       2017-03-30 17:11:29 -0300 1678) 	if (!defined $parameterdescs{$param} && $param !~ /^#/) {
151c468b44a89 (Mauro Carvalho Chehab       2017-12-18 10:30:15 -0200 1679) 		$parameterdescs{$param} = $undescribed;
a6d3fe77dace2 (Martin Waitz                2006-01-09 20:53:55 -0800 1680) 
be5cd20c9b491 (Jonathan Corbet             2019-01-11 12:31:39 -0700 1681) 	        if (show_warnings($type, $declaration_name) && $param !~ /\./) {
2defb27292176 (Mauro Carvalho Chehab       2017-12-18 10:30:18 -0200 1682) 			print STDERR
2defb27292176 (Mauro Carvalho Chehab       2017-12-18 10:30:18 -0200 1683) 			      "${file}:$.: warning: Function parameter or member '$param' not described in '$declaration_name'\n";
2defb27292176 (Mauro Carvalho Chehab       2017-12-18 10:30:18 -0200 1684) 			++$warnings;
2defb27292176 (Mauro Carvalho Chehab       2017-12-18 10:30:18 -0200 1685) 		}
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1686) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1687) 
25985edcedea6 (Lucas De Marchi             2011-03-30 22:57:33 -0300 1688) 	# strip spaces from $param so that it is one continuous string
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1689) 	# on @parameterlist;
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1690) 	# this fixes a problem where check_sections() cannot find
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1691) 	# a parameter like "addr[6 + 2]" because it actually appears
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1692) 	# as "addr[6", "+", "2]" on the parameter list;
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1693) 	# but it's better to maintain the param string unchanged for output,
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1694) 	# so just weaken the string compare in check_sections() to ignore
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1695) 	# "[blah" in a parameter string;
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1696) 	###$param =~ s/\s*//g;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1697) 	push @parameterlist, $param;
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1698) 	$org_arg =~ s/\s\s+/ /g;
ed8348e23abce (Mauro Carvalho Chehab       2020-09-30 12:24:43 +0200 1699) 	$parametertypes{$param} = $org_arg;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1700) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1701) 
1081de2d2f917 (Mauro Carvalho Chehab       2017-12-18 10:30:14 -0200 1702) sub check_sections($$$$$) {
1081de2d2f917 (Mauro Carvalho Chehab       2017-12-18 10:30:14 -0200 1703) 	my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck) = @_;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1704) 	my @sects = split ' ', $sectcheck;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1705) 	my @prms = split ' ', $prmscheck;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1706) 	my $err;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1707) 	my ($px, $sx);
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1708) 	my $prm_clean;		# strip trailing "[array size]" and/or beginning "*"
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1709) 
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1710) 	foreach $sx (0 .. $#sects) {
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1711) 		$err = 1;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1712) 		foreach $px (0 .. $#prms) {
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1713) 			$prm_clean = $prms[$px];
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1714) 			$prm_clean =~ s/\[.*\]//;
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1715) 			$prm_clean =~ s/$attribute//i;
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1716) 			# ignore array size in a parameter string;
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1717) 			# however, the original param string may contain
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1718) 			# spaces, e.g.:  addr[6 + 2]
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1719) 			# and this appears in @prms as "addr[6" since the
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1720) 			# parameter list is split at spaces;
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1721) 			# hence just ignore "[..." for the sections check;
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1722) 			$prm_clean =~ s/\[.*//;
e34e7dbb35474 (Randy Dunlap                2009-06-17 17:37:47 -0700 1723) 
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1724) 			##$prm_clean =~ s/^\**//;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1725) 			if ($prm_clean eq $sects[$sx]) {
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1726) 				$err = 0;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1727) 				last;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1728) 			}
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1729) 		}
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1730) 		if ($err) {
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1731) 			if ($decl_type eq "function") {
d40e1e6532efb (Bart Van Assche             2015-09-04 15:43:21 -0700 1732) 				print STDERR "${file}:$.: warning: " .
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1733) 					"Excess function parameter " .
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1734) 					"'$sects[$sx]' " .
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1735) 					"description in '$decl_name'\n";
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1736) 				++$warnings;
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1737) 			}
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1738) 		}
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1739) 	}
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1740) }
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1741) 
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1742) ##
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1743) # Checks the section describing the return value of a function.
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1744) sub check_return_section {
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1745)         my $file = shift;
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1746)         my $declaration_name = shift;
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1747)         my $return_type = shift;
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1748) 
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1749)         # Ignore an empty return type (It's a macro)
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1750)         # Ignore functions with a "void" return type. (But don't ignore "void *")
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1751)         if (($return_type eq "") || ($return_type =~ /void\s*\w*\s*$/)) {
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1752)                 return;
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1753)         }
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1754) 
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1755)         if (!defined($sections{$section_return}) ||
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1756)             $sections{$section_return} eq "") {
d40e1e6532efb (Bart Van Assche             2015-09-04 15:43:21 -0700 1757)                 print STDERR "${file}:$.: warning: " .
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1758)                         "No description found for return value of " .
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1759)                         "'$declaration_name'\n";
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1760)                 ++$warnings;
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1761)         }
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1762) }
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1763) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1764) ##
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1765) # takes a function prototype and the name of the current file being
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1766) # processed and spits out all the details stored in the global
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1767) # arrays/hashes.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1768) sub dump_function($$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1769)     my $prototype = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1770)     my $file = shift;
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1771)     my $noret = 0;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1772) 
5ef09c96d48b4 (Mauro Carvalho Chehab       2020-10-09 10:15:25 +0200 1773)     print_lineno($new_start_line);
5eb6b4b3e2161 (Mauro Carvalho Chehab       2020-09-09 16:10:33 +0200 1774) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1775)     $prototype =~ s/^static +//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1776)     $prototype =~ s/^extern +//;
4dc3b16ba18c0 (Pavel Pisa                  2005-05-01 08:59:25 -0700 1777)     $prototype =~ s/^asmlinkage +//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1778)     $prototype =~ s/^inline +//;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1779)     $prototype =~ s/^__inline__ +//;
32e794015aa69 (Randy Dunlap                2006-10-11 01:22:10 -0700 1780)     $prototype =~ s/^__inline +//;
32e794015aa69 (Randy Dunlap                2006-10-11 01:22:10 -0700 1781)     $prototype =~ s/^__always_inline +//;
32e794015aa69 (Randy Dunlap                2006-10-11 01:22:10 -0700 1782)     $prototype =~ s/^noinline +//;
74fc5c653c5d0 (Randy Dunlap                2008-06-19 16:03:29 -0700 1783)     $prototype =~ s/__init +//;
20072205fcdf7 (Randy Dunlap                2010-03-23 13:35:24 -0700 1784)     $prototype =~ s/__init_or_module +//;
80342d484afce (Matthew Wilcox              2021-04-27 12:48:28 +0100 1785)     $prototype =~ s/__deprecated +//;
084aa00162bda (Aditya Srivastava           2021-03-06 17:05:10 +0530 1786)     $prototype =~ s/__flatten +//;
270a00963cd36 (Randy Dunlap                2014-08-24 18:17:17 -0700 1787)     $prototype =~ s/__meminit +//;
70c95b00b87f8 (Randy Dunlap                2012-01-21 10:31:54 -0800 1788)     $prototype =~ s/__must_check +//;
0df7c0e3a73f5 (Randy Dunlap                2012-08-16 16:23:20 -0700 1789)     $prototype =~ s/__weak +//;
0891f95993520 (Matthew Wilcox              2018-03-15 05:06:23 -0700 1790)     $prototype =~ s/__sched +//;
95e760cbf6275 (Randy Dunlap                2019-08-05 09:29:50 -0700 1791)     $prototype =~ s/__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +//;
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1792)     my $define = $prototype =~ s/^#\s*define\s+//; #ak added
084aa00162bda (Aditya Srivastava           2021-03-06 17:05:10 +0530 1793)     $prototype =~ s/__attribute_const__ +//;
b1aaa546b52ba (Paolo Bonzini               2017-01-02 16:22:24 +0100 1794)     $prototype =~ s/__attribute__\s*\(\(
b1aaa546b52ba (Paolo Bonzini               2017-01-02 16:22:24 +0100 1795)             (?:
b1aaa546b52ba (Paolo Bonzini               2017-01-02 16:22:24 +0100 1796)                  [\w\s]++          # attribute name
b1aaa546b52ba (Paolo Bonzini               2017-01-02 16:22:24 +0100 1797)                  (?:\([^)]*+\))?   # attribute arguments
b1aaa546b52ba (Paolo Bonzini               2017-01-02 16:22:24 +0100 1798)                  \s*+,?            # optional comma at the end
b1aaa546b52ba (Paolo Bonzini               2017-01-02 16:22:24 +0100 1799)             )+
b1aaa546b52ba (Paolo Bonzini               2017-01-02 16:22:24 +0100 1800)           \)\)\s+//x;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1801) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1802)     # Yes, this truly is vile.  We are looking for:
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1803)     # 1. Return type (may be nothing if we're looking at a macro)
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1804)     # 2. Function name
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1805)     # 3. Function parameters.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1806)     #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1807)     # All the while we have to watch out for function pointer parameters
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1808)     # (which IIRC is what the two sections are for), C types (these
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1809)     # regexps don't even start to express all the possibilities), and
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1810)     # so on.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1811)     #
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1812)     # If you mess with these regexps, it's a good idea to check that
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1813)     # the following functions' documentation still comes out right:
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1814)     # - parport_register_device (function pointer parameters)
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1815)     # - atomic_set (macro)
9598f91f2216b (Martin Waitz                2006-02-01 03:06:55 -0800 1816)     # - pci_match_device, __copy_to_user (long return type)
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1817)     my $name = qr{[a-zA-Z0-9_~:]+};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1818)     my $prototype_end1 = qr{[^\(]*};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1819)     my $prototype_end2 = qr{[^\{]*};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1820)     my $prototype_end = qr{\(($prototype_end1|$prototype_end2)\)};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1821)     my $type1 = qr{[\w\s]+};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1822)     my $type2 = qr{$type1\*+};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1823) 
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1824)     if ($define && $prototype =~ m/^()($name)\s+/) {
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1825)         # This is an object-like macro, it has no return type and no parameter
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1826)         # list.
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1827)         # Function-like macros are not allowed to have spaces between
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1828)         # declaration_name and opening parenthesis (notice the \s+).
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1829)         $return_type = $1;
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1830)         $declaration_name = $2;
cbb4d3e6510b9 (Horia Geanta                2014-07-12 09:55:03 -0700 1831)         $noret = 1;
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1832)     } elsif ($prototype =~ m/^()($name)\s*$prototype_end/ ||
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1833) 	$prototype =~ m/^($type1)\s+($name)\s*$prototype_end/ ||
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 1834) 	$prototype =~ m/^($type2+)\s*($name)\s*$prototype_end/)  {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1835) 	$return_type = $1;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1836) 	$declaration_name = $2;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1837) 	my $args = $3;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1838) 
151c468b44a89 (Mauro Carvalho Chehab       2017-12-18 10:30:15 -0200 1839) 	create_parameterlist($args, ',', $file, $declaration_name);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1840)     } else {
d40e1e6532efb (Bart Van Assche             2015-09-04 15:43:21 -0700 1841) 	print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1842) 	return;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1843)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1844) 
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1845)     if ($identifier ne $declaration_name) {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1846) 	print STDERR "${file}:$.: warning: expecting prototype for $identifier(). Prototype was for $declaration_name() instead\n";
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1847) 	return;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1848)     }
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1849) 
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1850)     my $prms = join " ", @parameterlist;
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1851)     check_sections($file, $declaration_name, "function", $sectcheck, $prms);
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1852) 
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1853)     # This check emits a lot of warnings at the moment, because many
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1854)     # functions don't have a 'Return' doc section. So until the number
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1855)     # of warnings goes sufficiently down, the check is only performed in
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1856)     # verbose mode.
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1857)     # TODO: always perform the check.
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1858)     if ($verbose && !$noret) {
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1859) 	    check_return_section($file, $declaration_name, $return_type);
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1860)     }
4092bac771310 (Yacine Belkadi              2012-11-26 22:22:27 +0100 1861) 
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1862)     # The function parser can be called with a typedef parameter.
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1863)     # Handle it.
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1864)     if ($return_type =~ /typedef/) {
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1865) 	output_declaration($declaration_name,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1866) 			   'function',
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1867) 			   {'function' => $declaration_name,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1868) 			    'typedef' => 1,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1869) 			    'module' => $modulename,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1870) 			    'functiontype' => $return_type,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1871) 			    'parameterlist' => \@parameterlist,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1872) 			    'parameterdescs' => \%parameterdescs,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1873) 			    'parametertypes' => \%parametertypes,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1874) 			    'sectionlist' => \@sectionlist,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1875) 			    'sections' => \%sections,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1876) 			    'purpose' => $declaration_purpose
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1877) 			   });
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1878)     } else {
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1879) 	output_declaration($declaration_name,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1880) 			   'function',
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1881) 			   {'function' => $declaration_name,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1882) 			    'module' => $modulename,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1883) 			    'functiontype' => $return_type,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1884) 			    'parameterlist' => \@parameterlist,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1885) 			    'parameterdescs' => \%parameterdescs,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1886) 			    'parametertypes' => \%parametertypes,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1887) 			    'sectionlist' => \@sectionlist,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1888) 			    'sections' => \%sections,
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1889) 			    'purpose' => $declaration_purpose
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1890) 			   });
47bcacfd2b00e (Mauro Carvalho Chehab       2020-09-30 09:47:01 +0200 1891)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1892) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1893) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1894) sub reset_state {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1895)     $function = "";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1896)     %parameterdescs = ();
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1897)     %parametertypes = ();
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1898)     @parameterlist = ();
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1899)     %sections = ();
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1900)     @sectionlist = ();
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1901)     $sectcheck = "";
a1d94aa5560dc (Randy Dunlap                2008-12-19 08:49:30 -0800 1902)     $struct_actual = "";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1903)     $prototype = "";
3c3b809e256c4 (Randy Dunlap                2006-02-01 03:06:58 -0800 1904) 
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300 1905)     $state = STATE_NORMAL;
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300 1906)     $inline_doc_state = STATE_INLINE_NA;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1907) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1908) 
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1909) sub tracepoint_munge($) {
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1910) 	my $file = shift;
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1911) 	my $tracepointname = 0;
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1912) 	my $tracepointargs = 0;
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1913) 
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1914) 	if ($prototype =~ m/TRACE_EVENT\((.*?),/) {
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1915) 		$tracepointname = $1;
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1916) 	}
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1917) 	if ($prototype =~ m/DEFINE_SINGLE_EVENT\((.*?),/) {
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1918) 		$tracepointname = $1;
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1919) 	}
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1920) 	if ($prototype =~ m/DEFINE_EVENT\((.*?),(.*?),/) {
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1921) 		$tracepointname = $2;
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1922) 	}
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1923) 	$tracepointname =~ s/^\s+//; #strip leading whitespace
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1924) 	if ($prototype =~ m/TP_PROTO\((.*?)\)/) {
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1925) 		$tracepointargs = $1;
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1926) 	}
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1927) 	if (($tracepointname eq 0) || ($tracepointargs eq 0)) {
d40e1e6532efb (Bart Van Assche             2015-09-04 15:43:21 -0700 1928) 		print STDERR "${file}:$.: warning: Unrecognized tracepoint format: \n".
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1929) 			     "$prototype\n";
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1930) 	} else {
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1931) 		$prototype = "static inline void trace_$tracepointname($tracepointargs)";
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 1932) 		$identifier = "trace_$identifier";
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1933) 	}
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1934) }
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1935) 
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1936) sub syscall_munge() {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1937) 	my $void = 0;
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1938) 
7c9aa0157ef4b (Mauro Carvalho Chehab       2017-12-18 10:30:12 -0200 1939) 	$prototype =~ s@[\r\n]+@ @gos; # strip newlines/CR's
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1940) ##	if ($prototype =~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1941) 	if ($prototype =~ m/SYSCALL_DEFINE0/) {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1942) 		$void = 1;
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1943) ##		$prototype = "long sys_$1(void)";
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1944) 	}
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1945) 
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1946) 	$prototype =~ s/SYSCALL_DEFINE.*\(/long sys_/; # fix return type & func name
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1947) 	if ($prototype =~ m/long (sys_.*?),/) {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1948) 		$prototype =~ s/,/\(/;
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1949) 	} elsif ($void) {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1950) 		$prototype =~ s/\)/\(void\)/;
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1951) 	}
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1952) 
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1953) 	# now delete all of the odd-number commas in $prototype
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1954) 	# so that arg types & arg names don't have a comma between them
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1955) 	my $count = 0;
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1956) 	my $len = length($prototype);
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1957) 	if ($void) {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1958) 		$len = 0;	# skip the for-loop
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1959) 	}
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1960) 	for (my $ix = 0; $ix < $len; $ix++) {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1961) 		if (substr($prototype, $ix, 1) eq ',') {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1962) 			$count++;
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1963) 			if ($count % 2 == 1) {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1964) 				substr($prototype, $ix, 1) = ' ';
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1965) 			}
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1966) 		}
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1967) 	}
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1968) }
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1969) 
b7afa92b55043 (Daniel Vetter               2016-06-01 23:46:24 +0200 1970) sub process_proto_function($$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1971)     my $x = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1972)     my $file = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1973) 
51f5a0c8f6399 (Randy Dunlap                2007-07-19 01:48:24 -0700 1974)     $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
51f5a0c8f6399 (Randy Dunlap                2007-07-19 01:48:24 -0700 1975) 
890c78c2d681a (Randy Dunlap                2008-10-25 17:06:43 -0700 1976)     if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#\s*define/)) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1977) 	# do nothing
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1978)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1979)     elsif ($x =~ /([^\{]*)/) {
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1980) 	$prototype .= $1;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1981)     }
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1982) 
890c78c2d681a (Randy Dunlap                2008-10-25 17:06:43 -0700 1983)     if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) {
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 1984) 	$prototype =~ s@/\*.*?\*/@@gos;	# strip comments.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1985) 	$prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 1986) 	$prototype =~ s@^\s+@@gos; # strip leading spaces
7ae281b05c0ce (Mauro Carvalho Chehab       2020-06-23 09:09:02 +0200 1987) 
7ae281b05c0ce (Mauro Carvalho Chehab       2020-06-23 09:09:02 +0200 1988) 	 # Handle prototypes for function pointers like:
7ae281b05c0ce (Mauro Carvalho Chehab       2020-06-23 09:09:02 +0200 1989) 	 # int (*pcs_config)(struct foo)
7ae281b05c0ce (Mauro Carvalho Chehab       2020-06-23 09:09:02 +0200 1990) 	$prototype =~ s@^(\S+\s+)\(\s*\*(\S+)\)@$1$2@gos;
7ae281b05c0ce (Mauro Carvalho Chehab       2020-06-23 09:09:02 +0200 1991) 
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1992) 	if ($prototype =~ /SYSCALL_DEFINE/) {
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1993) 		syscall_munge();
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 1994) 	}
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1995) 	if ($prototype =~ /TRACE_EVENT/ || $prototype =~ /DEFINE_EVENT/ ||
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1996) 	    $prototype =~ /DEFINE_SINGLE_EVENT/)
3a9089fd78367 (Jason Baron                 2009-12-01 12:18:49 -0500 1997) 	{
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1998) 		tracepoint_munge($file);
56afb0f882365 (Jason Baron                 2009-04-30 13:29:36 -0400 1999) 	}
b4870bc5ee8c7 (Randy Dunlap                2009-02-11 13:04:33 -0800 2000) 	dump_function($prototype, $file);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2001) 	reset_state();
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2002)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2003) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2004) 
b7afa92b55043 (Daniel Vetter               2016-06-01 23:46:24 +0200 2005) sub process_proto_type($$) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2006)     my $x = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2007)     my $file = shift;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2008) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2009)     $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2010)     $x =~ s@^\s+@@gos; # strip leading spaces
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2011)     $x =~ s@\s+$@@gos; # strip trailing spaces
51f5a0c8f6399 (Randy Dunlap                2007-07-19 01:48:24 -0700 2012)     $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
51f5a0c8f6399 (Randy Dunlap                2007-07-19 01:48:24 -0700 2013) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2014)     if ($x =~ /^#/) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2015) 	# To distinguish preprocessor directive from regular declaration later.
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2016) 	$x .= ";";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2017)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2018) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2019)     while (1) {
673bb2dfc3648 (Ben Hutchings               2018-08-05 17:41:09 +0100 2020) 	if ( $x =~ /([^\{\};]*)([\{\};])(.*)/ ) {
463a0fdc3e800 (Markus Heiser               2017-06-16 21:27:48 +0200 2021)             if( length $prototype ) {
463a0fdc3e800 (Markus Heiser               2017-06-16 21:27:48 +0200 2022)                 $prototype .= " "
463a0fdc3e800 (Markus Heiser               2017-06-16 21:27:48 +0200 2023)             }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2024) 	    $prototype .= $1 . $2;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2025) 	    ($2 eq '{') && $brcount++;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2026) 	    ($2 eq '}') && $brcount--;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2027) 	    if (($2 eq ';') && ($brcount == 0)) {
b9d97328e27b9 (Randy Dunlap                2009-06-09 08:50:38 -0700 2028) 		dump_declaration($prototype, $file);
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2029) 		reset_state();
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 2030) 		last;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2031) 	    }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2032) 	    $x = $3;
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 2033) 	} else {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2034) 	    $prototype .= $x;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2035) 	    last;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2036) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2037)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2038) }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2039) 
6b5b55f6c404f (Randy Dunlap                2007-10-16 23:31:20 -0700 2040) 
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2041) sub map_filename($) {
2283a117f6565 (Randy Dunlap                2005-07-07 15:39:26 -0700 2042)     my $file;
68f86662380c3 (Ben Hutchings               2015-09-01 23:48:49 +0100 2043)     my ($orig_file) = @_;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2044) 
2283a117f6565 (Randy Dunlap                2005-07-07 15:39:26 -0700 2045)     if (defined($ENV{'SRCTREE'})) {
68f86662380c3 (Ben Hutchings               2015-09-01 23:48:49 +0100 2046) 	$file = "$ENV{'SRCTREE'}" . "/" . $orig_file;
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2047)     } else {
68f86662380c3 (Ben Hutchings               2015-09-01 23:48:49 +0100 2048) 	$file = $orig_file;
2283a117f6565 (Randy Dunlap                2005-07-07 15:39:26 -0700 2049)     }
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2050) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2051)     if (defined($source_map{$file})) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2052) 	$file = $source_map{$file};
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2053)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2054) 
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2055)     return $file;
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2056) }
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2057) 
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2058) sub process_export_file($) {
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2059)     my ($orig_file) = @_;
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2060)     my $file = map_filename($orig_file);
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2061) 
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2062)     if (!open(IN,"<$file")) {
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2063) 	print STDERR "Error: Cannot open file $file\n";
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2064) 	++$errors;
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2065) 	return;
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2066)     }
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2067) 
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2068)     while (<IN>) {
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2069) 	if (/$export_symbol/) {
eab795ddd84ff (Mauro Carvalho Chehab       2020-09-29 14:23:39 +0200 2070) 	    next if (defined($nosymbol_table{$2}));
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2071) 	    $function_table{$2} = 1;
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2072) 	}
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2073)     }
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2074) 
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2075)     close(IN);
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2076) }
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2077) 
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2078) #
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2079) # Parsers for the various processing states.
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2080) #
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2081) # STATE_NORMAL: looking for the /** to begin everything.
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2082) #
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2083) sub process_normal() {
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2084)     if (/$doc_start/o) {
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2085) 	$state = STATE_NAME;	# next line is always the function name
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2086) 	$in_doc_sect = 0;
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2087) 	$declaration_start_line = $. + 1;
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2088)     }
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2089) }
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2090) 
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2091) #
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2092) # STATE_NAME: Looking for the "name - description" line
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2093) #
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2094) sub process_name($$) {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2095)     my $file = shift;
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2096)     my $descr;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2097) 
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2098)     if (/$doc_block/o) {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2099) 	$state = STATE_DOCBLOCK;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2100) 	$contents = "";
5ef09c96d48b4 (Mauro Carvalho Chehab       2020-10-09 10:15:25 +0200 2101) 	$new_start_line = $.;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2102) 
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2103) 	if ( $1 eq "" ) {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2104) 	    $section = $section_intro;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2105) 	} else {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2106) 	    $section = $1;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2107) 	}
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2108)     } elsif (/$doc_decl/o) {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2109) 	$identifier = $1;
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2110) 	my $is_kernel_comment = 0;
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 2111) 	my $decl_start = qr{$doc_com};
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2112) 	# test for pointer declaration type, foo * bar() - desc
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2113) 	my $fn_type = qr{\w+\s*\*\s*}; 
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2114) 	my $parenthesis = qr{\(\w*\)};
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2115) 	my $decl_end = qr{[-:].*};
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 2116) 	if (/^$decl_start([\w\s]+?)$parenthesis?\s*$decl_end?$/) {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2117) 	    $identifier = $1;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2118) 	}
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2119) 	if ($identifier =~ m/^(struct|union|enum|typedef)\b\s*(\S*)/) {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2120) 	    $decl_type = $1;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2121) 	    $identifier = $2;
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2122) 	    $is_kernel_comment = 1;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2123) 	}
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2124) 	# Look for foo() or static void foo() - description; or misspelt
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2125) 	# identifier
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 2126) 	elsif (/^$decl_start$fn_type?(\w+)\s*$parenthesis?\s*$decl_end?$/ ||
e86bdb24375a8 (Aditya Srivastava           2021-05-14 20:12:44 +0530 2127) 	    /^$decl_start$fn_type?(\w+.*)$parenthesis?\s*$decl_end$/) {
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2128) 	    $identifier = $1;
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2129) 	    $decl_type = 'function';
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2130) 	    $identifier =~ s/^define\s+//;
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2131) 	    $is_kernel_comment = 1;
f9bbc12ccb35a (Aditya Srivastava           2021-04-15 00:55:29 +0530 2132) 	}
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2133) 	$identifier =~ s/\s+$//;
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2134) 
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2135) 	$state = STATE_BODY;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2136) 	# if there's no @param blocks need to set up default section
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2137) 	# here
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2138) 	$contents = "";
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2139) 	$section = $section_default;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2140) 	$new_start_line = $. + 1;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2141) 	if (/[-:](.*)/) {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2142) 	    # strip leading/trailing/multiple spaces
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2143) 	    $descr= $1;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2144) 	    $descr =~ s/^\s*//;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2145) 	    $descr =~ s/\s*$//;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2146) 	    $descr =~ s/\s+/ /g;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2147) 	    $declaration_purpose = $descr;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2148) 	    $state = STATE_BODY_MAYBE;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2149) 	} else {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2150) 	    $declaration_purpose = "";
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2151) 	}
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2152) 
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2153) 	if (!$is_kernel_comment) {
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2154) 	    print STDERR "${file}:$.: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst\n";
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2155) 	    print STDERR $_;
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2156) 	    ++$warnings;
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2157) 	    $state = STATE_NORMAL;
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2158) 	}
3e58e839150db (Aditya Srivastava           2021-03-29 14:59:45 +0530 2159) 
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2160) 	if (($declaration_purpose eq "") && $verbose) {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2161) 	    print STDERR "${file}:$.: warning: missing initial short description on line:\n";
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2162) 	    print STDERR $_;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2163) 	    ++$warnings;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2164) 	}
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2165) 
0b54c2e34be79 (Mauro Carvalho Chehab       2021-03-03 09:42:14 +0100 2166) 	if ($identifier eq "" && $decl_type ne "enum") {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2167) 	    print STDERR "${file}:$.: warning: wrong kernel-doc identifier on line:\n";
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2168) 	    print STDERR $_;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2169) 	    ++$warnings;
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2170) 	    $state = STATE_NORMAL;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2171) 	}
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2172) 
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2173) 	if ($verbose) {
52042e2db4529 (Mauro Carvalho Chehab       2021-01-14 09:04:47 +0100 2174) 	    print STDERR "${file}:$.: info: Scanning doc for $decl_type $identifier\n";
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2175) 	}
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2176)     } else {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2177) 	print STDERR "${file}:$.: warning: Cannot understand $_ on line $.",
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2178) 	    " - I thought it was a doc line\n";
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2179) 	++$warnings;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2180) 	$state = STATE_NORMAL;
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2181)     }
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2182) }
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2183) 
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2184) 
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2185) #
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2186) # STATE_BODY and STATE_BODY_MAYBE: the bulk of a kerneldoc comment.
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2187) #
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2188) sub process_body($$) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2189)     my $file = shift;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2190) 
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2191)     # Until all named variable macro parameters are
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2192)     # documented using the bare name (`x`) rather than with
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2193)     # dots (`x...`), strip the dots:
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2194)     if ($section =~ /\w\.\.\.$/) {
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2195) 	$section =~ s/\.\.\.$//;
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2196) 
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2197) 	if ($verbose) {
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2198) 	    print STDERR "${file}:$.: warning: Variable macro arguments should be documented without dots\n";
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2199) 	    ++$warnings;
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2200) 	}
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2201)     }
43756e347f213 (Jonathan Neuschäfer         2019-11-07 14:41:33 +0100 2202) 
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2203)     if ($state == STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) {
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2204) 	dump_section($file, $section, $contents);
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2205) 	$section = $section_default;
5ef09c96d48b4 (Mauro Carvalho Chehab       2020-10-09 10:15:25 +0200 2206) 	$new_start_line = $.;
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2207) 	$contents = "";
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2208)     }
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2209) 
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2210)     if (/$doc_sect/i) { # case insensitive for supported section names
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2211) 	$newsection = $1;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2212) 	$newcontents = $2;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2213) 
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2214) 	# map the supported section names to the canonical names
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2215) 	if ($newsection =~ m/^description$/i) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2216) 	    $newsection = $section_default;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2217) 	} elsif ($newsection =~ m/^context$/i) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2218) 	    $newsection = $section_context;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2219) 	} elsif ($newsection =~ m/^returns?$/i) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2220) 	    $newsection = $section_return;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2221) 	} elsif ($newsection =~ m/^\@return$/) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2222) 	    # special: @return is a section, not a param description
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2223) 	    $newsection = $section_return;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2224) 	}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2225) 
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2226) 	if (($contents ne "") && ($contents ne "\n")) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2227) 	    if (!$in_doc_sect && $verbose) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2228) 		print STDERR "${file}:$.: warning: contents before sections\n";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2229) 		++$warnings;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2230) 	    }
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2231) 	    dump_section($file, $section, $contents);
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2232) 	    $section = $section_default;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2233) 	}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2234) 
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2235) 	$in_doc_sect = 1;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2236) 	$state = STATE_BODY;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2237) 	$contents = $newcontents;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2238) 	$new_start_line = $.;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2239) 	while (substr($contents, 0, 1) eq " ") {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2240) 	    $contents = substr($contents, 1);
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2241) 	}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2242) 	if ($contents ne "") {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2243) 	    $contents .= "\n";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2244) 	}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2245) 	$section = $newsection;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2246) 	$leading_space = undef;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2247)     } elsif (/$doc_end/) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2248) 	if (($contents ne "") && ($contents ne "\n")) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2249) 	    dump_section($file, $section, $contents);
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2250) 	    $section = $section_default;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2251) 	    $contents = "";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2252) 	}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2253) 	# look for doc_com + <text> + doc_end:
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2254) 	if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2255) 	    print STDERR "${file}:$.: warning: suspicious ending line: $_";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2256) 	    ++$warnings;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2257) 	}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2258) 
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2259) 	$prototype = "";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2260) 	$state = STATE_PROTO;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2261) 	$brcount = 0;
5ef09c96d48b4 (Mauro Carvalho Chehab       2020-10-09 10:15:25 +0200 2262)         $new_start_line = $. + 1;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2263)     } elsif (/$doc_content/) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2264) 	if ($1 eq "") {
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2265) 	    if ($section eq $section_context) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2266) 		dump_section($file, $section, $contents);
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2267) 		$section = $section_default;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2268) 		$contents = "";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2269) 		$new_start_line = $.;
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2270) 		$state = STATE_BODY;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2271) 	    } else {
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2272) 		if ($section ne $section_default) {
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2273) 		    $state = STATE_BODY_WITH_BLANK_LINE;
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2274) 		} else {
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2275) 		    $state = STATE_BODY;
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2276) 		}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2277) 		$contents .= "\n";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2278) 	    }
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2279) 	} elsif ($state == STATE_BODY_MAYBE) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2280) 	    # Continued declaration purpose
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2281) 	    chomp($declaration_purpose);
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2282) 	    $declaration_purpose .= " " . $1;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2283) 	    $declaration_purpose =~ s/\s+/ /g;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2284) 	} else {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2285) 	    my $cont = $1;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2286) 	    if ($section =~ m/^@/ || $section eq $section_context) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2287) 		if (!defined $leading_space) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2288) 		    if ($cont =~ m/^(\s+)/) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2289) 			$leading_space = $1;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2290) 		    } else {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2291) 			$leading_space = "";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2292) 		    }
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2293) 		}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2294) 		$cont =~ s/^$leading_space//;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2295) 	    }
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2296) 	    $contents .= $cont . "\n";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2297) 	}
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2298)     } else {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2299) 	# i dont know - bad line?  ignore.
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2300) 	print STDERR "${file}:$.: warning: bad line: $_";
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2301) 	++$warnings;
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2302)     }
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2303) }
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2304) 
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2305) 
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2306) #
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2307) # STATE_PROTO: reading a function/whatever prototype.
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2308) #
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2309) sub process_proto($$) {
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2310)     my $file = shift;
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2311) 
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2312)     if (/$doc_inline_oneline/) {
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2313) 	$section = $1;
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2314) 	$contents = $2;
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2315) 	if ($contents ne "") {
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2316) 	    $contents .= "\n";
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2317) 	    dump_section($file, $section, $contents);
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2318) 	    $section = $section_default;
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2319) 	    $contents = "";
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2320) 	}
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2321)     } elsif (/$doc_inline_start/) {
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2322) 	$state = STATE_INLINE;
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2323) 	$inline_doc_state = STATE_INLINE_NAME;
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2324)     } elsif ($decl_type eq 'function') {
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2325) 	process_proto_function($_, $file);
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2326)     } else {
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2327) 	process_proto_type($_, $file);
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2328)     }
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2329) }
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2330) 
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2331) #
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2332) # STATE_DOCBLOCK: within a DOC: block.
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2333) #
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2334) sub process_docblock($$) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2335)     my $file = shift;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2336) 
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2337)     if (/$doc_end/) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2338) 	dump_doc_section($file, $section, $contents);
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2339) 	$section = $section_default;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2340) 	$contents = "";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2341) 	$function = "";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2342) 	%parameterdescs = ();
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2343) 	%parametertypes = ();
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2344) 	@parameterlist = ();
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2345) 	%sections = ();
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2346) 	@sectionlist = ();
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2347) 	$prototype = "";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2348) 	$state = STATE_NORMAL;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2349)     } elsif (/$doc_content/) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2350) 	if ( $1 eq "" )	{
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2351) 	    $contents .= $blankline;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2352) 	} else {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2353) 	    $contents .= $1 . "\n";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2354) 	}
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2355)     }
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2356) }
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2357) 
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2358) #
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2359) # STATE_INLINE: docbook comments within a prototype.
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2360) #
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2361) sub process_inline($$) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2362)     my $file = shift;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2363) 
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2364)     # First line (state 1) needs to be a @parameter
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2365)     if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2366) 	$section = $1;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2367) 	$contents = $2;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2368) 	$new_start_line = $.;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2369) 	if ($contents ne "") {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2370) 	    while (substr($contents, 0, 1) eq " ") {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2371) 		$contents = substr($contents, 1);
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2372) 	    }
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2373) 	    $contents .= "\n";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2374) 	}
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2375) 	$inline_doc_state = STATE_INLINE_TEXT;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2376) 	# Documentation block end */
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2377)     } elsif (/$doc_inline_end/) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2378) 	if (($contents ne "") && ($contents ne "\n")) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2379) 	    dump_section($file, $section, $contents);
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2380) 	    $section = $section_default;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2381) 	    $contents = "";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2382) 	}
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2383) 	$state = STATE_PROTO;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2384) 	$inline_doc_state = STATE_INLINE_NA;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2385) 	# Regular text
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2386)     } elsif (/$doc_content/) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2387) 	if ($inline_doc_state == STATE_INLINE_TEXT) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2388) 	    $contents .= $1 . "\n";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2389) 	    # nuke leading blank lines
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2390) 	    if ($contents =~ /^\s*$/) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2391) 		$contents = "";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2392) 	    }
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2393) 	} elsif ($inline_doc_state == STATE_INLINE_NAME) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2394) 	    $inline_doc_state = STATE_INLINE_ERROR;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2395) 	    print STDERR "${file}:$.: warning: ";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2396) 	    print STDERR "Incorrect use of kernel-doc format: $_";
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2397) 	    ++$warnings;
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2398) 	}
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2399)     }
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2400) }
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2401) 
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2402) 
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2403) sub process_file($) {
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2404)     my $file;
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2405)     my $initial_section_counter = $section_counter;
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2406)     my ($orig_file) = @_;
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2407) 
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2408)     $file = map_filename($orig_file);
1ad560e43c911 (Jani Nikula                 2016-06-07 10:53:39 +0300 2409) 
dbe8ba00e5adc (Mauro Carvalho Chehab       2020-09-28 12:52:34 +0200 2410)     if (!open(IN_FILE,"<$file")) {
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2411) 	print STDERR "Error: Cannot open file $file\n";
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2412) 	++$errors;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2413) 	return;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2414)     }
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2415) 
a9e7314b7940c (Ilya Dryomov                2010-02-26 13:05:47 -0800 2416)     $. = 1;
a9e7314b7940c (Ilya Dryomov                2010-02-26 13:05:47 -0800 2417) 
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2418)     $section_counter = 0;
dbe8ba00e5adc (Mauro Carvalho Chehab       2020-09-28 12:52:34 +0200 2419)     while (<IN_FILE>) {
654784284430b (Daniel Santos               2012-10-04 17:15:05 -0700 2420) 	while (s/\\\s*$//) {
dbe8ba00e5adc (Mauro Carvalho Chehab       2020-09-28 12:52:34 +0200 2421) 	    $_ .= <IN_FILE>;
654784284430b (Daniel Santos               2012-10-04 17:15:05 -0700 2422) 	}
7c9aa0157ef4b (Mauro Carvalho Chehab       2017-12-18 10:30:12 -0200 2423) 	# Replace tabs by spaces
7c9aa0157ef4b (Mauro Carvalho Chehab       2017-12-18 10:30:12 -0200 2424)         while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2425) 	# Hand this line to the appropriate state handler
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300 2426) 	if ($state == STATE_NORMAL) {
07048d13136bc (Jonathan Corbet             2018-02-05 14:15:19 -0700 2427) 	    process_normal();
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2428) 	} elsif ($state == STATE_NAME) {
3cac2bc41d1b4 (Jonathan Corbet             2018-02-05 14:36:33 -0700 2429) 	    process_name($file, $_);
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2430) 	} elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE ||
0d55d48b19ff3 (Mauro Carvalho Chehab       2020-04-14 18:48:29 +0200 2431) 		 $state == STATE_BODY_WITH_BLANK_LINE) {
d742f24d6cce6 (Jonathan Corbet             2018-02-05 15:36:05 -0700 2432) 	    process_body($file, $_);
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300 2433) 	} elsif ($state == STATE_INLINE) { # scanning for inline parameters
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2434) 	    process_inline($file, $_);
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2435) 	} elsif ($state == STATE_PROTO) {
cc794812eba91 (Jonathan Corbet             2018-02-05 15:46:30 -0700 2436) 	    process_proto($file, $_);
48af606ad8912 (Jani Nikula                 2016-05-26 14:56:05 +0300 2437) 	} elsif ($state == STATE_DOCBLOCK) {
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2438) 	    process_docblock($file, $_);
3c308798a337d (Randy Dunlap                2007-05-08 00:24:39 -0700 2439) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2440)     }
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2441) 
c17add56ca4ee (Jonathan Corbet             2018-02-05 16:11:47 -0700 2442)     # Make sure we got something interesting.
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600 2443)     if ($initial_section_counter == $section_counter && $
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600 2444) 	output_mode ne "none") {
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600 2445) 	if ($output_selection == OUTPUT_INCLUDE) {
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600 2446) 	    print STDERR "${file}:1: warning: '$_' not found\n"
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600 2447) 		for keys %function_table;
3a025e1d1c2ea (Matthew Wilcox              2017-11-20 10:40:40 -0800 2448) 	}
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600 2449) 	else {
b0d60bfbb60ce (Jonathan Corbet             2019-05-24 14:52:01 -0600 2450) 	    print STDERR "${file}:1: warning: no structured comments found\n";
e946c43a11652 (Johannes Berg               2013-11-12 15:11:12 -0800 2451) 	}
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2452)     }
dbe8ba00e5adc (Mauro Carvalho Chehab       2020-09-28 12:52:34 +0200 2453)     close IN_FILE;
^1da177e4c3f4 (Linus Torvalds              2005-04-16 15:20:36 -0700 2454) }
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2455) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2456) 
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200 2457) if ($output_mode eq "rst") {
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200 2458) 	get_sphinx_version() if (!$sphinx_major);
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200 2459) }
93351d4196802 (Mauro Carvalho Chehab       2020-10-04 09:44:28 +0200 2460) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2461) $kernelversion = get_kernel_version();
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2462) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2463) # generate a sequence of code that will splice in highlighting information
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2464) # using the s// operator.
1ef0623371e0a (Mauro Carvalho Chehab       2015-11-17 13:29:49 -0200 2465) for (my $k = 0; $k < @highlights; $k++) {
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300 2466)     my $pattern = $highlights[$k][0];
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300 2467)     my $result = $highlights[$k][1];
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300 2468) #   print STDERR "scanning pattern:$pattern, highlight:($result)\n";
4d73270192ec8 (Danilo Cesar Lemes de Paula 2015-09-07 17:01:59 -0300 2469)     $dohighlight .=  "\$contents =~ s:$pattern:$result:gs;\n";
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2470) }
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2471) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2472) # Read the file that maps relative names to absolute names for
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2473) # separate source and object directories and for shadow trees.
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2474) if (open(SOURCE_MAP, "<.tmp_filelist.txt")) {
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2475) 	my ($relname, $absname);
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2476) 	while(<SOURCE_MAP>) {
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2477) 		chop();
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2478) 		($relname, $absname) = (split())[0..1];
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2479) 		$relname =~ s:^/+::;
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2480) 		$source_map{$relname} = $absname;
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2481) 	}
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2482) 	close(SOURCE_MAP);
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2483) }
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2484) 
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2485) if ($output_selection == OUTPUT_EXPORTED ||
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2486)     $output_selection == OUTPUT_INTERNAL) {
c9b2cfb3faece (Jani Nikula                 2016-06-07 11:05:53 +0300 2487) 
c9b2cfb3faece (Jani Nikula                 2016-06-07 11:05:53 +0300 2488)     push(@export_file_list, @ARGV);
c9b2cfb3faece (Jani Nikula                 2016-06-07 11:05:53 +0300 2489) 
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2490)     foreach (@export_file_list) {
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2491) 	chomp;
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2492) 	process_export_file($_);
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2493)     }
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2494) }
88c2b57da4ce3 (Jani Nikula                 2016-06-07 11:00:52 +0300 2495) 
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2496) foreach (@ARGV) {
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2497)     chomp;
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2498)     process_file($_);
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2499) }
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2500) if ($verbose && $errors) {
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2501)   print STDERR "$errors errors\n";
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2502) }
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2503) if ($verbose && $warnings) {
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2504)   print STDERR "$warnings warnings\n";
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2505) }
8484baaa5065b (Randy Dunlap                2011-01-05 16:28:43 -0800 2506) 
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500 2507) if ($Werror && $warnings) {
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500 2508)     print STDERR "$warnings warnings as Errors\n";
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500 2509)     exit($warnings);
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500 2510) } else {
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500 2511)     exit($output_mode eq "none" ? 0 : $errors)
2c12c8103d8f1 (Pierre-Louis Bossart        2020-07-28 11:20:40 -0500 2512) }