From nobody Tue Dec 2 01:26:16 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 0292F2857C1; Sat, 22 Nov 2025 12:38:07 +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=1763815088; cv=none; b=TDT+zrBefAJJRde6jpNCZfKHIrCfGFaweVWE5m2FNkgueXRI1iKemkiEYOb3eEys89k2L7Xh4OG5dYvstOTQxgBBdfEXlFfyKZxvVW7J4CyoDpCHDaF9oAGIdiwpO8VCIAZeKQdzVbUFy0ACFPWCweEZXamhOiIAV4Ee8RQyGmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763815088; c=relaxed/simple; bh=3mMj2/bpTFkS1JYhOQCrsyMcgLS2GZpq30GUkfbjkfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dTRZg7158e8rDGgmAs0Qe/ExWAfGQ7Snag7Ugyz2AEME/kTJEsFv61ZjrbifnfCEB3qncbN6YFJy8BYDQJ8kYzt/ztWCkc613SKFsyNkJ0HqKBPoEgnKAfarqBvNJg5ASaz+3yPlNiuAr1bNqN7RU7knSnS9D189zzAulwlJWhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UR+EQDcI; 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="UR+EQDcI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 640EFC116C6; Sat, 22 Nov 2025 12:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763815087; bh=3mMj2/bpTFkS1JYhOQCrsyMcgLS2GZpq30GUkfbjkfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UR+EQDcI5GIc4YOZwdFEbVBmIdzDu91RkTp+wn/tRu8GEqmfNKQL5VXmHa6GxNWBv mxioVClgGtoUyubs7lMFfC7ZHmei+lj+6tgsX3R8Ik10bq03QRpS5owSw0xKp3LS1a Xvbggl3Xy0a18pOYmW0RBoB6yfTJCMoHz/DLdgiKpyt6MVI8n8C0JG9B6WChAyFpiM DIHZpJSnTJy638RA/amzPEInTjU/bQ9IPf/bshSS7/vYmWIZqENRcGuMH4ty166FLD hGmNDIHxnYagw9j4d+T86qYkoARfMBmgDzbnlDLcYohVPUMMRgHzY8jFnLXUAYig6W NzaeQU3PbKHgQ== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vMmsP-00000004pm2-2140; Sat, 22 Nov 2025 13:38:05 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , "Jonathan Corbet" Cc: Mauro Carvalho Chehab , "Mauro Carvalho Chehab" , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v4 1/5] kernel-doc: add support for handling global variables Date: Sat, 22 Nov 2025 13:37:55 +0100 Message-ID: X-Mailer: git-send-email 2.51.1 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 natice 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 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 14378953301b..8d811c2afaab 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 c0cc714d4d6f..edb0fb5330e0 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) @@ -924,6 +924,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. @@ -935,6 +987,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.51.1 From nobody Tue Dec 2 01:26:16 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 C415C1C860A; Sat, 22 Nov 2025 12:38:07 +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=1763815087; cv=none; b=iVNDw0h7jD5uOS9YnjBj7L2MyL/Xw8KSXPNFKRPQtloh3tkLak5V7dtK7K8RwQ0k/ZtCJZn4mZXUhz/+oVguMzx5vawiALfW9RQSTj8sBPYC+Un0x7EVP4bTipoHnHxx6pU0/Bd6RzD1qSqJJGyc7gmL80R/6b6CvCiCDuvtQdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763815087; c=relaxed/simple; bh=TwvR1MbqOEr/NW02G9o73v7ORLVCV0/ulknx4UAlhb0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lVt+I7uOL5ZB44NYSFbfGhwKPcpP+JlOwdqV1M/So3CBb3U3kTLCrFybZlDqRAD+3z3lkCkLdoWHoxeMqpn57dx6J8/M2aaRp1bt56bSKoS9FQ4GxdG4+yJDTFnuyqKSbcS8KVTiChQ5oxwjLPiOFfYAeWleldzuyC69F2h+SpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E+AWUPS1; 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="E+AWUPS1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62448C4AF0B; Sat, 22 Nov 2025 12:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763815087; bh=TwvR1MbqOEr/NW02G9o73v7ORLVCV0/ulknx4UAlhb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+AWUPS1wGziNemDvPZjmKNauSGUQ3/KOrSSb1l+VVECKpUpu/eAN71sbW0BdxPkv WFY0SjTK5qGLy48+16c2FBE1ZGi2WyRc9EdQaxf50Vu/PpiREB/xDgTqRHP6NsUhvS 6/6m0WAjd4bvglUePdcY91t99I0yuHDHf6uVmKPlgtwBBundmveL8OlY8tmwFzyz6Z YfM6sTBm3RfSgiN0bey74N3H9iS0TmQFrOA+pj+1fsJ0Yl1+GBRAs/gDd3oCFnNOYX SXypDhz9NwDnRjk6qwU0yxzyNZrGtGVo4gVq3poEE9XzIOtHKFjjKUavG9auOctQEA sofz3cxlbEvaw== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vMmsP-00000004pm9-2894; Sat, 22 Nov 2025 13:38:05 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , "Jonathan Corbet" Cc: Mauro Carvalho Chehab , "Mauro Carvalho Chehab" , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v4 2/5] kernel-doc: add support to handle DEFINE_ variables Date: Sat, 22 Nov 2025 13:37:56 +0100 Message-ID: X-Mailer: git-send-email 2.51.1 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 | 3 +-- tools/lib/python/kdoc/kdoc_parser.py | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tools/lib/python/kdoc/kdoc_output.py b/tools/lib/python/kdoc/k= doc_output.py index 8d811c2afaab..afb3f6d633fd 100644 --- a/tools/lib/python/kdoc/kdoc_output.py +++ b/tools/lib/python/kdoc/kdoc_output.py @@ -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 edb0fb5330e0..a3cd1bb0c8e7 100644 --- a/tools/lib/python/kdoc/kdoc_parser.py +++ b/tools/lib/python/kdoc/kdoc_parser.py @@ -946,12 +946,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 @@ -965,14 +980,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.51.1 From nobody Tue Dec 2 01:26:16 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 BCE511DDDD; Sat, 22 Nov 2025 12:38:07 +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=1763815087; cv=none; b=S/3POPoRBwJpJabplRpB2S42KVhSs+5FOwn7D8+1kNhWyYgkoL9AL3wslU6qGFZ6MiDVc6vxsemv7VG42ctWmNjXzG56+2PbEHS5ip/y1UAwu0mon+bmxTgscOqBx+cWsXj6mdNpUMxdkXX3On3kw9geyGqpRM7A5wnbMpJao0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763815087; c=relaxed/simple; bh=EHqiTl/gEFOctfX43h+L9XFYer9UoRGKk7O6CT/FANo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W5WVUNg/0hF402N/klqpLqQLI3YoUebeEks9Qsk/7pbYf5aCXF2nhyi3/KLPYjfHz4PFnl1IpCf7rRxSqjLm6FtagZbe/UM6bDo3RH6Q6XI31qirejthSEQKr8vo49oIePIG8He18jsfX8RDgdEQwoYJdV9Ws93cOwdqJdmQma4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GN+Vt+Lg; 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="GN+Vt+Lg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CDEDC116D0; Sat, 22 Nov 2025 12:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763815087; bh=EHqiTl/gEFOctfX43h+L9XFYer9UoRGKk7O6CT/FANo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GN+Vt+LgFN2f9wjxgOpTq9pYMB3Ob9rLqKVveeX4KCeYDwLCoYBJS3ng4V04GSYMh vbUDCvFjr5olUDgQPCFh5pqMp521X/eW8/WGwb3jjopXqqn4B+xlCU5UAhxf8Np80+ 0SQJapjuh/h2iQ27i3FOOJu299KTzL5FiLRLOL9AmLil6MmP+JVbaWZ3tu/vub8f5A sPN+nsHDyhaO58y99K0gX7v+PIESfVCHBrEf/X7Q9+vw6Yx0c+5tiFKBg3NxIpm4SR e7MPjObN9DN863JUX5dvysNabjsJT36S3KmIv24R8v8w/3oQ24MCBinfDPK3Mg2Ggv vYWADoM63KuTg== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vMmsP-00000004pmD-2F9W; Sat, 22 Nov 2025 13:38:05 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , "Jonathan Corbet" Cc: Mauro Carvalho Chehab , "Mauro Carvalho Chehab" , "Randy Dunlap" , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 3/5] docs: media: v4l2-ioctl.h: document two global variables Date: Sat, 22 Nov 2025 13:37:57 +0100 Message-ID: <7f471a4d2749c7dc7985e35c69b6f5e67e0aa33d.1763814816.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.51.1 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. 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..ed63841a100c 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 strings. + * + * 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.51.1 From nobody Tue Dec 2 01:26:16 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 BCE1E524F; Sat, 22 Nov 2025 12:38:07 +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=1763815087; cv=none; b=MeULWbBqhxrZqVS6D44mkBHoNbGFm+23e28lBUjX5oylHQoYG0/duVjmcZuRxUTxpS1nSMDhv/aRu/MWDyHb1iVaiiZJpV8DJbInZr1cEqqObsKx05OKL8Vrv7y4TuEC4mNxXL4xoYgXPkR6lnd07EE+FpGDbKRHHf4Jjvde3Cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763815087; c=relaxed/simple; bh=kXa4ys6hkQ4doBFd9i3ExpWBNpug/g4Cc9eJw3PZgxc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XO++Xfob2MDpd1F/uO9btSM5A0d1Jah474VSmGqysxgpOYnevL8NrrGpxr796G4PdQOw5hlJ2IEs96QjPo6JYWbbq1W3WfsHheJ6rfSseEsBeEjMtrnVxo5YIiD+XZYf1sSCEoHNq9zw9O/1caovLAtVBOHndRzBSMu9ar+anY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fw5EGh13; 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="Fw5EGh13" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B108C4CEF5; Sat, 22 Nov 2025 12:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763815087; bh=kXa4ys6hkQ4doBFd9i3ExpWBNpug/g4Cc9eJw3PZgxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fw5EGh13VoZNtWor06/2MTtPYpgs+oqs2V7zpupNtAtQpfu/oJrTB4WoIabde7W/D ynVJxX9j43wdl+FzJ54M/wQHvrml2vagXj40wqrJru5OAmrEDlcv5GAjhhZlnFX5sS 2oWLHLehD91oDR4klUfZjdeawL55+kwKFVqzhROKot2rvqX8MqADXxCmrpv5VEr1Fa WPs0kAz2gVqPUhp9hIkZPI+GIzEJX8JwJhwXregMLRgy22XZaTI69/51G1ugeMgUeG SLrCAieUG+7mlZbZlz9udR2eNhUn/H38PqVlzY6h+D09FPpycfocBL0+hkkSMl3ZG6 Aa8VhJ2JUSghw== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vMmsP-00000004pmH-2Lsf; Sat, 22 Nov 2025 13:38:05 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , "Jonathan Corbet" Cc: Mauro Carvalho Chehab , "Mauro Carvalho Chehab" , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v4 4/5] docs: kernel-doc.rst: don't let automarkup mangle with consts Date: Sat, 22 Nov 2025 13:37:58 +0100 Message-ID: X-Mailer: git-send-email 2.51.1 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.51.1 From nobody Tue Dec 2 01:26:16 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 C40EC1917FB; Sat, 22 Nov 2025 12:38:07 +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=1763815087; cv=none; b=CEqCCN/IgXhG3pGAMWxa9tdUUw8vnUhM2BvGQRaXEOpuqRHkE8QPI3LXOBMFTzNu5qd0jNZmeqwzNVOOK20yKVecYQ+s16SP5Q4iWTlbi5GUnl9TBcF7WQCfm8QAGJDPL9cFH12Gnq6nIBJHckN6lQNHpyph0bgbfpWQwqOqUJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763815087; c=relaxed/simple; bh=WiyWZu0I2v9Q5Kn5QLFrux4dYHtK/j2mUZCTGm3fUBY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rh4XZYMzZ+kJU576jD+F4c0GY5BOdbXpMsLf1Kiz4cHBrMpfhfUucUgXCcpB0ODUcHpL8lpaBJq+hV+i0czV8/tgSE3EDZVPA8kxMeD4qALO3DALxRdsvyAf5TUaTytAuC9lN2u9gMXIWdvdSo2GouSFBj+HVoMc/AU/CZwKQmc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ieT0Jnaq; 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="ieT0Jnaq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60902C4AF09; Sat, 22 Nov 2025 12:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763815087; bh=WiyWZu0I2v9Q5Kn5QLFrux4dYHtK/j2mUZCTGm3fUBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ieT0JnaqWS8DoG1VpQ9t+RlA54pENcJPFjYp/BQmF4tf09OY6hi11iOxiN6J0bKmk OsQvS1rCoxlLEuz1oahcYyUEMHFDoxryfsewzEcl3fAPIeLpwqWhbgC41dj4Qy5liW Kbb9gjhMJnWJxn1Slfucu2Fy29Z6yLE6/K2mg3Meh8MoOk60xmqt2iVR2OiMTFb1ne 2aVDAS7EJ7FAz8atmOHCMyMu5IH7FeofKew4MjpK273bnKZOreQmsXmFRtwmufEHbU nuD5RXXtUq26FbkFPMMstLk0sXsmGSGf0m1mqtxbl7SFZAr45F2/bYOt8WzTVq09DK wYkRMXZNr0L5A== Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1vMmsP-00000004pmL-2SVK; Sat, 22 Nov 2025 13:38:05 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , "Jonathan Corbet" Cc: Mauro Carvalho Chehab , "Mauro Carvalho Chehab" , "Randy Dunlap" , linux-kernel@vger.kernel.org Subject: [PATCH v4 5/5] docs: kernel-doc.rst: document the new "var" kernel-doc markup Date: Sat, 22 Nov 2025 13:37:59 +0100 Message-ID: <9d7830a2c4a2c9cd4062af54227daeed7f842cc3.1763814816.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.51.1 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.51.1