diff mbox

[v2] kernel-doc: parse DECLARE_KFIFO and DECLARE_KFIFO_PTR()

Message ID 37a81ae259c9d3a90fbdbe1532f904946139bfdd.1512741889.git.mchehab@s-opensource.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab Dec. 8, 2017, 2:05 p.m. UTC
On media, we now have an struct declared with:

struct lirc_fh {
        struct list_head list;
        struct rc_dev *rc;
        int                             carrier_low;
        bool                            send_timeout_reports;
        DECLARE_KFIFO_PTR(rawir, unsigned int);
        DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode);
        wait_queue_head_t               wait_poll;
        u8                              send_mode;
        u8                              rec_mode;
};

gpiolib.c has a similar declaration with DECLARE_KFIFO().

Currently, those produce the following error:

	./include/media/rc-core.h:96: warning: No description found for parameter 'int'
	./include/media/rc-core.h:96: warning: No description found for parameter 'lirc_scancode'
	./include/media/rc-core.h:96: warning: Excess struct member 'rawir' description in 'lirc_fh'
	./include/media/rc-core.h:96: warning: Excess struct member 'scancodes' description in 'lirc_fh'
	../drivers/gpio/gpiolib.c:601: warning: No description found for parameter '16'
	../drivers/gpio/gpiolib.c:601: warning: Excess struct member 'events' description in 'lineevent_state'

So, teach kernel-doc how to parse DECLARE_KFIFO() and DECLARE_KFIFO_PTR().

While here, relax at the past DECLARE_foo() macros, accepting a random
number of spaces after comma.

The addition of DECLARE_KFIFO() was
Suggested-by: Randy Dunlap <rdunlap@infradead.org>

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 scripts/kernel-doc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Markus Heiser Dec. 8, 2017, 4:01 p.m. UTC | #1
FYI: added similar patch to the linuxdoc sphinx-extension

 https://github.com/return42/linuxdoc/commit/726af7a

Thanks!

-- Markus -- 

> Am 08.12.2017 um 15:05 schrieb Mauro Carvalho Chehab <mchehab@s-opensource.com>:
> 
> On media, we now have an struct declared with:
> 
> struct lirc_fh {
>       struct list_head list;
>       struct rc_dev *rc;
>       int                             carrier_low;
>       bool                            send_timeout_reports;
>       DECLARE_KFIFO_PTR(rawir, unsigned int);
>       DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode);
>       wait_queue_head_t               wait_poll;
>       u8                              send_mode;
>       u8                              rec_mode;
> };
> 
> gpiolib.c has a similar declaration with DECLARE_KFIFO().
> 
> Currently, those produce the following error:
> 
> 	./include/media/rc-core.h:96: warning: No description found for parameter 'int'
> 	./include/media/rc-core.h:96: warning: No description found for parameter 'lirc_scancode'
> 	./include/media/rc-core.h:96: warning: Excess struct member 'rawir' description in 'lirc_fh'
> 	./include/media/rc-core.h:96: warning: Excess struct member 'scancodes' description in 'lirc_fh'
> 	../drivers/gpio/gpiolib.c:601: warning: No description found for parameter '16'
> 	../drivers/gpio/gpiolib.c:601: warning: Excess struct member 'events' description in 'lineevent_state'
> 
> So, teach kernel-doc how to parse DECLARE_KFIFO() and DECLARE_KFIFO_PTR().
> 
> While here, relax at the past DECLARE_foo() macros, accepting a random
> number of spaces after comma.
> 
> The addition of DECLARE_KFIFO() was
> Suggested-by: Randy Dunlap <rdunlap@infradead.org>
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
> scripts/kernel-doc | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index bd29a92b4b48..cfdabdd08631 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -2208,9 +2208,13 @@ sub dump_struct($$) {
> 	$members =~ s/__aligned\s*\([^;]*\)//gos;
> 	$members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos;
> 	# replace DECLARE_BITMAP
> -	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
> +	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
> 	# replace DECLARE_HASHTABLE
> -	$members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
> +	$members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
> +	# replace DECLARE_KFIFO
> +	$members =~ s/DECLARE_KFIFO\s*\(([^,)]+),\s*([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
> +	# replace DECLARE_KFIFO_PTR
> +	$members =~ s/DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
> 
> 	create_parameterlist($members, ';', $file);
> 	check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual, $nested);
> -- 
> 2.14.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-doc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Randy Dunlap Dec. 8, 2017, 10:07 p.m. UTC | #2
On 12/08/2017 06:05 AM, Mauro Carvalho Chehab wrote:
> On media, we now have an struct declared with:
> 
> struct lirc_fh {
>         struct list_head list;
>         struct rc_dev *rc;
>         int                             carrier_low;
>         bool                            send_timeout_reports;
>         DECLARE_KFIFO_PTR(rawir, unsigned int);
>         DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode);
>         wait_queue_head_t               wait_poll;
>         u8                              send_mode;
>         u8                              rec_mode;
> };
> 
> gpiolib.c has a similar declaration with DECLARE_KFIFO().
> 
> Currently, those produce the following error:
> 
> 	./include/media/rc-core.h:96: warning: No description found for parameter 'int'
> 	./include/media/rc-core.h:96: warning: No description found for parameter 'lirc_scancode'
> 	./include/media/rc-core.h:96: warning: Excess struct member 'rawir' description in 'lirc_fh'
> 	./include/media/rc-core.h:96: warning: Excess struct member 'scancodes' description in 'lirc_fh'
> 	../drivers/gpio/gpiolib.c:601: warning: No description found for parameter '16'
> 	../drivers/gpio/gpiolib.c:601: warning: Excess struct member 'events' description in 'lineevent_state'
> 
> So, teach kernel-doc how to parse DECLARE_KFIFO() and DECLARE_KFIFO_PTR().
> 
> While here, relax at the past DECLARE_foo() macros, accepting a random
> number of spaces after comma.
> 
> The addition of DECLARE_KFIFO() was
> Suggested-by: Randy Dunlap <rdunlap@infradead.org>
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

Tested-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>

Thanks.

> ---
>  scripts/kernel-doc | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index bd29a92b4b48..cfdabdd08631 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -2208,9 +2208,13 @@ sub dump_struct($$) {
>  	$members =~ s/__aligned\s*\([^;]*\)//gos;
>  	$members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos;
>  	# replace DECLARE_BITMAP
> -	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
> +	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
>  	# replace DECLARE_HASHTABLE
> -	$members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
> +	$members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
> +	# replace DECLARE_KFIFO
> +	$members =~ s/DECLARE_KFIFO\s*\(([^,)]+),\s*([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
> +	# replace DECLARE_KFIFO_PTR
> +	$members =~ s/DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
>  
>  	create_parameterlist($members, ';', $file);
>  	check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual, $nested);
>
Jonathan Corbet Dec. 11, 2017, 9:20 p.m. UTC | #3
On Fri,  8 Dec 2017 09:05:12 -0500
Mauro Carvalho Chehab <mchehab@s-opensource.com> wrote:

> So, teach kernel-doc how to parse DECLARE_KFIFO() and DECLARE_KFIFO_PTR().
> 
> While here, relax at the past DECLARE_foo() macros, accepting a random
> number of spaces after comma.

Applied, thanks.

jon
diff mbox

Patch

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index bd29a92b4b48..cfdabdd08631 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2208,9 +2208,13 @@  sub dump_struct($$) {
 	$members =~ s/__aligned\s*\([^;]*\)//gos;
 	$members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos;
 	# replace DECLARE_BITMAP
-	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
+	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
 	# replace DECLARE_HASHTABLE
-	$members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
+	$members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
+	# replace DECLARE_KFIFO
+	$members =~ s/DECLARE_KFIFO\s*\(([^,)]+),\s*([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
+	# replace DECLARE_KFIFO_PTR
+	$members =~ s/DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
 
 	create_parameterlist($members, ';', $file);
 	check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual, $nested);