From nobody Thu Dec 18 09:23:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90F9634B19A; Tue, 16 Dec 2025 14:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895184; cv=none; b=dXj9F2cZ9mYrDkbX3cajwMPFiWThoU2mgvBIGqC4+IWYnF88va532BISuEouqqniZUsRIZCI3QKLB1W1JnQSGxUA7CFX74rFTRj9inFMIBd6ydTu/lMAPId6dZJx8fXbjvIKoo3s3NuF5dy+lpIM26oWDNGzIXbHIGbOGbIkJMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895184; c=relaxed/simple; bh=D5Dan+chdaKCsHfpLGspv1TIRzMfinLgSlG6JG25Zz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YsOEBZx+jgInlyvYtkD3gCzC3JtsQyuage8YjAE7TzylDX6p4yAoGoZ67cwqvBw+/u58A7UdU9u0hPqjj72Cb5YXwforM+hgXC9WienhJwTzuKQWZMvYx3MIiMshfX2cupCQhtBKm1IOIE3Ql6fS2vJPmLsmwSpSms1OQl4vIBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F4ZhULlt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F4ZhULlt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BC15C4CEF1; Tue, 16 Dec 2025 14:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765895184; bh=D5Dan+chdaKCsHfpLGspv1TIRzMfinLgSlG6JG25Zz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F4ZhULltBwmzjiMZjPBrfdObM140oLI9BuiA0GVHSyMKW4rNqKuto+4t5EgZqHQoD JtgeQLbTAUEMmOJ2HPv7YT1xCjNgyucjLBWSoyxPomvphMRp/H/uCZoeP8pMRGp4bW NzIJCAEa6kncocXw2jVxSvvl264NiOOgDKIJIBp3MorCUieREzX9JRJq/3qPYl4RMZ 70jJbUtdURE2Xd0Co8ZEgXUWFR3JkH3S3SEfnXu8r+cg0CEY5duTa+H4Pwh6Hicx4C lU11i9CWU/2FUgLgIVnle6q2tf5lyK8TMH7NsFShPSPFU+zKrGMK22r/lHaH7CqCuO fAy4M52DihLqA== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVW0M-00000000ssF-2YcS; Tue, 16 Dec 2025 15:26:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v7 1/6] kernel-doc: add support for handling global variables Date: Tue, 16 Dec 2025 15:26:12 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Specially on kAPI, sometimes it is desirable to be able to describe global variables that are part of kAPI. Documenting vars with Sphinx is simple, as we don't need to parse a data struct. All we need is the variable declaration and use native C domain ::c:var: to format it for us. Add support for it. Link: https://lore.kernel.org/linux-doc/491c3022-cef8-4860-a945-c9c4a3b63c0= 9@infradead.org/T/#m947c25d95cb1d96a394410ab1131dc8e9e5013f1 Suggested-by: Randy Dunlap Tested-by: Randy Dunlap Acked-by: Randy Dunlap Signed-off-by: Mauro Carvalho Chehab --- tools/lib/python/kdoc/kdoc_output.py | 47 +++++++++++++++++++++++ tools/lib/python/kdoc/kdoc_parser.py | 56 +++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/tools/lib/python/kdoc/kdoc_output.py b/tools/lib/python/kdoc/k= doc_output.py index b1aaa7fc3604..50aedbb3d6de 100644 --- a/tools/lib/python/kdoc/kdoc_output.py +++ b/tools/lib/python/kdoc/kdoc_output.py @@ -199,6 +199,10 @@ class OutputFormat: self.out_enum(fname, name, args) return self.data =20 + if dtype =3D=3D "var": + self.out_var(fname, name, args) + return self.data + if dtype =3D=3D "typedef": self.out_typedef(fname, name, args) return self.data @@ -227,6 +231,9 @@ class OutputFormat: def out_enum(self, fname, name, args): """Outputs an enum""" =20 + def out_var(self, fname, name, args): + """Outputs a variable""" + def out_typedef(self, fname, name, args): """Outputs a typedef""" =20 @@ -472,6 +479,25 @@ class RestFormat(OutputFormat): self.lineprefix =3D oldprefix self.out_section(args) =20 + def out_var(self, fname, name, args): + oldprefix =3D self.lineprefix + ln =3D args.declaration_start_line + full_proto =3D args.other_stuff["full_proto"] + + self.lineprefix =3D " " + + self.data +=3D f"\n\n.. c:macro:: {name}\n\n{self.lineprefix}{full= _proto}\n\n" + + self.print_lineno(ln) + self.output_highlight(args.get('purpose', '')) + self.data +=3D "\n" + + if args.other_stuff["default_val"]: + self.data +=3D f'{self.lineprefix}**Initialization**\n\n' + self.output_highlight(f'default: ``{args.other_stuff["default_= val"]}``') + + self.out_section(args) + def out_typedef(self, fname, name, args): =20 oldprefix =3D self.lineprefix @@ -773,6 +799,27 @@ class ManFormat(OutputFormat): self.data +=3D f'.SH "{section}"' + "\n" self.output_highlight(text) =20 + def out_var(self, fname, name, args): + out_name =3D self.arg_name(args, name) + prototype =3D args.other_stuff["var_type"] + full_proto =3D args.other_stuff["full_proto"] + + self.data +=3D f'.TH "{self.modulename}" 9 "{out_name}" "{self.man= _date}" "API Manual" LINUX' + "\n" + + self.data +=3D ".SH NAME\n" + self.data +=3D f"{prototype} \\- {args['purpose']}\n" + + self.data +=3D ".SH SYNOPSIS\n" + self.data +=3D f"{full_proto}\n" + + if args.other_stuff["default_val"]: + self.data +=3D f'.SH "Initialization"' + "\n" + self.output_highlight(f'default: {args.other_stuff["default_va= l"]}') + + for section, text in args.sections.items(): + self.data +=3D f'.SH "{section}"' + "\n" + self.output_highlight(text) + def out_typedef(self, fname, name, args): module =3D self.modulename purpose =3D args.get('purpose') diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/k= doc_parser.py index 500aafc50032..06bed1a12a45 100644 --- a/tools/lib/python/kdoc/kdoc_parser.py +++ b/tools/lib/python/kdoc/kdoc_parser.py @@ -64,7 +64,7 @@ type_param =3D KernRe(r"@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)= ", cache=3DFalse) # Tests for the beginning of a kerneldoc block in its various forms. # doc_block =3D doc_com + KernRe(r'DOC:\s*(.*)?', cache=3DFalse) -doc_begin_data =3D KernRe(r"^\s*\*?\s*(struct|union|enum|typedef)\b\s*(\w*= )", cache =3D False) +doc_begin_data =3D KernRe(r"^\s*\*?\s*(struct|union|enum|typedef|var)\b\s*= (\w*)", cache =3D False) doc_begin_func =3D KernRe(str(doc_com) + # initial " * ' r"(?:\w+\s*\*\s*)?" + # type (not captured) r'(?:define\s+)?' + # possible "define" (not cap= tured) @@ -927,6 +927,58 @@ class KernelDoc: self.output_declaration('enum', declaration_name, purpose=3Dself.entry.declaration_purpose) =20 + def dump_var(self, ln, proto): + """ + Store variables that are part of kAPI. + """ + VAR_ATTRIBS =3D [ + "extern", + ] + OPTIONAL_VAR_ATTR =3D "^(?:" + "|".join(VAR_ATTRIBS) + ")?" + + sub_prefixes =3D [ + (KernRe(r"__read_mostly"), ""), + (KernRe(r"__ro_after_init"), ""), + (KernRe(r"(?://.*)$"), ""), + (KernRe(r"(?:/\*.*\*/)"), ""), + (KernRe(r";$"), ""), + (KernRe(r"=3D.*"), ""), + ] + + # + # Store the full prototype before modifying it + # + full_proto =3D proto + + # + # Drop comments and macros to have a pure C prototype + # + for search, sub in sub_prefixes: + proto =3D search.sub(sub, proto) + + proto =3D proto.rstrip() + + # + # Variable name is at the end of the declaration + # + + r=3D KernRe(OPTIONAL_VAR_ATTR + r"\w.*\s+(?:\*+)?([\w_]+)\s*[\d\]\= []*\s*(=3D.*)?") + if not r.match(proto): + self.emit_msg(ln,f"{proto}: can't parse variable") + return + + var_type =3D r.group(0) + declaration_name =3D r.group(1) + default_val =3D r.group(2) + if default_val: + default_val =3D default_val.lstrip("=3D").strip() + + self.output_declaration("var", declaration_name, + full_proto=3Dfull_proto, + var_type=3Dvar_type, + default_val=3Ddefault_val, + purpose=3Dself.entry.declaration_purpose) + def dump_declaration(self, ln, prototype): """ Stores a data declaration inside self.entries array. @@ -938,6 +990,8 @@ class KernelDoc: self.dump_typedef(ln, prototype) elif self.entry.decl_type in ["union", "struct"]: self.dump_struct(ln, prototype) + elif self.entry.decl_type =3D=3D "var": + self.dump_var(ln, prototype) else: # This would be a bug self.emit_message(ln, f'Unknown declaration type: {self.entry.= decl_type}') --=20 2.52.0 From nobody Thu Dec 18 09:23:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3667F34BA54; Tue, 16 Dec 2025 14:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895185; cv=none; b=bAUxR4k+lL0SSDGaLTDK6YuwUSNUJA7ojGdPewfdfZC6NK/cp6reldw7RuoqYxnlufUHw+K5OFNic2nRijdGQyRGTlal2ZjyhaWFPFXGhH9l/hXPMtVCF5RawCc6kEzzkEmT/lr+tlSi6PU6x0wu2JO0ep9A6D7VPJvXY3eayIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895185; c=relaxed/simple; bh=NGjJSzPHUhLrxbgjeCgA2jiaySSHpT2Q4b/PjRan67U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MDAgBLXUx3zEEaw4rU+XC2rM/Zu7D0myn+bD/Zp1CreA2NCS3gPlP7necEIAbVc2sfJuQCi7Z4Qic81hqjfYTQlFEV/TLIoaDvtv0NQ+d0ueo4/0GpxcVgnTDHnD2l/nhanu+akMq9NjAtkDNiVPyOqCsTDPl7Wjn5/jLrZlgyg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q5WwbdsE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q5WwbdsE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9199C4CEF5; Tue, 16 Dec 2025 14:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765895184; bh=NGjJSzPHUhLrxbgjeCgA2jiaySSHpT2Q4b/PjRan67U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q5WwbdsE/K0OG7NIAv8XijYPMHpv9OxMzE7s53Nh7bvPiQmXH7N96Q/RZ6fVajZ5c U/0TIvFqUILi8n2bKc83SfyvVI0JLtEBYr+HmkwzT4RJF30+NktKLaeLl6OGyoWWO3 M+YXRCreLYWlyucxeZVTYAgovAftGkabLMexAflzQasXF9xh4sLGArMp9L+ryN/M1h oVrs0pyDPHg/uOpHFjHG06tVZjdwNUZeUNTlREzgFVb6jraIXP+wupza7BpcMkmUGU TD4o/MYTr58Z5AQzAtpDNXqqPkSc3d+4FcXndl+hSDu2CBH/STZf+aEeAhYnsN4WP5 F3epAUx0IIXWA== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVW0N-00000000stQ-059y; Tue, 16 Dec 2025 15:26:23 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v7 2/6] kernel-doc: add support to handle DEFINE_ variables Date: Tue, 16 Dec 2025 15:26:13 +0100 Message-ID: <757a45100cfc493984574ff780aa9d90506eecb4.1765894964.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Improve the parser and output plugin to work with macros, adding support for the common pattern of using DEFINE_* to create variables. Signed-off-by: Mauro Carvalho Chehab --- tools/lib/python/kdoc/kdoc_output.py | 5 ++--- tools/lib/python/kdoc/kdoc_parser.py | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tools/lib/python/kdoc/kdoc_output.py b/tools/lib/python/kdoc/k= doc_output.py index 50aedbb3d6de..d2bf94275d65 100644 --- a/tools/lib/python/kdoc/kdoc_output.py +++ b/tools/lib/python/kdoc/kdoc_output.py @@ -486,7 +486,7 @@ class RestFormat(OutputFormat): =20 self.lineprefix =3D " " =20 - self.data +=3D f"\n\n.. c:macro:: {name}\n\n{self.lineprefix}{full= _proto}\n\n" + self.data +=3D f"\n\n.. c:macro:: {name}\n\n{self.lineprefix}``{fu= ll_proto}``\n\n" =20 self.print_lineno(ln) self.output_highlight(args.get('purpose', '')) @@ -801,13 +801,12 @@ class ManFormat(OutputFormat): =20 def out_var(self, fname, name, args): out_name =3D self.arg_name(args, name) - prototype =3D args.other_stuff["var_type"] full_proto =3D args.other_stuff["full_proto"] =20 self.data +=3D f'.TH "{self.modulename}" 9 "{out_name}" "{self.man= _date}" "API Manual" LINUX' + "\n" =20 self.data +=3D ".SH NAME\n" - self.data +=3D f"{prototype} \\- {args['purpose']}\n" + self.data +=3D f"{name} \\- {args['purpose']}\n" =20 self.data +=3D ".SH SYNOPSIS\n" self.data +=3D f"{full_proto}\n" diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/k= doc_parser.py index 06bed1a12a45..aaa352855717 100644 --- a/tools/lib/python/kdoc/kdoc_parser.py +++ b/tools/lib/python/kdoc/kdoc_parser.py @@ -949,12 +949,27 @@ class KernelDoc: # Store the full prototype before modifying it # full_proto =3D proto + declaration_name =3D None + + # + # Handle macro definitions + # + macro_prefixes =3D [ + KernRe(r"DEFINE_[\w_]+\s*\(([\w_]+)\)"), + ] + + for r in macro_prefixes: + match =3D r.search(proto) + if match: + declaration_name =3D match.group(1) + break =20 # # Drop comments and macros to have a pure C prototype # - for search, sub in sub_prefixes: - proto =3D search.sub(sub, proto) + if not declaration_name: + for r, sub in sub_prefixes: + proto =3D r.sub(sub, proto) =20 proto =3D proto.rstrip() =20 @@ -968,14 +983,16 @@ class KernelDoc: return =20 var_type =3D r.group(0) - declaration_name =3D r.group(1) + + if not declaration_name: + declaration_name =3D r.group(1) + default_val =3D r.group(2) if default_val: default_val =3D default_val.lstrip("=3D").strip() =20 self.output_declaration("var", declaration_name, full_proto=3Dfull_proto, - var_type=3Dvar_type, default_val=3Ddefault_val, purpose=3Dself.entry.declaration_purpose) =20 --=20 2.52.0 From nobody Thu Dec 18 09:23:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7999834C155; Tue, 16 Dec 2025 14:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895185; cv=none; b=YWX/h6w0gIR2zMiTsmAtmMeWoMfiSQGC2pXF6Mi9OMrGoUwSHUdQcmETQwsEsTHXJMpiQDJJLDB5DnvirrjUTTDoYc5Ql4L44OxD2cYlogsj8jKD061qOu1wpVfDTGrhgN4he8gU4U1vsoxPJ/cbCAg3TFXLLhSP80QcDKWZpms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895185; c=relaxed/simple; bh=VVgdng7M0JzhwueoxHr8KaGzLmH+L+ByH2S75VMJM9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dlBi23SJSx7l2M3U17H796jIHGsBB/awMJp8y7OWKG+Ga1qaE3OMyJ5DPBf6/pP486swN0ZBhH/hrNC5z2vWaAYKnsh814PR3fc5e2zd3h2p7uH5v2B0xLKImzy5meemBfq0eFdASjJMgKOYXrb3G0NOuVrsfu2Wy3ehf8n58eo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AWbLLbAv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AWbLLbAv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52381C4CEF1; Tue, 16 Dec 2025 14:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765895185; bh=VVgdng7M0JzhwueoxHr8KaGzLmH+L+ByH2S75VMJM9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AWbLLbAvamySnCpOWcicu38aIvPshSauKTqfJJLewRrof7mvNyr9A0ki/uQjYCCH8 725sGjHZY7UMmEfKHM42w3jqXyr7Wyb63LLGZBKJxqxayJAwQ09hg6oHdN1UO45pLL IhfF5l/k9xS8U1kh7tme8bAJ978ETeD4So9Crvyv+QPl/k9lic/7uRbzj8CQFmj+c0 7t6haqgkmg/RfLhba1WEkrJgkoybMCfuH8xnWLnePaJoxpcTY9kbw5oWLTQnJNkE5a HdA16U+ae5RuzRRPlOHzqenOOdnYs7aom5MaI+taWW75hXIEVn2MgOeUtvMjeEf0HC OLUlYBH9WpZEg== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVW0N-00000000sub-1llu; Tue, 16 Dec 2025 15:26:23 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Randy Dunlap" , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v7 3/6] docs: media: v4l2-ioctl.h: document two global variables Date: Tue, 16 Dec 2025 15:26:14 +0100 Message-ID: <8ebe25ff579962fec09b586f00e77fae7802985f.1765894964.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The media kAPI has two global variables at v4l2-ioctl.h. Document them. Acked-by: Randy Dunlap Tested-by: Randy Dunlap Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-ioctl.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index 6f7a58350441..54c83b18d555 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -663,7 +663,22 @@ void v4l_printk_ioctl(const char *prefix, unsigned int= cmd); struct video_device; =20 /* names for fancy debug output */ + +/** + * var v4l2_field_names - Helper array mapping ``V4L2_FIELD_*`` to strings. + * + * Specially when printing debug messages, it is interesting to output + * the field order at the V4L2 buffers. This array associates all possible + * values of field pix format from V4L2 API into a string. + */ extern const char *v4l2_field_names[]; + +/** + * var v4l2_type_names - Helper array mapping ``V4L2_BUF_TYPE_*`` to strin= gs. + * + * When printing debug messages, it is interesting to output the V4L2 buff= er + * type number with a name that represents its content. + */ extern const char *v4l2_type_names[]; =20 #ifdef CONFIG_COMPAT --=20 2.52.0 From nobody Thu Dec 18 09:23:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CA2234CFC6; Tue, 16 Dec 2025 14:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895186; cv=none; b=VS+BodVO5HLw3pE0fOYcewA+Bm7Cs83Jiom9p55BPBo3eTsiMdGl7vk6GYPh1TdnCGxYtQCFz+6X57D1616hYXxQwbb73EMu2ijPP2lJjn6GfZnutPDL8PLiLgmX1n+XtGvJMnP++gqH6BWphGDsHk2cmRhyD8lHPM62QurZM9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895186; c=relaxed/simple; bh=rnTwv2cFqokhQ8w4FIjECmjXqxObhLiO6X9QzGmpU3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qI2BzweAqM6W3fOtcxgYsXeUL7LdIwabUMElmAUlhGWVXZIlbFNlABId/qYMd/NQkKNaib0MxkXtLwGGVC8FPjcWsodEVT9mRsUdC6QjHOy9hIWJVgt1Z18rtt4Br6Qcpr8NwCtwaZUpnCKo0OBBL49g+vqBavJyELSFALzxGcY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AGgqmf3m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AGgqmf3m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5BB2C4CEF5; Tue, 16 Dec 2025 14:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765895185; bh=rnTwv2cFqokhQ8w4FIjECmjXqxObhLiO6X9QzGmpU3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AGgqmf3mn3bvRjJCarRxRj4LYy1vl+AZin7aFU20FZBMnaDL+xg/YD6z9csdszn3e n+PdKylbL2PEmFjNrKyege+dmwFtXffKCnwHl9UpT6q1VX2coVixgwuUpBsTaQp8LD J2+R2u3BKgvUSWsjkYGGxgbXj8g8M5I+lKT4a6h+F2enAyuRHAKezTMWH4Az+zsDWT W+KE/7H2lIYSfJLi0pcErnThneDLas4qzOZe3WLETb7sH1diJOMHZmW7Otv4uhOETW DcC18xJsvAKCX0YR5d3H05Pl/n341+zeaeSOwyEyrdstan0oF5uPsQwBclDCTK9gRT gigw7qgFF2Q9w== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVW0N-00000000svm-47A3; Tue, 16 Dec 2025 15:26:23 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v7 4/6] docs: kernel-doc.rst: don't let automarkup mangle with consts Date: Tue, 16 Dec 2025 15:26:15 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" This document contains several words that tricks automarkup. Ensure that all of them will be inside a ``const`` markup, avoiding automarkup to touch them. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Randy Dunlap --- Documentation/doc-guide/kernel-doc.rst | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Documentation/doc-guide/kernel-doc.rst b/Documentation/doc-gui= de/kernel-doc.rst index fd89a6d56ea9..2e18a810f98b 100644 --- a/Documentation/doc-guide/kernel-doc.rst +++ b/Documentation/doc-guide/kernel-doc.rst @@ -174,7 +174,8 @@ named ``Return`` (or ``Returns``). Structure, union, and enumeration documentation ----------------------------------------------- =20 -The general format of a struct, union, and enum kernel-doc comment is:: +The general format of a ``struct``, ``union``, and ``enum`` kernel-doc +comment is:: =20 /** * struct struct_name - Brief description. @@ -187,8 +188,8 @@ The general format of a struct, union, and enum kernel-= doc comment is:: */ =20 You can replace the ``struct`` in the above example with ``union`` or -``enum`` to describe unions or enums. ``member`` is used to mean struct -and union member names as well as enumerations in an enum. +``enum`` to describe unions or enums. ``member`` is used to mean ``struct= `` +and ``union`` member names as well as enumerations in an ``enum``. =20 The brief description following the structure name may span multiple lines, and ends with a member description, a blank comment line, or the @@ -201,7 +202,7 @@ Members of structs, unions and enums should be document= ed the same way as function parameters; they immediately succeed the short description and may be multi-line. =20 -Inside a struct or union description, you can use the ``private:`` and +Inside a ``struct`` or ``union`` description, you can use the ``private:``= and ``public:`` comment tags. Structure fields that are inside a ``private:`` area are not listed in the generated output documentation. =20 @@ -273,11 +274,11 @@ It is possible to document nested structs and unions,= like:: =20 .. note:: =20 - #) When documenting nested structs or unions, if the struct/union ``foo= `` - is named, the member ``bar`` inside it should be documented as + #) When documenting nested structs or unions, if the ``struct``/``union= `` + ``foo`` is named, the member ``bar`` inside it should be documented = as ``@foo.bar:`` - #) When the nested struct/union is anonymous, the member ``bar`` in it - should be documented as ``@bar:`` + #) When the nested ``struct``/``union`` is anonymous, the member ``bar`= ` in + it should be documented as ``@bar:`` =20 In-line member documentation comments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -319,7 +320,7 @@ on a line of their own, like all other kernel-doc comme= nts:: Typedef documentation --------------------- =20 -The general format of a typedef kernel-doc comment is:: +The general format of a ``typedef`` kernel-doc comment is:: =20 /** * typedef type_name - Brief description. @@ -432,8 +433,8 @@ Domain`_ references. Typedef reference. =20 ``&struct_name->member`` or ``&struct_name.member`` - Structure or union member reference. The cross-reference will be to the = struct - or union definition, not the member directly. + ``struct`` or ``union`` member reference. The cross-reference will be to= the + ``struct`` or ``union`` definition, not the member directly. =20 ``&name`` A generic type reference. Prefer using the full reference described above @@ -537,7 +538,7 @@ identifiers: *[ function/type ...]* Include documentation for each *function* and *type* in *source*. If no *function* is specified, the documentation for all functions and types in the *source* will be included. - *type* can be a struct, union, enum, or typedef identifier. + *type* can be a ``struct``, ``union``, ``enum``, or ``typedef`` identifi= er. =20 Examples:: =20 --=20 2.52.0 From nobody Thu Dec 18 09:23:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CF2534D4DF; Tue, 16 Dec 2025 14:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895186; cv=none; b=ByueVtS+LmR40yOtXdV00LT0kBvYIH0nZeoD6YerDVSh16KCuD3BwikGxagrphv9TZKs4ab6/mGab2tKDbyAixXoR7j1rUROdensFgZwEnnF7BnrOXRVmsGmWaZ7pXGgrZ24d6sV0Mz3DD8oNjN2sTrGZAIuyrGN7sFOoo30uaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895186; c=relaxed/simple; bh=UB2o82o87HHa9AtHwJBPazCyg8AVw8kzw99ZHsm4WaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DHdbnLNYA9vlpx1naOtQ4rowu7KBazQ9vbem4X9WVkQxVZfNevm1P25G7qYgUd3iBp9By1/N3i0DgiL6UFkhyy+zTczsLCQg8M8iQQ/jgd9M8LOG5M5VsAMkHpndsk9RgTkVAuX44Fib/+ugKXS0H1HMTJpuRY9j0tfrX21/Ul4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pQvuOZLO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pQvuOZLO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 175CEC4CEF1; Tue, 16 Dec 2025 14:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765895186; bh=UB2o82o87HHa9AtHwJBPazCyg8AVw8kzw99ZHsm4WaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pQvuOZLOVf0dwIK7B9/4YLGOxmwnJUn7rQPBfuJmMFEm4A0Sw3IsTNlhH7SXcmi40 LMxVUKNx9aXK1FM93IXwxBjdT3JPHczYiSg3MswSz8CZN3bAagtgZDCCWdhzz4Ebgn 8rpaZigDcGxiH/rfX3rJizYYRKpaFUfnXwB2bqg3G0zzUZNH9e9oImJRQXIhnKM7NP rgQt/2ES9P8TPYzB2/BZNv8RoEtdyZZ6cA3Ne0Gd5MYD60BJOBUI1CIo1/L7pQiAqx LNYXYFnFdFMEf5A9V9Qd96vCrfyJEFtC5zn/gA2dULMJnuAxhTVzKV0AmsMmJ0Tczp E9yIsRxTu3BzQ== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVW0O-00000000swy-1Vqw; Tue, 16 Dec 2025 15:26:24 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v7 5/6] docs: kernel-doc.rst: document the new "var" kernel-doc markup Date: Tue, 16 Dec 2025 15:26:16 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Add a description containing the new syntax to document variables within kernel-doc markups. Reviewed-by: Randy Dunlap Signed-off-by: Mauro Carvalho Chehab --- Documentation/doc-guide/kernel-doc.rst | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Documentation/doc-guide/kernel-doc.rst b/Documentation/doc-gui= de/kernel-doc.rst index 2e18a810f98b..0de0e344e10d 100644 --- a/Documentation/doc-guide/kernel-doc.rst +++ b/Documentation/doc-guide/kernel-doc.rst @@ -342,6 +342,18 @@ Typedefs with function prototypes can also be document= ed:: */ typedef void (*type_name)(struct v4l2_ctrl *arg1, void *arg2); =20 +Variables documentation +----------------------- + +The general format of a kernel-doc variable comment is:: + + /** + * var var_name - Brief description. + * + * Description of the var_name variable. + */ + extern int var_name; + Object-like macro documentation ------------------------------- =20 @@ -463,14 +475,18 @@ through the following syntax:: =20 For further details, please refer to the `Sphinx C Domain`_ documentation. =20 +.. note:: + Variables aren't automatically cross referenced. For those, you need to + explicitly add a C domain cross-reference. + Overview documentation comments ------------------------------- =20 To facilitate having source code and comments close together, you can incl= ude kernel-doc documentation blocks that are free-form comments instead of bei= ng -kernel-doc for functions, structures, unions, enums, or typedefs. This cou= ld be -used for something like a theory of operation for a driver or library code= , for -example. +kernel-doc for functions, structures, unions, enums, typedefs or variables. +This could be used for something like a theory of operation for a driver or +library code, for example. =20 This is done by using a ``DOC:`` section keyword with a section title. =20 @@ -538,7 +554,8 @@ identifiers: *[ function/type ...]* Include documentation for each *function* and *type* in *source*. If no *function* is specified, the documentation for all functions and types in the *source* will be included. - *type* can be a ``struct``, ``union``, ``enum``, or ``typedef`` identifi= er. + *type* can be a ``struct``, ``union``, ``enum``, ``typedef`` or ``var`` + identifier. =20 Examples:: =20 --=20 2.52.0 From nobody Thu Dec 18 09:23:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D658734D934; Tue, 16 Dec 2025 14:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895186; cv=none; b=NT6dt03QoPVntZqmMm+wtSa/OgEnKgFY86HLhlLbjz6t393+KZJl2Oov2JDkTCrfoGYThC6RGHrF8B0VsfqpCFvAK3tk/4KWStTwb91vgZPnA5namMSOmKYHkN2ZsuLiwqOTF8Bu0myicnymUkq9xIItW98sU7G5YU1yPFSRHTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895186; c=relaxed/simple; bh=V3q0OW77JHsfRVR1rTc4eyv6RLc6cSrB8gvXSOLS46Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fwdgoh7DKRPRYSbM3P4CAhv81vmxamh6AUtmKEvnuloENIX9polLBiDlrZcCAZCjA1cmT6vnO0Rh6MM5Caq32rU50CvK1igwLFYer/CvkoAi1WN/sNxRIpx1fiEzJTDm7D6cyNBG3N9gqGpBGtNIPNc+Vs4zoiT+XWY2UpLxEdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fXfwIuHe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fXfwIuHe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E468C19423; Tue, 16 Dec 2025 14:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765895186; bh=V3q0OW77JHsfRVR1rTc4eyv6RLc6cSrB8gvXSOLS46Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fXfwIuHeMj0XhngTQfhH2LLKaJhEOkFBCU1goraFJwFGZIlg3viURjPjGYlfxpOOG mkD8HNp3SwOh6CASAMmF++l+R5Gl4qRW7za+ie0FHMPkqDcKx/Z9hsElzjMQbyyh3I w35ZV3OnvUztpboHckjaiHTgbeZKyByyX9n3aotoQKZqCUDSXwZaVL3vUfE252lNzk 12GbHGVg0rFDom2OF0i/Aea59s8M5OwvU2LNGYJa4REAEJ/3eD7nsrspnEkX5cbXzf 5CjJWOumBVtsa16oayXojIocHM2YdnBpHw/lrGDUYFwnJklNLU0IiqWYcSJmx74Wv9 54tew7sJ1EgjA== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVW0O-00000000syA-32vm; Tue, 16 Dec 2025 15:26:24 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v7 6/6] docs: kernel-doc.rst: Parse DEFINE_ macros without prefixes Date: Tue, 16 Dec 2025 15:26:17 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Currently, the logic for vars require a type DEFINE_foo(); where type is usually "static". Make the logic more generic. Reported-by: Randy Dunlap Closes: https://lore.kernel.org/linux-doc/e1dad7e4-a0ca-4be6-a33c-97b75175c= 12f@infradead.org/ Signed-off-by: Mauro Carvalho Chehab --- tools/lib/python/kdoc/kdoc_parser.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/k= doc_parser.py index aaa352855717..e137bd9a7dac 100644 --- a/tools/lib/python/kdoc/kdoc_parser.py +++ b/tools/lib/python/kdoc/kdoc_parser.py @@ -977,17 +977,23 @@ class KernelDoc: # Variable name is at the end of the declaration # =20 + default_val =3D None + r=3D KernRe(OPTIONAL_VAR_ATTR + r"\w.*\s+(?:\*+)?([\w_]+)\s*[\d\]\= []*\s*(=3D.*)?") - if not r.match(proto): + if r.match(proto): + if not declaration_name: + declaration_name =3D r.group(1) + + default_val =3D r.group(2) + else: + r=3D KernRe(OPTIONAL_VAR_ATTR + r"(?:\w.*)?\s+(?:\*+)?(?:[\w_]= +)\s*[\d\]\[]*\s*(=3D.*)?") + if r.match(proto): + default_val =3D r.group(1) + + if not declaration_name: self.emit_msg(ln,f"{proto}: can't parse variable") return =20 - var_type =3D r.group(0) - - if not declaration_name: - declaration_name =3D r.group(1) - - default_val =3D r.group(2) if default_val: default_val =3D default_val.lstrip("=3D").strip() =20 --=20 2.52.0