From nobody Thu Dec 18 15:03:37 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 35F272C027A; Tue, 16 Dec 2025 14:19:38 +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=1765894779; cv=none; b=a4o9N584QR2CN+Jc7SE1BDSMFhmX18I8CC5vdU8uZ8DpFw7IJq+zGs2LSbod9a48XKWtDFRJfXvQlGYuYynUKLl6KF0xo76TomBGzMOdIxoOZtN+m4qOsU9DxR7vRhfOMNCji0WhYa+gMuQlMm3i7GTQI0BOd6JNi0Ae50NYbzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765894779; c=relaxed/simple; bh=D5Dan+chdaKCsHfpLGspv1TIRzMfinLgSlG6JG25Zz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QpaDZvm0294rb8N3DPqUda4u9q0SUildVraKSeACuQGIxvWaDR2FjVfCJ/OJqUmZ3QVwd1aJCkoSYnCKSw+Ntj31MT0EiCjrnmXTgM7d5tu2MvkM6em9BmwTwa0k/cApLgjvLdng3h1ePDyM05Pu9HkH3KTHAnFQIbA6hW8Bxog= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LASO9bJ0; 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="LASO9bJ0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABA99C19422; Tue, 16 Dec 2025 14:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765894778; bh=D5Dan+chdaKCsHfpLGspv1TIRzMfinLgSlG6JG25Zz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LASO9bJ0ewDjVZ+y+axcsBfy8duZ0C2qL+9VcUwDbkF5CYz0uSvSWs3D2vHQ5AmeH pMcLPwaPq7tML1L7sqVC6OBPwxL7jDUjkJmErJXT1YxHjR+eR9UunK9KMn2DfoG71r 4t4GHBATqKZRZAef79VQ0El33qrYZe8OtsRzKK1a0PWot9/FNytps2Z7a0p9EgIrdJ cLEWS0rURuC/ltpGtVlpKaJMr/6mqJeKr6cRQM1AGEo16Ybb9x79wALsmZbzi2MiL/ SQn1rRe+UXbl8OxMrUyvzIfVrlSQuMq3Hw2FHN/8Du63+6tzdDSUxTrGs+dgO1EwOF vxgsn5BTaTMFg== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVVto-00000000sQU-3rdD; Tue, 16 Dec 2025 15:19:36 +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 v6 1/6] kernel-doc: add support for handling global variables Date: Tue, 16 Dec 2025 15:19:23 +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 15:03:37 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 908DF2C2343; Tue, 16 Dec 2025 14:19:39 +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=1765894779; cv=none; b=iIJLOORci7voLJpFubLjlTH37MCZVaNQniGrIcUEmG8u6DD16ck8wXR+VrobrpdQ0NjwBqLRpp7rhpdW0PkirxrGMQL3zP/e2HmFsolRR7TPXb8ArqYXrjWnqthWd2VFKTR7pqRSg34Y9BUqxlBSrtaM0DGrhff4+tWGf/1yG6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765894779; c=relaxed/simple; bh=NGjJSzPHUhLrxbgjeCgA2jiaySSHpT2Q4b/PjRan67U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r8isvdcIQQfHTmG/elR8tvaA5hLtjwyAvpySvMjbGl22DCWIjaraC19SfBBT/h2vcKe2eAiRDm3OqQmvFVT3TbICNSPCHboZ8YhDZIp74nAlARUVuykOHyP2SaQi2c4+Ild2fzPO96Q0V/xQyFrWInsNxWP/DxLW6qVZWbDv7dk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ih32hZy2; 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="Ih32hZy2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19EF0C4CEF5; Tue, 16 Dec 2025 14:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765894779; bh=NGjJSzPHUhLrxbgjeCgA2jiaySSHpT2Q4b/PjRan67U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ih32hZy2NMeiMnKdTY5+YicwHWn4JqpOpeLU4Gg/dZs/1rl1st+Xvck9TbQLamu7e qUzq46auSvgvjpYr8MSb8p2TKfpkiINJmO6FuL7bYopitg5etdfb8OHRsWOJwTMDhJ +wH76c6sX6ywS3dXioFLqylSu8M15dL+YRuRDj8/0oe3vkrP5oqg/Z/+/1wjZHPqgq NS0qTBN2tyM4EpU6r8RPLQXTKA4rdpCHtcJZyarpfKel+RWoHcMZNk4leqvFYKMplw HLxoWZ40FY4zOkzjFMp5Ard881++8EudcQAu8zfRWr998iPbcK8wWqtyFgvHmWF1ZI G6mkVgbpFiG+g== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVVtp-00000000sRf-0tiE; Tue, 16 Dec 2025 15:19:37 +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 v6 2/6] kernel-doc: add support to handle DEFINE_ variables Date: Tue, 16 Dec 2025 15:19:24 +0100 Message-ID: <757a45100cfc493984574ff780aa9d90506eecb4.1765894670.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 15:03:37 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 E765D2D193F; Tue, 16 Dec 2025 14:19:39 +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=1765894780; cv=none; b=Fj5NYxhv/7iOJeg479Atp+KJhAEQXOf0P00HDNpDfqmBBpfZ8Mb738t1STl0wTRyoym2dHCXtNkTZeoVM8+CWjyaK5QK+YV3jUaAyQp98NWHkL9cZ8aN9YH3hsC7NTdugjELgqRTOf7+ucRohlm7YfYIswN+xd8TVPjUa/ti090= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765894780; c=relaxed/simple; bh=VVgdng7M0JzhwueoxHr8KaGzLmH+L+ByH2S75VMJM9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BN3jg4fWEipAtemu8samoIj4ZmjhlMPDfXQakId9iKKXqXG3WLaMpFQfr+gEK+vF9TItNQrZvvSO5ybxTDiWp3V+pGg8aXUNYaA1TsznDc/cXUGzhKfW5AkyztIq0w51lFkbY/3vzGkyzAWvu7gDQ4Xyt2go5lwhkVqiW9M9VYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RzhC5oXy; 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="RzhC5oXy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 723EDC4CEF1; Tue, 16 Dec 2025 14:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765894779; bh=VVgdng7M0JzhwueoxHr8KaGzLmH+L+ByH2S75VMJM9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RzhC5oXyAWN+5eW3siLBYnKoCk7kMGL8wOvSwvHKbsRYQ21CGONtjmJspAdRpDv6V s9AmJteJAEzn0+Xro/dHGtTE+9gFQqCbvhOmzorMXCVMP0gxVVA5owU9AS1aZF3lQY T088NY5NMvgxOCdfwy+/TgwzJddHWmlFNaq3tTSXwti47TSH5OA/nCUOEmdPyOVoWp jO2Nk0w12TurIbZu0qKgSTGiDxrk6IkZ9xmMU2FSN/4GYUuB9/aj+hj/18fb9zc+NA 3b5T01S6GdaGBm9h4mWz/XOe2EOcx5K68KktXUWrI8ap0pVF3swHOVBJx203qOc9e9 XkvWtUWZgWDwQ== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVVtp-00000000sSq-2He8; Tue, 16 Dec 2025 15:19:37 +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 v6 3/6] docs: media: v4l2-ioctl.h: document two global variables Date: Tue, 16 Dec 2025 15:19:25 +0100 Message-ID: <8ebe25ff579962fec09b586f00e77fae7802985f.1765894670.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 15:03:37 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 049B42D1F7C; Tue, 16 Dec 2025 14:19:40 +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=1765894780; cv=none; b=qfWe4c8Uchv+MSeLCHY8qKQCt9k7G6/FpzD57XMZeHex+FDuknuiYoKSwIoRr8vD3BbmRDmZL8zaJ1HuVwPw3OTE6tQ/wcIze+q9bGMl9QKq19HrSf0ixnOrT/woZbNJrChP0Thx0W8+FOui6tfkuOmhJ4QVy0P6FsA64y86lnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765894780; c=relaxed/simple; bh=rnTwv2cFqokhQ8w4FIjECmjXqxObhLiO6X9QzGmpU3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J+b45AjSsJ+LZDgXWupw7iIgPJkuQChFmWHTxiV80C35qS2RI/ah1tVnoEk/395+i8vyAb2WTC85kX/NM8bir4v3x15IXPM56oS3/Ne+JycjMsep07B4yDRrOpj096Su45mq79Rj8nYDTljQI0xMyxneby7fbEScTKwRZ7gQRfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M9afdder; 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="M9afdder" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D43B5C4CEF5; Tue, 16 Dec 2025 14:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765894779; bh=rnTwv2cFqokhQ8w4FIjECmjXqxObhLiO6X9QzGmpU3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M9afdder3fSOdXdjr2c9t7YxQJZ5TICfdh0RhOvvgpL0aSANK1ViUb/umhlIaSWG8 DyVQrG9OChPZZqCCVFeLnphx0UFsBMFXoJYjRJxfx3Pk8Obdryy5sN2sx/SL8xp1tF S/pFDg4kbuIazgAaGos//8tv0kfSgPTDG2DBBjEJDL5RDetpU6vWhISRw8jBmoZ45b Ov5gbHOtvspiJwIVABz0cA5uRimhxEppBXR9D97/NQH7ic69CxsYYIFPSeSoptYxk9 OkVxLmaCK84xxS14D2X3s94DJdl0Y05tGJs8dG/vScHC8VOTpxl2JdOoNOB+QfyJAQ rg89bf8CkgAfg== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVVtp-00000000sU1-45r2; Tue, 16 Dec 2025 15:19:37 +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 v6 4/6] docs: kernel-doc.rst: don't let automarkup mangle with consts Date: Tue, 16 Dec 2025 15:19:26 +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 15:03:37 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 841B32D641C; Tue, 16 Dec 2025 14:19:40 +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=1765894780; cv=none; b=p7839BZMo9IldzzsmDHbXMRBEldT2aD7LTtThhhWOHCxgbzvQQcYEDJACsqm2GrW63ZTh1nfi4EqxJhNW1N3+l4/+8bF9c/Dsz85YdViplXJ3xW5pDTGdSv5Ic/HEdZpAd3XVWlklGpRlP8cjOvAlUcF0pW4t+I8tBMdy4YYXis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765894780; c=relaxed/simple; bh=LW+my7+Nosv4HMVpRcedr9bi+/i8Tx3j1/Iz4nIDNOI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C0Ebe/G3942DkMYJc9ku1rqoz4QmkuSWphtIj5x8YveYQxns/prKN42/DlEd5zgOZPS8x33PZAY5Ha7P/UaaImpQ0jTDNTELqSagfkFSKYhuJkrVwYYbZND08LnsXR1WXx5ju7w4E4OjlgWH2027PvJat+chIEfX2Jfxzgwtvcc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YButqyMy; 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="YButqyMy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F31DC4CEF5; Tue, 16 Dec 2025 14:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765894780; bh=LW+my7+Nosv4HMVpRcedr9bi+/i8Tx3j1/Iz4nIDNOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YButqyMyojwZimpQsHmdp2sPviAv6ihgEij+xONl2KdTQqmvScYzRveRT98MpAycT gs2kMZ+5vsefFRjwg42lY8aQHtdiNVJSYfEYdVg1FtI7g7ohWhQDdDzJXVK/RDhNeq 2kuMPdu8CD3ZIZy6bjODRZ/7SKs0kIFbBrndYu6TNhEGR0VxVrnOySygDCNAstzIKe hL7qcK9X/A2vrt1MoXVuRDwaPPcyJ5/qRKAzCxiDJSjEfUxw7Zi4i9iz3NAOireMGk jg5ZN2sF90pHLKgG97zhQFxxo10THJa/k60vxgMic+0bD7YW6hXUk1kZHk7YxID8sk hHHuZJR4nChzg== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVVtq-00000000sVC-1NTW; Tue, 16 Dec 2025 15:19:38 +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 v6 5/6] docs: kernel-doc.rst: document the new "var" kernel-doc markup Date: Tue, 16 Dec 2025 15:19:27 +0100 Message-ID: <1cddf44071c19fe3489e1db0b18bc779d2e8e212.1765894670.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" Add a description containing the new syntax to document variables within kernel-doc markups. 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 15:03:37 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 292F12D8382; Tue, 16 Dec 2025 14:19:40 +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=1765894781; cv=none; b=hMLjFAebDmOoSDt4BYow8OviNvYoYYEqNe+/W9BY4tPCHGfkoSgZjXF70TPArbN7zI6WtBFamxoqZcOOJPnDffk9j3+Eb+d7dJgrmFZ+VjySrw0jklMQcpHNqah6TXAO1C4EZdoFTXNNdC2I30CunZNwIoBkz4aCci2cLmaIx2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765894781; c=relaxed/simple; bh=D9Elma9t5b0gMah/+NSYAD1snetTLQ4VuKhuEdvqBe8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uYd7u+yl7VDxV/dzAvQkLy0HMs1sPuXCChK3UQYjslsTf+7Eea1TTna2/QYKC3M3iZ51QWW822uXuwZFlC8p/tOax4nLC+OlJ/8jwdu/ibwBnOD57O1dV+CuLunHCk8LO+wOjgGy1GIrPfemt0fppmzv67oh9ksOz6R50avIMlU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ukM6JyW5; 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="ukM6JyW5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86556C4CEF1; Tue, 16 Dec 2025 14:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765894780; bh=D9Elma9t5b0gMah/+NSYAD1snetTLQ4VuKhuEdvqBe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ukM6JyW5XNbfA16rDDHlJhALN3YAH1TKAY0oKuwQe7jkRvZnK8TEKOEyUXzfRHyqJ rjX6QlegNn77r6ncWAtM9o9t1XspBbczykh1uPfHZytZeNt5BkomtyBmVdFZR+7pxS FFeGBsLEzjjsgLIqzm8DvVhQHz2kr8vHlbW2v3IzCFKUm1QPfs6CiAZKt4KsP4QzTU KK2nNp1o3ysnOYYB2PXLFed3uNYaPentbZgcdkO1Cwh0MWcAEaqmG3iCt2HSwL8Syn gf8Pn0oTlFjFy3xD2tzqCv3JQXP2Gwg9I0dJP3Gz1kHRKxJebYIh0r0iXSDj7pvAE+ BF1dYvFHHj3JQ== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vVVtq-00000000sWN-2jod; Tue, 16 Dec 2025 15:19:38 +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 v6 6/6] docs: kernel-doc.rst: Parse DEFINE_ macros without prefixes Date: Tue, 16 Dec 2025 15:19:28 +0100 Message-ID: <90cefe3986a62061f1b962f05a97797db11ab027.1765894670.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" 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/ Reviewed-by: Randy Dunlap 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