From nobody Tue Dec 16 22:10:39 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 EE63E1CEAC2; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=Iqzw5D+FXPC/mfsKDbS4KSpDqx4c5g7TLnCBhBnypr5XpAhsERCWsgRMErZ2EA0Q99tmmtWSbxwQ2wtLKXiyTmps8D8Ibfn6TxTZwNDjrSeXvfESdvkLzxZN4pvPtLTNuMa/q8t9uiXfqCcOZ1J0gIK73iV8ffD2Rf9ja3d/ixw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=OOogPGxX0Vy45ilzrAOiFUxIeadBVZaAODgzfVd0odE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=foj42lwohdugF6xNR3y2T5ykkTvvCb5Jxb5LOuMS1Wi9G17jcTGGSIpKfltqvvHcHyfkR2WKZ0LVEmV9uDEQ6b73Eu/W7/Kt93e784NnPXQ9aR4psA2EFXQyj/7TYIiisfFcQsyQyKweNkS4hnBcCJgrg2m/VspMIbSZp79GKrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A8Wy/PkA; 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="A8Wy/PkA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8674C4CEEA; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=OOogPGxX0Vy45ilzrAOiFUxIeadBVZaAODgzfVd0odE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8Wy/PkAHP/k8BbDb5bQfCIvpGdY5p2jY5xoOOWUcr68VKkuTR3cb4ZrG4YFzcrBP vud0ifkjZrfTjy3owbJCbH1UcrbNMTQ3xxKC9jnswIIxIVUj6L7I1h89TS76DCjD5M HbTCS05K+sg+U2op1e/fWjX41ojFn9208asnrcaEfBUwTFGDoztkgehdY0RM8caInV oBr0Fr+e2crZ4byU8oFCXWARin8b2GHbelObSXcEgBhLBJY+085XSWchgJ6f1em7PX bBeiWpc25gkJvVYSGpqBqmuPYhitAXrhqQvFMDPw0GLWNNYM5Aa4qJIMKEqvRvW/VM sWVsOZRgMCCxw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQrt-00000006CiC-3i8A; Mon, 10 Feb 2025 11:18:21 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , Randy Dunlap , Vegard Nossum , linux-kernel@vger.kernel.org Subject: [PATCH 01/27] docs: sphinx: remove kernellog.py file Date: Mon, 10 Feb 2025 11:17:50 +0100 Message-ID: <48bf16f199250d7048ca164d1b90773861915157.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" In the past, there was a need for a wrapper due to different Sphinx versions support (before Sphinx 1.6). This is long gone, and now it is just a wrapper. Get rig of it to simplify the code. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/sphinx/kernel_abi.py | 5 +- Documentation/sphinx/kerneldoc.py | 14 +++--- Documentation/sphinx/kernellog.py | 22 -------- Documentation/sphinx/kfigure.py | 81 ++++++++++++++++-------------- 4 files changed, 53 insertions(+), 69 deletions(-) delete mode 100644 Documentation/sphinx/kernellog.py diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index 5911bd0d7965..8401562cb5d9 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -37,13 +37,13 @@ import os import subprocess import sys import re -import kernellog =20 from docutils import nodes, statemachine from docutils.statemachine import ViewList from docutils.parsers.rst import directives, Directive from docutils.utils.error_reporting import ErrorString from sphinx.util.docutils import switch_source_input +from sphinx.util import logging =20 __version__ =3D '1.0' =20 @@ -64,6 +64,7 @@ class KernelCmd(Directive): optional_arguments =3D 2 has_content =3D False final_argument_whitespace =3D True + logger =3D logging.getLogger('kernel_abi') =20 option_spec =3D { "debug" : directives.flag, @@ -129,7 +130,7 @@ class KernelCmd(Directive): else: content.append(line, f, ln) =20 - kernellog.info(self.state.document.settings.env.app, "%s: parsed %= i lines" % (fname, n)) + self.logger.info("%s: parsed %i lines" % (fname, n)) =20 if content: self.do_parse(content, node) diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerne= ldoc.py index ec1ddfff1863..be5b8fbf373f 100644 --- a/Documentation/sphinx/kerneldoc.py +++ b/Documentation/sphinx/kerneldoc.py @@ -39,7 +39,7 @@ from docutils.statemachine import ViewList from docutils.parsers.rst import directives, Directive import sphinx from sphinx.util.docutils import switch_source_input -import kernellog +from sphinx.util import logging =20 __version__ =3D '1.0' =20 @@ -56,6 +56,7 @@ class KernelDocDirective(Directive): 'functions': directives.unchanged, } has_content =3D False + logger =3D logging.getLogger('kerneldoc') =20 def run(self): env =3D self.state.document.settings.env @@ -109,8 +110,7 @@ class KernelDocDirective(Directive): cmd +=3D [filename] =20 try: - kernellog.verbose(env.app, - 'calling kernel-doc \'%s\'' % (" ".join(cmd)= )) + self.logger.verbose("calling kernel-doc '%s'" % (" ".join(cmd)= )) =20 p =3D subprocess.Popen(cmd, stdout=3Dsubprocess.PIPE, stderr= =3Dsubprocess.PIPE) out, err =3D p.communicate() @@ -120,8 +120,8 @@ class KernelDocDirective(Directive): if p.returncode !=3D 0: sys.stderr.write(err) =20 - kernellog.warn(env.app, - 'kernel-doc \'%s\' failed with return code = %d' % (" ".join(cmd), p.returncode)) + self.logger.warning("kernel-doc '%s' failed with return co= de %d" + % (" ".join(cmd), p.returncode)) return [nodes.error(None, nodes.paragraph(text =3D "kernel= -doc missing"))] elif env.config.kerneldoc_verbosity > 0: sys.stderr.write(err) @@ -148,8 +148,8 @@ class KernelDocDirective(Directive): return node.children =20 except Exception as e: # pylint: disable=3DW0703 - kernellog.warn(env.app, 'kernel-doc \'%s\' processing failed w= ith: %s' % - (" ".join(cmd), str(e))) + self.logger.warning("kernel-doc '%s' processing failed with: %= s" % + (" ".join(cmd), str(e))) return [nodes.error(None, nodes.paragraph(text =3D "kernel-doc= missing"))] =20 def do_parse(self, result, node): diff --git a/Documentation/sphinx/kernellog.py b/Documentation/sphinx/kerne= llog.py deleted file mode 100644 index 0bc00c138cad..000000000000 --- a/Documentation/sphinx/kernellog.py +++ /dev/null @@ -1,22 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# Sphinx has deprecated its older logging interface, but the replacement -# only goes back to 1.6. So here's a wrapper layer to keep around for -# as long as we support 1.4. -# -# We don't support 1.4 anymore, but we'll keep the wrappers around until -# we change all the code to not use them anymore :) -# -import sphinx -from sphinx.util import logging - -logger =3D logging.getLogger('kerneldoc') - -def warn(app, message): - logger.warning(message) - -def verbose(app, message): - logger.verbose(message) - -def info(app, message): - logger.info(message) diff --git a/Documentation/sphinx/kfigure.py b/Documentation/sphinx/kfigure= .py index 97166333b727..383f9a695b08 100644 --- a/Documentation/sphinx/kfigure.py +++ b/Documentation/sphinx/kfigure.py @@ -59,12 +59,14 @@ from docutils.parsers.rst import directives from docutils.parsers.rst.directives import images import sphinx from sphinx.util.nodes import clean_astext -import kernellog +from sphinx.util import logging =20 Figure =3D images.Figure =20 __version__ =3D '1.0.0' =20 +logger =3D logging.getLogger('kfigure') + # simple helper # ------------- =20 @@ -170,7 +172,7 @@ def setupTools(app): """ global dot_cmd, dot_Tpdf, convert_cmd, rsvg_convert_cmd # pylint: di= sable=3DW0603 global inkscape_cmd, inkscape_ver_one # pylint: disable=3DW0603 - kernellog.verbose(app, "kfigure: check installed tools ...") + logger.verbose("kfigure: check installed tools ...") =20 dot_cmd =3D which('dot') convert_cmd =3D which('convert') @@ -178,7 +180,7 @@ def setupTools(app): inkscape_cmd =3D which('inkscape') =20 if dot_cmd: - kernellog.verbose(app, "use dot(1) from: " + dot_cmd) + logger.verbose("use dot(1) from: " + dot_cmd) =20 try: dot_Thelp_list =3D subprocess.check_output([dot_cmd, '-Thelp'], @@ -190,10 +192,11 @@ def setupTools(app): dot_Tpdf_ptn =3D b'pdf' dot_Tpdf =3D re.search(dot_Tpdf_ptn, dot_Thelp_list) else: - kernellog.warn(app, "dot(1) not found, for better output quality i= nstall " - "graphviz from https://www.graphviz.org") + logger.warning( + "dot(1) not found, for better output quality install graphviz = from https://www.graphviz.org" + ) if inkscape_cmd: - kernellog.verbose(app, "use inkscape(1) from: " + inkscape_cmd) + logger.verbose("use inkscape(1) from: " + inkscape_cmd) inkscape_ver =3D subprocess.check_output([inkscape_cmd, '--version= '], stderr=3Dsubprocess.DEVNULL) ver_one_ptn =3D b'Inkscape 1' @@ -204,26 +207,27 @@ def setupTools(app): =20 else: if convert_cmd: - kernellog.verbose(app, "use convert(1) from: " + convert_cmd) + logger.verbose("use convert(1) from: " + convert_cmd) else: - kernellog.verbose(app, + logger.verbose( "Neither inkscape(1) nor convert(1) found.\n" - "For SVG to PDF conversion, " - "install either Inkscape (https://inkscape.org/) (preferre= d) or\n" - "ImageMagick (https://www.imagemagick.org)") + "For SVG to PDF conversion, install either Inkscape (https= ://inkscape.org/) (preferred) or\n" + "ImageMagick (https://www.imagemagick.org)" + ) =20 if rsvg_convert_cmd: - kernellog.verbose(app, "use rsvg-convert(1) from: " + rsvg_con= vert_cmd) - kernellog.verbose(app, "use 'dot -Tsvg' and rsvg-convert(1) fo= r DOT -> PDF conversion") + logger.verbose("use rsvg-convert(1) from: " + rsvg_convert_cmd) + logger.verbose("use 'dot -Tsvg' and rsvg-convert(1) for DOT ->= PDF conversion") dot_Tpdf =3D False else: - kernellog.verbose(app, + logger.verbose( "rsvg-convert(1) not found.\n" - " SVG rendering of convert(1) is done by ImageMagick-nati= ve renderer.") + " SVG rendering of convert(1) is done by ImageMagick-nati= ve renderer." + ) if dot_Tpdf: - kernellog.verbose(app, "use 'dot -Tpdf' for DOT -> PDF con= version") + logger.verbose("use 'dot -Tpdf' for DOT -> PDF conversion") else: - kernellog.verbose(app, "use 'dot -Tsvg' and convert(1) for= DOT -> PDF conversion") + logger.verbose("use 'dot -Tsvg' and convert(1) for DOT -> = PDF conversion") =20 =20 # integrate conversion tools @@ -257,13 +261,12 @@ def convert_image(img_node, translator, src_fname=3DN= one): =20 # in kernel builds, use 'make SPHINXOPTS=3D-v' to see verbose messages =20 - kernellog.verbose(app, 'assert best format for: ' + img_node['uri']) + logger.verbose('assert best format for: ' + img_node['uri']) =20 if in_ext =3D=3D '.dot': =20 if not dot_cmd: - kernellog.verbose(app, - "dot from graphviz not available / include D= OT raw.") + logger.verbose("dot from graphviz not available / include DOT = raw.") img_node.replace_self(file2literal(src_fname)) =20 elif translator.builder.format =3D=3D 'latex': @@ -290,10 +293,11 @@ def convert_image(img_node, translator, src_fname=3DN= one): =20 if translator.builder.format =3D=3D 'latex': if not inkscape_cmd and convert_cmd is None: - kernellog.warn(app, - "no SVG to PDF conversion available / in= clude SVG raw." - "\nIncluding large raw SVGs can cause xe= latex error." - "\nInstall Inkscape (preferred) or Image= Magick.") + logger.warning( + "no SVG to PDF conversion available / include SVG raw.= \n" + "Including large raw SVGs can cause xelatex error.\n" + "Install Inkscape (preferred) or ImageMagick." + ) img_node.replace_self(file2literal(src_fname)) else: dst_fname =3D path.join(translator.builder.outdir, fname += '.pdf') @@ -306,15 +310,14 @@ def convert_image(img_node, translator, src_fname=3DN= one): _name =3D dst_fname[len(str(translator.builder.outdir)) + 1:] =20 if isNewer(dst_fname, src_fname): - kernellog.verbose(app, - "convert: {out}/%s already exists and is new= er" % _name) + logger.verbose("convert: {out}/%s already exists and is newer"= % _name) =20 else: ok =3D False mkdir(path.dirname(dst_fname)) =20 if in_ext =3D=3D '.dot': - kernellog.verbose(app, 'convert DOT to: {out}/' + _name) + logger.verbose('convert DOT to: {out}/' + _name) if translator.builder.format =3D=3D 'latex' and not dot_Tp= df: svg_fname =3D path.join(translator.builder.outdir, fna= me + '.svg') ok1 =3D dot2format(app, src_fname, svg_fname) @@ -325,7 +328,7 @@ def convert_image(img_node, translator, src_fname=3DNon= e): ok =3D dot2format(app, src_fname, dst_fname) =20 elif in_ext =3D=3D '.svg': - kernellog.verbose(app, 'convert SVG to: {out}/' + _name) + logger.verbose('convert SVG to: {out}/' + _name) ok =3D svg2pdf(app, src_fname, dst_fname) =20 if not ok: @@ -354,7 +357,7 @@ def dot2format(app, dot_fname, out_fname): with open(out_fname, "w") as out: exit_code =3D subprocess.call(cmd, stdout =3D out) if exit_code !=3D 0: - kernellog.warn(app, + logger.warning( "Error #%d when calling: %s" % (exit_code, " ".j= oin(cmd))) return bool(exit_code =3D=3D 0) =20 @@ -388,13 +391,14 @@ def svg2pdf(app, svg_fname, pdf_fname): pass =20 if exit_code !=3D 0: - kernellog.warn(app, "Error #%d when calling: %s" % (exit_code, " "= .join(cmd))) + logger.warning("Error #%d when calling: %s" % + (exit_code, " ".join(cmd))) if warning_msg: - kernellog.warn(app, "Warning msg from %s: %s" - % (cmd_name, str(warning_msg, 'utf-8'))) + logger.warning( "Warning msg from %s: %s" % + (cmd_name, str(warning_msg, 'utf-8'))) elif warning_msg: - kernellog.verbose(app, "Warning msg from %s (likely harmless):\n%s" - % (cmd_name, str(warning_msg, 'utf-8'))) + logger.verbose("Warning msg from %s (likely harmless):\n%s" % + (cmd_name, str(warning_msg, 'utf-8'))) =20 return bool(exit_code =3D=3D 0) =20 @@ -418,7 +422,8 @@ def svg2pdf_by_rsvg(app, svg_fname, pdf_fname): # use stdout and stderr from parent exit_code =3D subprocess.call(cmd) if exit_code !=3D 0: - kernellog.warn(app, "Error #%d when calling: %s" % (exit_code,= " ".join(cmd))) + logger.warning("Error #%d when calling: %s" % + (exit_code, " ".join(cmd))) ok =3D bool(exit_code =3D=3D 0) =20 return ok @@ -513,15 +518,15 @@ def visit_kernel_render(self, node): app =3D self.builder.app srclang =3D node.get('srclang') =20 - kernellog.verbose(app, 'visit kernel-render node lang: "%s"' % (srclan= g)) + logger.verbose('visit kernel-render node lang: "%s"' % srclang) =20 tmp_ext =3D RENDER_MARKUP_EXT.get(srclang, None) if tmp_ext is None: - kernellog.warn(app, 'kernel-render: "%s" unknown / include raw.' %= (srclang)) + logger.warning( 'kernel-render: "%s" unknown / include raw.' % src= lang) return =20 if not dot_cmd and tmp_ext =3D=3D '.dot': - kernellog.verbose(app, "dot from graphviz not available / include = raw.") + logger.verbose("dot from graphviz not available / include raw.") return =20 literal_block =3D node[0] --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 7C1E91C5F36; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=HQGm/nJ6g1Oc+tSdZD5k6DEUMbetZ6YrByU5TJlVa4o+wjP4a1VzH+HlW9RHhuY1dR7LRCJZLcO9ZzDn6tup9JC8U1yH7n2jvJsSK7J467tJSq1ZthubWbzJmc7bk36Vc+KU61Fze2/URApFLh8pAFHZ3ZxHPujkQZlozxouxyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=Y/6DtB75n/8IACU5oUa83ZoIRDQNO5zVfF736uCoidc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IHavOLiluzi7i5eXJTujD7K7YyFrnF4HBWs62nhdO2tR5lHVjCoMbKzQrQUwjoEEHQF9+bxj5kKCf3mEA9MSh5paFHejsSpX4ejGm2zirGaJkYz6N4sSCVeumJSBFB7Opoka1hQTNY+BvMoNceieZh7c6PbrY41CW3v+G5zxvp8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I1HSStpA; 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="I1HSStpA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D304EC4CEE9; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182703; bh=Y/6DtB75n/8IACU5oUa83ZoIRDQNO5zVfF736uCoidc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I1HSStpAtk4WlHpVXY8ZdwGC4LK6ZafR37XI7tcVAEbHNDEH8xsWqZVb9iKXj84iy uXs3MiHsr5pS7WWY0/070X+e6CBPWcGM74V3ufLHT6S0IqMSpISwF/U0kSxWqPBljV iwmsfbGxv0hDbfOZTKbs7QIROlMPh9FkDI+v3xGvPU08qqlqNEeunnjq9u+bYJVmyU GmsP61o3zSD2IURCCsKL7+gbK8Hg7b7MqqlNvt4l8maSVxNEc4SRTvCyoXBV5X7lU3 896Xl9reJRYq3+usvLE3X/XvnHLQ4es/Hkbcdsh84txoXRJ63Iw08ZWHb6UGXxvmlO ++7Vyw/mTDOxg== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQrt-00000006CiG-3pT6; Mon, 10 Feb 2025 11:18:21 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 02/27] docs: sphinx/kernel_abi: adjust coding style Date: Mon, 10 Feb 2025 11:17:51 +0100 Message-ID: <02a9ec0fab61e4c94b9c2ff555bc0e9d93f59100.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Make pylint and flake8 happier with this module's coding style Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/sphinx/kernel_abi.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index 8401562cb5d9..38653f5706c0 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -32,32 +32,31 @@ u""" =20 """ =20 -import codecs import os +import re import subprocess import sys -import re =20 -from docutils import nodes, statemachine +from docutils import nodes from docutils.statemachine import ViewList from docutils.parsers.rst import directives, Directive -from docutils.utils.error_reporting import ErrorString from sphinx.util.docutils import switch_source_input from sphinx.util import logging =20 -__version__ =3D '1.0' +__version__ =3D "1.0" + =20 def setup(app): =20 app.add_directive("kernel-abi", KernelCmd) - return dict( - version =3D __version__ - , parallel_read_safe =3D True - , parallel_write_safe =3D True - ) + return { + "version": __version__, + "parallel_read_safe": True, + "parallel_write_safe": True + } + =20 class KernelCmd(Directive): - u"""KernelABI (``kernel-abi``) directive""" =20 required_arguments =3D 1 @@ -99,8 +98,8 @@ class KernelCmd(Directive): =20 if "debug" in self.options: code_block =3D "\n\n.. code-block:: rst\n :linenos:\n" - for l in lines.split("\n"): - code_block +=3D "\n " + l + for line in lines.split("\n"): + code_block +=3D "\n " + line lines =3D code_block + "\n\n" =20 line_regex =3D re.compile(r"^\.\. LINENO (\S+)\#([0-9]+)$") --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 C48461CAA86; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=uzuF8nJBe+1IHz1ZC3xxOfk8PpiUGibAglYCHuEm7XIye7otQ2bXA076S8V7sUzkptaHuytvK7UtYDbdaUbqUVCCcEM2RgvzxWmkMWc/1rWiWNGWh/CfZ+RFKbKUyif/waoSfdWyF0+z39P2S5E3Lomm19trRdwJXGMdJvGHtqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=IFfJ6jqxdTobj9ECUn0r6qKV42rp7aK/OvTRbD8u8YE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=noFJlVXIayFzcmTdOwltPAaTBHdw+eW7104M3Wd9YttStC0nIcE5Y1buMwYfafrjcez9DinEBp8rshbgMsFkeyaNrleds9h0UmR0Fr1J37BoS22Gsh1oxhxULM6hsiecX5Dwyhi3FLu67PFltiWuuMVbuG28Bv2uTjQ2H7F0j8I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rdzypHRA; 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="rdzypHRA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3586C4CEED; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=IFfJ6jqxdTobj9ECUn0r6qKV42rp7aK/OvTRbD8u8YE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rdzypHRAXrS/ucSvlHVj2dy1C/7ki2pi+g4AxaC7uSp9LQ5BE1T2X7pvImYl2S2Iz igCSRPGzVTaUz+F+PM+3nBBZN0SOWG6fKDKka3c1PWX+FIZEVHpzK3IO6mQV5vW33z KCnVtJEw4vdy2FvCJLkoVQNHZujmY3li+TmO/Je/DBTQrpql5D2G7V7VQxeVQQ3b4w vjlu8IV9FsZMJJE95VJ9FgTWm3ZoS2N3VBQGxCVevB3xhFW+epQu1QV5L/NicGKJBr PXKiu+YvX5QGJ5RBkTkmDK2ehF1/FIxVxGeD3R0s+GXhfHbsX49lI2sFbCnq7XQja1 fvyIO3VSlyVAA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQrt-00000006CiK-3wTB; Mon, 10 Feb 2025 11:18:21 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 03/27] docs: admin-guide: abi: add SPDX tags to ABI files Date: Mon, 10 Feb 2025 11:17:52 +0100 Message-ID: <8c7bfe676e7349ea2d1930bf918d54e27d15ae9e.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Such files are missing SPDX tags containing the licensing information. Add them. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/admin-guide/abi-obsolete.rst | 2 ++ Documentation/admin-guide/abi-removed.rst | 2 ++ Documentation/admin-guide/abi-stable.rst | 2 ++ Documentation/admin-guide/abi-testing.rst | 2 ++ Documentation/admin-guide/abi.rst | 2 ++ 5 files changed, 10 insertions(+) diff --git a/Documentation/admin-guide/abi-obsolete.rst b/Documentation/adm= in-guide/abi-obsolete.rst index 594e697aa1b2..b655615917f1 100644 --- a/Documentation/admin-guide/abi-obsolete.rst +++ b/Documentation/admin-guide/abi-obsolete.rst @@ -1,3 +1,5 @@ +.. SPDX-License-Identifier: GPL-2.0 + ABI obsolete symbols =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/Documentation/admin-guide/abi-removed.rst b/Documentation/admi= n-guide/abi-removed.rst index f9e000c81828..ba941c1af178 100644 --- a/Documentation/admin-guide/abi-removed.rst +++ b/Documentation/admin-guide/abi-removed.rst @@ -1,3 +1,5 @@ +.. SPDX-License-Identifier: GPL-2.0 + ABI removed symbols =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/Documentation/admin-guide/abi-stable.rst b/Documentation/admin= -guide/abi-stable.rst index fc3361d847b1..5d738f345333 100644 --- a/Documentation/admin-guide/abi-stable.rst +++ b/Documentation/admin-guide/abi-stable.rst @@ -1,3 +1,5 @@ +.. SPDX-License-Identifier: GPL-2.0 + ABI stable symbols =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/Documentation/admin-guide/abi-testing.rst b/Documentation/admi= n-guide/abi-testing.rst index 19767926b344..a867e6578bf7 100644 --- a/Documentation/admin-guide/abi-testing.rst +++ b/Documentation/admin-guide/abi-testing.rst @@ -1,3 +1,5 @@ +.. SPDX-License-Identifier: GPL-2.0 + ABI testing symbols =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/Documentation/admin-guide/abi.rst b/Documentation/admin-guide/= abi.rst index bcab3ef2597c..64e772bde943 100644 --- a/Documentation/admin-guide/abi.rst +++ b/Documentation/admin-guide/abi.rst @@ -1,3 +1,5 @@ +.. SPDX-License-Identifier: GPL-2.0 + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Linux ABI description =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 7C1951C5F26; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=F2gSdwFvNgvAU29lE5m4lPuCV2c1GT6XDxDqghylAyjvTDzSi/KrJEuUWl53rl7MAiEhrltNNcgK2lK9UZ9+oIU2pgM6EWP75P4Vu+pSNgUzeP1b4Rj+8h3QkRXYmLfTXj5Ay4/ICh+2Czk/urL46xAGF0TH1H2By6XtKjY2ZD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=hdD/lkpi+9/YArLnX7wjSWSXiDV5h4tehxtqm9TMWBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O/oej/mr+GixexbPVGXyFhr+S4Mcb86TLnDB+/JkfDGut3mMlJLMfS9fcqlMWmaAJ03XG7QVzSL/JsBbEiqKLpmlzhF0CNMaiE+wVT+MChZS3khvY/aTy90X8yMw3ozf7g5uRfp9wi8hkNZ+D1gMTGoTxsYVtj768pdVDXWbgOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gK4IzSh7; 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="gK4IzSh7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8F4AC4CEE8; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182703; bh=hdD/lkpi+9/YArLnX7wjSWSXiDV5h4tehxtqm9TMWBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gK4IzSh74oV/PMAN1TbaccYqTPFi0h7UTglCsSjtFjav+ORarQK5IRT46evSWva6X 07YtQDeu5hNh5+LuXZdxzhxqUUf7hPym0CUnuozXL+jyGKdXh2xUmq2ORwSiav4IT/ 0O6N+IWb2GebzH6YXE9aMoZLamQSZgGy9911O83PB1J8q0h1u+330BIQcFezeBuHZi 5Jiehf+kgxw4ln6Ze+buR8B8MIST3xzDTrT5uyHH5iwnf7SuTHI4LEP/DExaZypRi8 xsMrti9j4f7prV6w/bHTjKccBfsgwfe2YvwohgqCYFN/kyHLiDo7GZupseF4HqNdke xJ6Q3mH0tkwPw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQrt-00000006CiO-43NZ; Mon, 10 Feb 2025 11:18:21 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , Johannes Berg , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH 04/27] ABI: sysfs-class-rfkill: fix kernelversion tags Date: Mon, 10 Feb 2025 11:17:53 +0100 Message-ID: X-Mailer: git-send-email 2.48.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" Some kernelversion tags are missing colons. Add them to comply with ABI description and produce right results when converted to html/pdf. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/ABI/removed/sysfs-class-rfkill | 2 +- Documentation/ABI/stable/sysfs-class-rfkill | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/ABI/removed/sysfs-class-rfkill b/Documentation/A= BI/removed/sysfs-class-rfkill index f25174eafd55..20cb688af173 100644 --- a/Documentation/ABI/removed/sysfs-class-rfkill +++ b/Documentation/ABI/removed/sysfs-class-rfkill @@ -4,7 +4,7 @@ For details to this subsystem look at Documentation/driver-= api/rfkill.rst. =20 What: /sys/class/rfkill/rfkill[0-9]+/claim Date: 09-Jul-2007 -KernelVersion v2.6.22 +KernelVersion: v2.6.22 Contact: linux-wireless@vger.kernel.org Description: This file was deprecated because there no longer was a way to claim just control over a single rfkill instance. diff --git a/Documentation/ABI/stable/sysfs-class-rfkill b/Documentation/AB= I/stable/sysfs-class-rfkill index 037979f7dc4b..67b605e3dd16 100644 --- a/Documentation/ABI/stable/sysfs-class-rfkill +++ b/Documentation/ABI/stable/sysfs-class-rfkill @@ -16,7 +16,7 @@ Description: The rfkill class subsystem folder. =20 What: /sys/class/rfkill/rfkill[0-9]+/name Date: 09-Jul-2007 -KernelVersion v2.6.22 +KernelVersion: v2.6.22 Contact: linux-wireless@vger.kernel.org Description: Name assigned by driver to this key (interface or driver nam= e). Values: arbitrary string. @@ -24,7 +24,7 @@ Values: arbitrary string. =20 What: /sys/class/rfkill/rfkill[0-9]+/type Date: 09-Jul-2007 -KernelVersion v2.6.22 +KernelVersion: v2.6.22 Contact: linux-wireless@vger.kernel.org Description: Driver type string ("wlan", "bluetooth", etc). Values: See include/linux/rfkill.h. @@ -32,7 +32,7 @@ Values: See include/linux/rfkill.h. =20 What: /sys/class/rfkill/rfkill[0-9]+/persistent Date: 09-Jul-2007 -KernelVersion v2.6.22 +KernelVersion: v2.6.22 Contact: linux-wireless@vger.kernel.org Description: Whether the soft blocked state is initialised from non-volat= ile storage at startup. @@ -44,7 +44,7 @@ Values: A numeric value: =20 What: /sys/class/rfkill/rfkill[0-9]+/state Date: 09-Jul-2007 -KernelVersion v2.6.22 +KernelVersion: v2.6.22 Contact: linux-wireless@vger.kernel.org Description: Current state of the transmitter. This file was scheduled to be removed in 2014, but due to its @@ -67,7 +67,7 @@ Values: A numeric value. =20 What: /sys/class/rfkill/rfkill[0-9]+/hard Date: 12-March-2010 -KernelVersion v2.6.34 +KernelVersion: v2.6.34 Contact: linux-wireless@vger.kernel.org Description: Current hardblock state. This file is read only. Values: A numeric value. @@ -81,7 +81,7 @@ Values: A numeric value. =20 What: /sys/class/rfkill/rfkill[0-9]+/soft Date: 12-March-2010 -KernelVersion v2.6.34 +KernelVersion: v2.6.34 Contact: linux-wireless@vger.kernel.org Description: Current softblock state. This file is read and write. Values: A numeric value. --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 F28C61CF284; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=QZFk450snKguoeU582lXC10qreDEt85+4k+6Fqmhu6rA7Y2plBXlACw2PsikamLVRc0LGf9t+hlI+lC6Qs/tuK3iq3I+3/FGBBaxXyf1akHriClQHVdCr2YeyeyVHTrWEL/ey8VW5ayJ7cYUDvZpBIx0z9fPTqQ6ZcoeRGJNs9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=qrdsVxvuQlrneXqnvXiP9gvzFSX4e5M789thOkYc44o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GIx2cPAsDcAnXxoglYWsXCqwu71WnvMCYZuByehW3XQCQWcNB6hZTv/Bh+ZMXQaP1f1558syM45RtsjEYk2EfYUtwRPPHvrgttGwz4e5qUqmCdOTHsvziYQxDTptPDkbnVpHHjm36YCmGvjAB+9MnBtBEsIxVnrgRTlFpsAfpgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ikvZ3d5l; 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="ikvZ3d5l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C20DFC4CEE4; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=qrdsVxvuQlrneXqnvXiP9gvzFSX4e5M789thOkYc44o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ikvZ3d5lUn63D2CLG8RDencAAhg3jR/LANRXuatdb34SMOGWeaYQwR/Fv7vAAXLOW orS4OccvGoabjkvJx2g4BQ26TxsvR5UM/lrUdnWFZqnXQw8Gy2mpOztu6qaaPwZGgx VWOxjVGVZQcRsoCvWBjI36iq+YlN0Og2Ni+cXU5aOMyIhaz2yHjygxGiyUnkdTS807 PT7WgUJc8bYq+Z1hUeWLJK8xJwqBFjrur4jQNdNkoNyEmwnN9+/zeGWfOXNOMC/MHZ 9Org1oD4LAMqw4WAAbyRd/TDqsLTiEglSz1AkgQ0wW2UrH8kVkecgJFp8XWG5EVMNA dvsCpEBJODdgg== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQrt-00000006CiS-4AXV; Mon, 10 Feb 2025 11:18:21 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , James Clark , Mike Leach , Suzuki K Poulose , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/27] ABI: sysfs-bus-coresight-*: fix kernelversion tags Date: Mon, 10 Feb 2025 11:17:54 +0100 Message-ID: <72c3a6583c2ffca23ae9ee1c0b6dc98618ae0775.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Some kernelversion tags are missing colons. Add them to comply with ABI description and produce right results when converted to html/pdf. Signed-off-by: Mauro Carvalho Chehab Acked-by: Suzuki K Poulose Suggested-by: Jonathan Corbet --- .../testing/sysfs-bus-coresight-devices-cti | 78 +++++++++---------- .../testing/sysfs-bus-coresight-devices-tpdm | 52 ++++++------- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-cti b/Do= cumentation/ABI/testing/sysfs-bus-coresight-devices-cti index bf2869c413e7..a97b70f588da 100644 --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-cti +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-cti @@ -1,241 +1,241 @@ What: /sys/bus/coresight/devices//enable Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Enable/Disable the CTI hardware. =20 What: /sys/bus/coresight/devices//powered Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Indicate if the CTI hardware is powered. =20 What: /sys/bus/coresight/devices//ctmid Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Display the associated CTM ID =20 What: /sys/bus/coresight/devices//nr_trigger_cons Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Number of devices connected to triggers on this CTI =20 What: /sys/bus/coresight/devices//triggers/name Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Name of connected device =20 What: /sys/bus/coresight/devices//triggers/in_signals Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Input trigger signals from connected device =20 What: /sys/bus/coresight/devices//triggers/in_types Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Functional types for the input trigger signals from connected device =20 What: /sys/bus/coresight/devices//triggers/out_signals Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Output trigger signals to connected device =20 What: /sys/bus/coresight/devices//triggers/out_types Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Functional types for the output trigger signals to connected device =20 What: /sys/bus/coresight/devices//regs/inout_sel Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Select the index for inen and outen registers. =20 What: /sys/bus/coresight/devices//regs/inen Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Read or write the CTIINEN register selected by inout_sel. =20 What: /sys/bus/coresight/devices//regs/outen Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Read or write the CTIOUTEN register selected by inout_se= l. =20 What: /sys/bus/coresight/devices//regs/gate Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Read or write CTIGATE register. =20 What: /sys/bus/coresight/devices//regs/asicctl Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Read or write ASICCTL register. =20 What: /sys/bus/coresight/devices//regs/intack Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Write the INTACK register. =20 What: /sys/bus/coresight/devices//regs/appset Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Set CTIAPPSET register to activate channel. Read back to determine current value of register. =20 What: /sys/bus/coresight/devices//regs/appclear Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Write APPCLEAR register to deactivate channel. =20 What: /sys/bus/coresight/devices//regs/apppulse Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Write APPPULSE to pulse a channel active for one clock cycle. =20 What: /sys/bus/coresight/devices//regs/chinstatus Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Read current status of channel inputs. =20 What: /sys/bus/coresight/devices//regs/choutstatus Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) read current status of channel outputs. =20 What: /sys/bus/coresight/devices//regs/triginstatus Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) read current status of input trigger signals =20 What: /sys/bus/coresight/devices//regs/trigoutstatus Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) read current status of output trigger signals. =20 What: /sys/bus/coresight/devices//channels/trigin_attach Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Attach a CTI input trigger to a CTM channel. =20 What: /sys/bus/coresight/devices//channels/trigin_detach Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Detach a CTI input trigger from a CTM channel. =20 What: /sys/bus/coresight/devices//channels/trigout_attach Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Attach a CTI output trigger to a CTM channel. =20 What: /sys/bus/coresight/devices//channels/trigout_detach Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Detach a CTI output trigger from a CTM channel. =20 What: /sys/bus/coresight/devices//channels/chan_gate_enable Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Enable CTIGATE for single channel (Write) or list enabled channels through the gate (R). =20 What: /sys/bus/coresight/devices//channels/chan_gate_disable Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Disable CTIGATE for single channel. =20 What: /sys/bus/coresight/devices//channels/chan_set Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Activate a single channel. =20 What: /sys/bus/coresight/devices//channels/chan_clear Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Deactivate a single channel. =20 What: /sys/bus/coresight/devices//channels/chan_pulse Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Pulse a single channel - activate for a single clock = cycle. =20 What: /sys/bus/coresight/devices//channels/trigout_filtered Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) List of output triggers filtered across all connection= s. =20 What: /sys/bus/coresight/devices//channels/trig_filter_enable Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Enable or disable trigger output signal filtering. =20 What: /sys/bus/coresight/devices//channels/chan_inuse Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) show channels with at least one attached trigger signa= l. =20 What: /sys/bus/coresight/devices//channels/chan_free Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) show channels with no attached trigger signals. =20 What: /sys/bus/coresight/devices//channels/chan_xtrigs_sel Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (RW) Write channel number to select a channel to view, read to see selected channel number. =20 What: /sys/bus/coresight/devices//channels/chan_xtrigs_in Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Read to see input triggers connected to selected view channel. =20 What: /sys/bus/coresight/devices//channels/chan_xtrigs_out Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Read) Read to see output triggers connected to selected view channel. =20 What: /sys/bus/coresight/devices//channels/chan_xtrigs_reset Date: March 2020 -KernelVersion 5.7 +KernelVersion: 5.7 Contact: Mike Leach or Mathieu Poirier Description: (Write) Clear all channel / trigger programming. diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm b/D= ocumentation/ABI/testing/sysfs-bus-coresight-devices-tpdm index bf710ea6e0ef..53cb454b60d0 100644 --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm @@ -1,6 +1,6 @@ What: /sys/bus/coresight/devices//integration_test Date: January 2023 -KernelVersion 6.2 +KernelVersion: 6.2 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (Write) Run integration test for tpdm. Integration test @@ -14,7 +14,7 @@ Description: =20 What: /sys/bus/coresight/devices//reset_dataset Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (Write) Reset the dataset of the tpdm. @@ -24,7 +24,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_trig_type Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the trigger type of the DSB for tpdm. @@ -35,7 +35,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_trig_ts Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the trigger timestamp of the DSB for tpdm. @@ -46,7 +46,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_mode Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the programming mode of the DSB for tpdm. @@ -60,7 +60,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_edge/ctrl_idx Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the index number of the edge detection for the DSB @@ -69,7 +69,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_edge/ctrl_val Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: Write a data to control the edge detection corresponding to @@ -85,7 +85,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_edge/ctrl_mask Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: Write a data to mask the edge detection corresponding to the index @@ -97,21 +97,21 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_edge/edcr[0:15] Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: Read a set of the edge control value of the DSB in TPDM. =20 What: /sys/bus/coresight/devices//dsb_edge/edcmr[0:7] Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: Read a set of the edge control mask of the DSB in TPDM. =20 What: /sys/bus/coresight/devices//dsb_trig_patt/xpr[0:7] Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the value of the trigger pattern for the DSB @@ -119,7 +119,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_trig_patt/xpmr[0:7] Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the mask of the trigger pattern for the DSB @@ -127,21 +127,21 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_patt/tpr[0:7] Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the value of the pattern for the DSB subunit TPDM. =20 What: /sys/bus/coresight/devices//dsb_patt/tpmr[0:7] Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the mask of the pattern for the DSB subunit TPDM. =20 What: /sys/bus/coresight/devices//dsb_patt/enable_ts Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (Write) Set the pattern timestamp of DSB tpdm. Read @@ -153,7 +153,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_patt/set_type Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (Write) Set the pattern type of DSB tpdm. Read @@ -165,7 +165,7 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_msr/msr[0:31] Date: March 2023 -KernelVersion 6.7 +KernelVersion: 6.7 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the MSR(mux select register) for the DSB subunit @@ -173,7 +173,7 @@ Description: =20 What: /sys/bus/coresight/devices//cmb_mode Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (Write) Set the data collection mode of CMB tpdm. Continuous change creates CMB data set elements on every CMBCLK edge. @@ -187,7 +187,7 @@ Description: (Write) Set the data collection mode of CM= B tpdm. Continuous =20 What: /sys/bus/coresight/devices//cmb_trig_patt/xpr[0:1] Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the value of the trigger pattern for the CMB @@ -195,7 +195,7 @@ Description: =20 What: /sys/bus/coresight/devices//cmb_trig_patt/xpmr[0:1] Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the mask of the trigger pattern for the CMB @@ -203,21 +203,21 @@ Description: =20 What: /sys/bus/coresight/devices//dsb_patt/tpr[0:1] Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the value of the pattern for the CMB subunit TPDM. =20 What: /sys/bus/coresight/devices//dsb_patt/tpmr[0:1] Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the mask of the pattern for the CMB subunit TPDM. =20 What: /sys/bus/coresight/devices//cmb_patt/enable_ts Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (Write) Set the pattern timestamp of CMB tpdm. Read @@ -229,7 +229,7 @@ Description: =20 What: /sys/bus/coresight/devices//cmb_trig_ts Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the trigger timestamp of the CMB for tpdm. @@ -240,7 +240,7 @@ Description: =20 What: /sys/bus/coresight/devices//cmb_ts_all Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Read or write the status of timestamp upon all interface. @@ -252,7 +252,7 @@ Description: =20 What: /sys/bus/coresight/devices//cmb_msr/msr[0:31] Date: January 2024 -KernelVersion 6.9 +KernelVersion: 6.9 Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) <= quic_taozha@quicinc.com> Description: (RW) Set/Get the MSR(mux select register) for the CMB subunit --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 7C08E1C5F10; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=QXU8d7cGUYAi40iCB7hfWpcv/3oOjxKdQwh48RmqYOG4psOg5+mPsK2MkWwwqvsypUA3KWhlxJm4EBfPn1RM80yAzGVfSxkhO/7sqlLSbK6rSkhhe7CpyfVdHt57SVITVoV3tbUoMkTKVldTeXTbtIg3fFMjGIeYsPoy1G3HSiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=erz4OcTOvbnxgyfwrQKNDa0AznbtN3e8j1C5SQqASZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JWzCIizy7P4sNUK3kOcRZv2VUfjCASlWn1gLRdmmL5TqW4Q+rifkb+kolg8qSTaD4yUSgedbFoqAaOQmMVZisnjQ6ghwaCz2cao5R2PwCRkT/Wd3aJv8Gf1cIXLzAB8t0QRd7cDvu4kmKoBIukRiI66xTep9STaCDJdLs8P9VUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tJuJo/Za; 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="tJuJo/Za" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC8F7C4CEE5; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182703; bh=erz4OcTOvbnxgyfwrQKNDa0AznbtN3e8j1C5SQqASZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tJuJo/Za2UZaLzMPkWM3ErN6CEdY1JXAh9kUsv7ercsTEbVbPzt66nmVGL0xVLwWM jCdc7e+jNQfCM0vKlvrnpegE6LbNJaOFPNKGu1aY0T0RzDwCsySFBopa8bFJwo7EKZ nuy8BpLx3VjaJH747vIO/jtMMO+bRlMSfERbD8r4D2EUnEFS/1zWaUw+U0pBj+0sFu iuvm26DZ609zLPb7/I4DyqgZGmDhBA8eOG4jRsHoAfPEWPyycR9l+ktT1iZrvmo54U DjNrbOg+x/HER0eFMWPu4IIwZhZgzk3eGU/+JqMcIGHLlWHFi8dZYFpi/CZgFEYget EF8lf8xsf+I5A== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006CiW-05GM; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 06/27] ABI: sysfs-driver-dma-idxd: fix date tags Date: Mon, 10 Feb 2025 11:17:55 +0100 Message-ID: X-Mailer: git-send-email 2.48.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" Some date tags are missing colons. Add them to comply with ABI description and produce right results when converted to html/pdf. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/ABI/stable/sysfs-driver-dma-idxd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/stable/sysfs-driver-dma-idxd b/Documentation= /ABI/stable/sysfs-driver-dma-idxd index f2ec42949a54..4a355e6747ae 100644 --- a/Documentation/ABI/stable/sysfs-driver-dma-idxd +++ b/Documentation/ABI/stable/sysfs-driver-dma-idxd @@ -246,14 +246,14 @@ Description: Controls whether PRS disable is turned o= n for the workqueue. capability. =20 What: /sys/bus/dsa/devices/wq./occupancy -Date May 25, 2021 +Date: May 25, 2021 KernelVersion: 5.14.0 Contact: dmaengine@vger.kernel.org Description: Show the current number of entries in this WQ if WQ Occupancy Support bit WQ capabilities is 1. =20 What: /sys/bus/dsa/devices/wq./enqcmds_retries -Date Oct 29, 2021 +Date: Oct 29, 2021 KernelVersion: 5.17.0 Contact: dmaengine@vger.kernel.org Description: Indicate the number of retires for an enqcmds submission on a= sharedwq. --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 7C1131C5F1F; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=gcW9Gn+bKdnIrTlNa6NyjhJAP3mdsJRKFsjtt96dXi5cOViLPdgxixKNs4HXlZjEFTO+rP7gl3SAr0uLCIHePSNfF+YW4rdJfVVf0LAVfd8XS3EpnMGt4rRYIjhFfpEaM4rSKbQA7ikuzsF0K4n9EMy4rAcRwf2f2sNvowwaROA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=LI59JQtyPV/HF12ShAdqHJX2HFF3NXc8/5bk+IONPNM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=raoHHuRsIlSqI0R0d7e/ryHcoViV9+i+huj+4s/YkWZHHAQ1UQ1196OApwfVM4UcWcirHilaqBhLfP0A/zvLpGy7OckzCK4w3x/eaVK+1rGi21ZgFhRWS66k93MSJqYWxukbvXFRiAwqmPLbss2ybzDMzQ3pMuy9A1M2t8m+Rdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nO62iX7S; 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="nO62iX7S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFD75C4CEEB; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=LI59JQtyPV/HF12ShAdqHJX2HFF3NXc8/5bk+IONPNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nO62iX7S28S3shm7FksdxtyPreI2cGS6vi10HoQx+ObzswtwhDDeWQtpScBku+cfh gFhql5aAGvyOhNISZ5EmnbovIYanDSAbdfvNYT+CKFtBe6ShOJXPBPH62dZPUtSFsH /9DXMZ5Za8qeXXjLFCBjJMQBdOUmiKF9a8r90j1LbiNP7OuZPI3Fz/XJt3ZLjQ3cy7 OMmb8sI73yuK0P0M54zqtxXza6o7rx4Jrr4iEiW7RQFwdUnO4k3Fsk2ZOmgg/S37TM /1gYxlDf5k72He6hNuyZAtv/irgoR/KpiU0WidVNS2SX97c5eB1TEpJO0gNkTo0o2C 8nocUmRXPqJ7A== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cia-0CEy; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , Chao Yu , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 07/27] ABI: sysfs-fs-f2fs: fix date tags Date: Mon, 10 Feb 2025 11:17:56 +0100 Message-ID: <336ab631c0636e419282a38e7dd5b5cfb52fcd2d.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Some date tags are missing colons. Add them to comply with ABI description and produce right results when converted to html/pdf. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/ABI/testing/sysfs-fs-f2fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/te= sting/sysfs-fs-f2fs index 3e1630c70d8a..e44bb614964b 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -347,7 +347,7 @@ Description: Used to control configure extension list: - [c] means add/del cold file extension =20 What: /sys/fs/f2fs//unusable -Date April 2019 +Date: April 2019 Contact: "Daniel Rosenberg" Description: If checkpoint=3Ddisable, it displays the number of blocks that are unusable. @@ -355,7 +355,7 @@ Description: If checkpoint=3Ddisable, it displays the n= umber of blocks that would be unusable if checkpoint=3Ddisable were to be set. =20 What: /sys/fs/f2fs//encoding -Date July 2019 +Date: July 2019 Contact: "Daniel Rosenberg" Description: Displays name and version of the encoding set for the filesys= tem. If no encoding is set, displays (none) --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 BBEC01CAA76; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=aXhi9IW+tpNRMJEjT16Ubv2Icbgh1DRglQfZb4nVytm6sbei2KPvNZ0TML5wRQAhs42pOEzeSQA6fiDnzfpTDEjqIFFnGBpDKgp2R8z9otijkB/qcNluDoCAw/e2eHsqQJyn2fbeDOaCqbNRHguH5DeQBlYStFJvKlaeqYXfikI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=Tj1nz2RZBql0geo5lraeHUCDCc6IdX7LSdJsN5wj1mY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TT+stvLAcUFpEKtBvbImHQ0Dj/I+rli9lBcXZCNfygEPnEO4O7zj6PdZIz/HjapbrWDJq9/PofVKeSftm817wT0T+G88IbqpyvtpiouBbHqTLndS/0jKYqvVruJTUPPeS9xd8PRjDqmuWD4A8ahgTnLfLvv/VIHyvXx86435MlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gkyTn+T4; 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="gkyTn+T4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBB2BC4CEEE; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=Tj1nz2RZBql0geo5lraeHUCDCc6IdX7LSdJsN5wj1mY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gkyTn+T46XmjwUvB/NsFZsATTY/D6pP/CIlfrDaTdKfLuO7Kd+EPuT2Q0fOpEGyRp U4I8VplC4l0zulyZbxvHIU2A5wUEyR3x6TXDHdVF2JSnmKY47bYLha5H17eE/0Fgdr F7WFjVRuy/POEFg/mIPz9fypejZtXihLQJZc9PMxZOqUvybP9GYM+cC77fMPLZQzbT eEsb7flvm3GCMb8uR0AsnDXaR8ilHtSN875HSnv434GiNHrHtWkwzpce7D0zIvh0/T 2mppWRtGG2Oe8X7LnxSdXktEELekU1oBMMmKUYVYpKSAH6gfPnV6gxkw/ii0YImvm2 qUGi38cKe2Hhg== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cie-0IyP; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 08/27] ABI: sysfs-power: fix a what tag Date: Mon, 10 Feb 2025 11:17:57 +0100 Message-ID: <508051136ea2e07e0dd7fa41ff40382387c24ba8.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" There is one What tag that it is using semicolon instead of colon. Fix it to comply with ABI description and produce right results when converted to html/pdf. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/ABI/testing/sysfs-power | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/test= ing/sysfs-power index a3942b1036e2..2192478e83cf 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power @@ -131,7 +131,7 @@ Description: CAUTION: Using it will cause your machine's real-time (CMOS) clock to be set to a random invalid time after a resume. =20 -What; /sys/power/pm_trace_dev_match +What: /sys/power/pm_trace_dev_match Date: October 2010 Contact: James Hogan Description: --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 ABBEC1C9EAA; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=U7gfJsu9A+uQ9duiZ8cM5Rjm+cfNCDMIcEWceG5hhTZEXGnl84trxkRQvz5K3x5UHoH/RpA6TDPzoJ+RHLpU0ik3oET+k8tjnK39yAgkG0PAVTWqLrOMRjaVakz9vcLEr6YEEgZXVEkBpunGaDE3Hkv8MlNcxDl3nUu5mfrIOjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=0f7tLKTuX4jKgrpwqlZrJAjeosOKAdyvIyBElssJbRg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TH0KdMLjuG287DZ83q8iiu35qPSfJ1sIs+tHevNiOC/NnEamv7gPeHKvbaRx5LPkYSM9+k1l/2qNi9ClM5WtqfdY0pA8fzZA+VZHWTV88hQqFa+/m/g/owwZRQvrqzkM4J5ro285uRjoPLBZjbkYn0p1ianGyFU+LxP3d/sYxs8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gFpCRKsh; 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="gFpCRKsh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8DFFC4CEEC; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=0f7tLKTuX4jKgrpwqlZrJAjeosOKAdyvIyBElssJbRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFpCRKshyXHPkW8Pa5qqFE3RBtolfl3uSLLR2Hk5loLvpXm8nj4A8eACN+usbv/bv uWP7YJPfufIbhDBoiqvZJujd+XO3SW1eH7m2l1jYB/Lh1ly7aPr+XuUHBFBergkTTI 7nLoBbs8vK0dru3uRub8c2Nah/aIisbdDaPcS0Y415idsCFFHBK94C0HNVD40FpZ0V eq3OleQfskY91HFwxKnaiyjNp8I4sYmGz5UYgjfBSgBhWqpiJyN7tMfhiC154noBmh DRZ6cXPJ0qAyCa+Yuro/r95eu0DyaJhgI4oS0HKWB3TZDyX5N2c/1ukFej3JNqULNO tGEu5KGABbmsQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cii-0PuR; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 09/27] scripts/documentation-file-ref-check: don't check perl/python scripts Date: Mon, 10 Feb 2025 11:17:58 +0100 Message-ID: <712bfc8412ee5ad8ab43dd21a8c30fc858eff5a6.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Such scripts may have regular expressions, which would make the parser confusing. Also, they shouldn't hardcode filenames there, so skipping them is OK. While here, also don't check references on extensions used for file backup and patch rej/orig. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/documentation-file-ref-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/documentation-file-ref-check b/scripts/documentation-f= ile-ref-check index 68083f2f1122..408b1dbe7884 100755 --- a/scripts/documentation-file-ref-check +++ b/scripts/documentation-file-ref-check @@ -92,7 +92,7 @@ while () { next if ($f =3D~ m,^Next/,); =20 # Makefiles and scripts contain nasty expressions to parse docs - next if ($f =3D~ m/Makefile/ || $f =3D~ m/\.sh$/); + next if ($f =3D~ m/Makefile/ || $f =3D~ m/\.(sh|py|pl|~|rej|org|orig)$/); =20 # It doesn't make sense to parse hidden files next if ($f =3D~ m#/\.#); --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 2F4ED1DE4CE; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=ixhbPmvKVJEHPs55lm5oFzrwXXsRYVHf+fXgdY2rT25trGC0HfA1hj2XuK+pW6Wu2yTrSdV7ImLuDOGAimu7Zn8OFT6gWfinZiJOu0fVtJ+JZ03oC15aJB8TJbRN+tC/cY/f5WkApaxOCi2ICf1SREBtxJOHx3KdJs1l89mLGFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=IicVwLTuB76oueVrS4jhShL6OGXHV7R7qLE2HyzTv7E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lcJjY1UfGH5eEKkVPBK+rPpFzd2VV/t0pU/EM9sm1rJe+3AmjZArP+sHlAR9Wi/u7CfnPvGNL7Hnx2JeGfJUMJv3C84PRMFrhByB9jaoQHso6urW5BsP3Afsokc9vIR4ppk4GMxBRcpDGWZludxN/ppjZvLI8zXvjG3NZ+IHb38= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s5HdIb20; 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="s5HdIb20" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF141C4CEF1; Mon, 10 Feb 2025 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=IicVwLTuB76oueVrS4jhShL6OGXHV7R7qLE2HyzTv7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s5HdIb20+JWg+Kk+buxlZR1s9Z7RuLq0+diIj1rd7L+NByPQ3Qx+vDATNJIW/rl3q 24XMRsEBChzNjqNzpOoYkZK0mxTZ/299Z3H6jqnq+IvTtI495VBgNuZ66PkxwJsxuX yROudgb9dRn/QFugR9auaVywYgVNxgydckqZjBFZd438iiQGkZskB3B8c5RLHiU1Lk pzvPHnSer5m2vLGHiIbcewhl0blrKA6fmHIaRj7IK1/LGcQjY7wmv3a/ULFyXcRnHt 1vHscfYcW+1ZyZ9y6HbTGg5dqQKcNQ4I36kHXLWqgxckjdH0ppWVqgXWuI+qu+OZKm 0J42b2M7K7IGA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cim-0Wui; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 10/27] scripts/get_abi.py: add a Python tool to generate ReST output Date: Mon, 10 Feb 2025 11:17:59 +0100 Message-ID: <71a894211a8b69664711144d9c4f8a0e73d1ae3c.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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 get_abi.pl script is requiring some care, but it seems that the number of changes on it since when I originally wrote it was not too high. Maintaining perl scripts without using classes requires a higher efforted than on python, due to global variables management. Also, it sounds easier to find python developer those days than perl ones. As a plus, using a Python class to handle ABI allows a better integration with Sphinx extensions, allowing, for instance, to let automarkup to generate cross-references for ABI symbols. With that in mind, rewrite the core of get_abi.pl in Python, using classes, to help producing documentation. This will allow a better integration in the future with the Sphinx ABI extension. The algorithms used there are the same as the ones in Perl, with a couple of cleanups to remove redundant variables and to help with cross-reference generation. While doing that, remove some code that were important in the past, where ABI files weren't using ReST format. Some minor improvements were added like using a fixed seed when generating ABI keys for duplicated names, making its results reproductible. The end script is a little bit faster than the original one (tested on a machine with ssd disks). That's probably because we're now using only pre-compiled regular expressions, and it is using string replacement methods instead of regex where possible. The new version is a little bit more conservative when converting text to cross-references to avoid adding them into literal blocks. To ensure that the ReST output is parsing all variables and files properly, the end result was compared using diff with the one produced by the perl script and showed no regressions. There are minor improvements at the results, as it now properly groups What on some special cases. It also better escape some XREF names. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/get_abi.py | 118 ++++++++ scripts/lib/abi/abi_parser.py | 512 ++++++++++++++++++++++++++++++++++ scripts/lib/abi/helpers.py | 28 ++ 3 files changed, 658 insertions(+) create mode 100755 scripts/get_abi.py create mode 100644 scripts/lib/abi/abi_parser.py create mode 100644 scripts/lib/abi/helpers.py diff --git a/scripts/get_abi.py b/scripts/get_abi.py new file mode 100755 index 000000000000..bb17c54feeff --- /dev/null +++ b/scripts/get_abi.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +# pylint: disable=3DR0903 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# SPDX-License-Identifier: GPL-2.0 + +""" +Parse ABI documentation and produce results from it. +""" + +import argparse +import logging +import os +import sys + +# Import Python modules + +LIB_DIR =3D "lib/abi" +SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) + +sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) + +from abi_parser import AbiParser # pylint: disable=3DC0413 +from helpers import ABI_DIR, DEBUG_HELP # pylint: disable=3DC0413 + +# Command line classes + + +REST_DESC =3D """ +Produce output in ReST format. + +The output is done on two sections: + +- Symbols: show all parsed symbols in alphabetic order; +- Files: cross reference the content of each file with the symbols on it. +""" + +class AbiRest: + """Initialize an argparse subparser for rest output""" + + def __init__(self, subparsers): + """Initialize argparse subparsers""" + + parser =3D subparsers.add_parser("rest", + formatter_class=3Dargparse.RawTextH= elpFormatter, + description=3DREST_DESC) + + parser.add_argument("--enable-lineno", action=3D"store_true", + help=3D"enable lineno") + parser.add_argument("--raw", action=3D"store_true", + help=3D"output text as contained in the ABI fi= les. " + "It not used, output will contain dynamic= ally" + " generated cross references when possibl= e.") + parser.add_argument("--no-file", action=3D"store_true", + help=3D"Don't the files section") + parser.add_argument("--show-hints", help=3D"Show-hints") + + parser.set_defaults(func=3Dself.run) + + def run(self, args): + """Run subparser""" + + parser =3D AbiParser(args.dir, debug=3Dargs.debug) + parser.parse_abi() + parser.check_issues() + parser.print_data(args.enable_lineno, args.raw, not args.no_file) + + +class AbiValidate: + """Initialize an argparse subparser for ABI validation""" + + def __init__(self, subparsers): + """Initialize argparse subparsers""" + + parser =3D subparsers.add_parser("validate", + formatter_class=3Dargparse.Argument= DefaultsHelpFormatter, + description=3D"list events") + + parser.set_defaults(func=3Dself.run) + + def run(self, args): + """Run subparser""" + + parser =3D AbiParser(args.dir, debug=3Dargs.debug) + parser.parse_abi() + parser.check_issues() + + +def main(): + """Main program""" + + parser =3D argparse.ArgumentParser(formatter_class=3Dargparse.RawTextH= elpFormatter) + + parser.add_argument("-d", "--debug", type=3Dint, default=3D0, help=3D"= debug level") + parser.add_argument("-D", "--dir", default=3DABI_DIR, help=3DDEBUG_HEL= P) + + subparsers =3D parser.add_subparsers() + + AbiRest(subparsers) + AbiValidate(subparsers) + + args =3D parser.parse_args() + + if args.debug: + level =3D logging.DEBUG + else: + level =3D logging.INFO + + logging.basicConfig(level=3Dlevel, format=3D"[%(levelname)s] %(message= )s") + + if "func" in args: + args.func(args) + else: + sys.exit(f"Please specify a valid command for {sys.argv[0]}") + + +# Call main method +if __name__ =3D=3D "__main__": + main() diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py new file mode 100644 index 000000000000..b3fa70eee412 --- /dev/null +++ b/scripts/lib/abi/abi_parser.py @@ -0,0 +1,512 @@ +#!/usr/bin/env python3 +# pylint: disable=3DR0902,R0903,R0911,R0912,R0913,R0914,R0915,R0917,C0302 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# SPDX-License-Identifier: GPL-2.0 + +""" +Parse ABI documentation and produce results from it. +""" + +from argparse import Namespace +import logging +import os +import re + +from glob import glob +from pprint import pformat +from random import randrange, seed + +# Import Python modules + +from helpers import AbiDebug, ABI_DIR + + +class AbiParser: + """Main class to parse ABI files""" + + TAGS =3D r"(what|where|date|kernelversion|contact|description|users)" + XREF =3D r"(?:^|\s|\()(\/(?:sys|config|proc|dev|kvd)\/[^,.:;\)\s]+)(?:= [,.:;\)\s]|\Z)" + + def __init__(self, directory, logger=3DNone, + enable_lineno=3DFalse, show_warnings=3DTrue, debug=3D0): + """Stores arguments for the class and initialize class vars""" + + self.directory =3D directory + self.enable_lineno =3D enable_lineno + self.show_warnings =3D show_warnings + self.debug =3D debug + + if not logger: + self.log =3D logging.getLogger("get_abi") + else: + self.log =3D logger + + self.data =3D {} + self.what_symbols =3D {} + self.file_refs =3D {} + self.what_refs =3D {} + + # Regular expressions used on parser + self.re_tag =3D re.compile(r"(\S+)(:\s*)(.*)", re.I) + self.re_valid =3D re.compile(self.TAGS) + self.re_start_spc =3D re.compile(r"(\s*)(\S.*)") + self.re_whitespace =3D re.compile(r"^\s+") + + # Regular used on print + self.re_what =3D re.compile(r"(\/?(?:[\w\-]+\/?){1,2})") + self.re_escape =3D re.compile(r"([\.\x01-\x08\x0e-\x1f\x21-\x2f\x3= a-\x40\x7b-\xff])") + self.re_unprintable =3D re.compile(r"([\x00-\x2f\x3a-\x40\x5b-\x60= \x7b-\xff]+)") + self.re_title_mark =3D re.compile(r"\n[\-\*\=3D\^\~]+\n") + self.re_doc =3D re.compile(r"Documentation/(?!devicetree)(\S+)\.rs= t") + self.re_abi =3D re.compile(r"(Documentation/ABI/)([\w\/\-]+)") + self.re_xref_node =3D re.compile(self.XREF) + + def warn(self, fdata, msg, extra=3DNone): + """Displays a parse error if warning is enabled""" + + if not self.show_warnings: + return + + msg =3D f"{fdata.fname}:{fdata.ln}: {msg}" + if extra: + msg +=3D "\n\t\t" + extra + + self.log.warning(msg) + + def add_symbol(self, what, fname, ln=3DNone, xref=3DNone): + """Create a reference table describing where each 'what' is locate= d""" + + if what not in self.what_symbols: + self.what_symbols[what] =3D {"file": {}} + + if fname not in self.what_symbols[what]["file"]: + self.what_symbols[what]["file"][fname] =3D [] + + if ln and ln not in self.what_symbols[what]["file"][fname]: + self.what_symbols[what]["file"][fname].append(ln) + + if xref: + self.what_symbols[what]["xref"] =3D xref + + def _parse_line(self, fdata, line): + """Parse a single line of an ABI file""" + + new_what =3D False + new_tag =3D False + content =3D None + + match =3D self.re_tag.match(line) + if match: + new =3D match.group(1).lower() + sep =3D match.group(2) + content =3D match.group(3) + + match =3D self.re_valid.search(new) + if match: + new_tag =3D match.group(1) + else: + if fdata.tag =3D=3D "description": + # New "tag" is actually part of description. + # Don't consider it a tag + new_tag =3D False + elif fdata.tag !=3D "": + self.warn(fdata, f"tag '{fdata.tag}' is invalid", line) + + if new_tag: + # "where" is Invalid, but was a common mistake. Warn if found + if new_tag =3D=3D "where": + self.warn(fdata, "tag 'Where' is invalid. Should be 'What:= ' instead") + new_tag =3D "what" + + if new_tag =3D=3D "what": + fdata.space =3D None + + if content not in self.what_symbols: + self.add_symbol(what=3Dcontent, fname=3Dfdata.fname, l= n=3Dfdata.ln) + + if fdata.tag =3D=3D "what": + fdata.what.append(content.strip("\n")) + else: + if fdata.key: + if "description" not in self.data.get(fdata.key, {= }): + self.warn(fdata, f"{fdata.key} doesn't have a = description") + + for w in fdata.what: + self.add_symbol(what=3Dw, fname=3Dfdata.fname, + ln=3Dfdata.what_ln, xref=3Dfda= ta.key) + + fdata.label =3D content + new_what =3D True + + key =3D "abi_" + content.lower() + fdata.key =3D self.re_unprintable.sub("_", key).strip(= "_") + + # Avoid duplicated keys but using a defined seed, to m= ake + # the namespace identical if there aren't changes at t= he + # ABI symbols + seed(42) + + while fdata.key in self.data: + char =3D randrange(0, 51) + ord("A") + if char > ord("Z"): + char +=3D ord("a") - ord("Z") - 1 + + fdata.key +=3D chr(char) + + if fdata.key and fdata.key not in self.data: + self.data[fdata.key] =3D { + "what": [content], + "file": [fdata.file_ref], + "line_no": fdata.ln, + } + + fdata.what =3D self.data[fdata.key]["what"] + + self.what_refs[content] =3D fdata.key + fdata.tag =3D new_tag + fdata.what_ln =3D fdata.ln + + if fdata.nametag["what"]: + t =3D (content, fdata.key) + if t not in fdata.nametag["symbols"]: + fdata.nametag["symbols"].append(t) + + return + + if fdata.tag and new_tag: + fdata.tag =3D new_tag + + if new_what: + fdata.label =3D "" + + self.data[fdata.key]["type"] =3D fdata.ftype + + if "description" in self.data[fdata.key]: + self.data[fdata.key]["description"] +=3D "\n\n" + + if fdata.file_ref not in self.data[fdata.key]["file"]: + self.data[fdata.key]["file"].append(fdata.file_ref) + + if self.debug =3D=3D AbiDebug.WHAT_PARSING: + self.log.debug("what: %s", fdata.what) + + if not fdata.what: + self.warn(fdata, "'What:' should come first:", line) + return + + if new_tag =3D=3D "description": + fdata.space =3D None + + if content: + sep =3D sep.replace(":", " ") + + c =3D " " * len(new_tag) + sep + content + c =3D c.expandtabs() + + match =3D self.re_start_spc.match(c) + if match: + # Preserve initial spaces for the first line + fdata.space =3D match.group(1) + content =3D match.group(2) + "\n" + + self.data[fdata.key][fdata.tag] =3D content + + return + + # Store any contents before tags at the database + if not fdata.tag and "what" in fdata.nametag: + fdata.nametag["description"] +=3D line + return + + if fdata.tag =3D=3D "description": + content =3D line.expandtabs() + + if self.re_whitespace.sub("", content) =3D=3D "": + self.data[fdata.key][fdata.tag] +=3D "\n" + return + + if fdata.space is None: + match =3D self.re_start_spc.match(content) + if match: + # Preserve initial spaces for the first line + fdata.space =3D match.group(1) + + content =3D match.group(2) + "\n" + else: + if content.startswith(fdata.space): + content =3D content[len(fdata.space):] + + else: + fdata.space =3D "" + + if fdata.tag =3D=3D "what": + w =3D content.strip("\n") + if w: + self.data[fdata.key][fdata.tag].append(w) + else: + self.data[fdata.key][fdata.tag] +=3D content + return + + content =3D line.strip() + if fdata.tag: + if fdata.tag =3D=3D "what": + w =3D content.strip("\n") + if w: + self.data[fdata.key][fdata.tag].append(w) + else: + self.data[fdata.key][fdata.tag] +=3D "\n" + content.rstrip= ("\n") + return + + # Everything else is error + if content: + self.warn(fdata, "Unexpected content", line) + + def parse_file(self, fname, path, basename): + """Parse a single file""" + + ref =3D f"abi_file_{path}_{basename}" + ref =3D self.re_unprintable.sub("_", ref).strip("_") + + # Store per-file state into a namespace variable. This will be used + # by the per-line parser state machine and by the warning function. + fdata =3D Namespace + + fdata.fname =3D fname + fdata.name =3D basename + + pos =3D fname.find(ABI_DIR) + if pos > 0: + f =3D fname[pos:] + else: + f =3D fname + + fdata.file_ref =3D (f, ref) + self.file_refs[f] =3D ref + + fdata.ln =3D 0 + fdata.what_ln =3D 0 + fdata.tag =3D "" + fdata.label =3D "" + fdata.what =3D [] + fdata.key =3D None + fdata.xrefs =3D None + fdata.space =3D None + fdata.ftype =3D path.split("/")[0] + + fdata.nametag =3D {} + fdata.nametag["what"] =3D [f"File {path}/{basename}"] + fdata.nametag["type"] =3D "File" + fdata.nametag["file"] =3D [fdata.file_ref] + fdata.nametag["line_no"] =3D 1 + fdata.nametag["description"] =3D "" + fdata.nametag["symbols"] =3D [] + + self.data[ref] =3D fdata.nametag + + if self.debug & AbiDebug.WHAT_OPEN: + self.log.debug("Opening file %s", fname) + + with open(fname, "r", encoding=3D"utf8", errors=3D"backslashreplac= e") as fp: + for line in fp: + fdata.ln +=3D 1 + + self._parse_line(fdata, line) + + if "description" in fdata.nametag: + fdata.nametag["description"] =3D fdata.nametag["descriptio= n"].lstrip("\n") + + if fdata.key: + if "description" not in self.data.get(fdata.key, {}): + self.warn(fdata, f"{fdata.key} doesn't have a descript= ion") + + for w in fdata.what: + self.add_symbol(what=3Dw, fname=3Dfname, xref=3Dfdata.= key) + + def parse_abi(self): + """Parse documentation ABI""" + + ignore_suffixes =3D ("rej", "org", "orig", "bak", "~") + re_abi =3D re.compile(r".*" + ABI_DIR) + + for fname in glob(os.path.join(self.directory, "**"), recursive=3D= True): + if os.path.isdir(fname): + continue + + basename =3D os.path.basename(fname) + + if basename =3D=3D "README": + continue + if basename.startswith(".") or basename.endswith(ignore_suffix= es): + continue + + path =3D re_abi.sub("", os.path.dirname(fname)) + + self.parse_file(fname, path, basename) + + if self.debug & AbiDebug.DUMP_ABI_STRUCTS: + self.log.debug(pformat(self.data)) + + def print_desc_txt(self, desc): + """Print description as found inside ABI files""" + + desc =3D desc.strip(" \t\n") + + print(desc + "\n") + + def print_desc_rst(self, desc): + """Enrich ReST output by creating cross-references""" + + # Remove title markups from the description + # Having titles inside ABI files will only work if extra + # care would be taken in order to strictly follow the same + # level order for each markup. + desc =3D self.re_title_mark.sub("\n\n", "\n" + desc) + desc =3D desc.rstrip(" \t\n").lstrip("\n") + + # Python's regex performance for non-compiled expressions is a lot + # than Perl, as Perl automatically caches them at their + # first usage. Here, we'll need to do the same, as otherwise the + # performance penalty is be high + + new_desc =3D "" + for d in desc.split("\n"): + if d =3D=3D "": + new_desc +=3D "\n" + continue + + # Use cross-references for doc files where needed + d =3D self.re_doc.sub(r":doc:`/\1`", d) + + # Use cross-references for ABI generated docs where needed + matches =3D self.re_abi.findall(d) + for m in matches: + abi =3D m[0] + m[1] + + xref =3D self.file_refs.get(abi) + if not xref: + # This may happen if ABI is on a separate directory, + # like parsing ABI testing and symbol is at stable. + # The proper solution is to move this part of the code + # for it to be inside sphinx/kernel_abi.py + self.log.info("Didn't find ABI reference for '%s'", ab= i) + else: + new =3D self.re_escape.sub(r"\\\1", m[1]) + d =3D re.sub(fr"\b{abi}\b", f":ref:`{new} <{xref}>`", = d) + + # Seek for cross reference symbols like /sys/... + # Need to be careful to avoid doing it on a code block + if d[0] not in [" ", "\t"]: + matches =3D self.re_xref_node.findall(d) + for m in matches: + # Finding ABI here is more complex due to wildcards + xref =3D self.what_refs.get(m) + if xref: + new =3D self.re_escape.sub(r"\\\1", m) + d =3D re.sub(fr"\b{m}\b", f":ref:`{new} <{xref}>`"= , d) + + new_desc +=3D d + "\n" + + print(new_desc + "\n") + + def print_data(self, enable_lineno, output_in_txt, show_file=3DFalse): + """Print ABI at stdout""" + + part =3D None + for key, v in sorted(self.data.items(), + key=3Dlambda x: (x[1].get("type", ""), + x[1].get("what"))): + + wtype =3D v.get("type", "Var") + file_ref =3D v.get("file") + names =3D v.get("what", [""]) + + if not show_file and wtype =3D=3D "File": + continue + + if enable_lineno: + ln =3D v.get("line_no", 1) + print(f".. LINENO {file_ref[0][0]}#{ln}\n") + + if wtype !=3D "File": + cur_part =3D names[0] + if cur_part.find("/") >=3D 0: + match =3D self.re_what.match(cur_part) + if match: + symbol =3D match.group(1).rstrip("/") + cur_part =3D "Symbols under " + symbol + + if cur_part and cur_part !=3D part: + part =3D cur_part + print(f"{part}\n{"-" * len(part)}\n") + + print(f".. _{key}:\n") + + max_len =3D 0 + for i in range(0, len(names)): # pylint: disable= =3DC0200 + names[i] =3D "**" + self.re_escape.sub(r"\\\1", names[= i]) + "**" + + max_len =3D max(max_len, len(names[i])) + + print("+-" + "-" * max_len + "-+") + for name in names: + print(f"| {name}" + " " * (max_len - len(name)) + " |") + print("+-" + "-" * max_len + "-+") + print() + + for ref in file_ref: + if wtype =3D=3D "File": + print(f".. _{ref[1]}:\n") + else: + base =3D os.path.basename(ref[0]) + print(f"Defined on file :ref:`{base} <{ref[1]}>`\n") + + if wtype =3D=3D "File": + print(f"{names[0]}\n{"-" * len(names[0])}\n") + + desc =3D v.get("description") + if not desc and wtype !=3D "File": + print(f"DESCRIPTION MISSING for {names[0]}\n") + + if desc: + if output_in_txt: + self.print_desc_txt(desc) + else: + self.print_desc_rst(desc) + + symbols =3D v.get("symbols") + if symbols: + print("Has the following ABI:\n") + + for w, label in symbols: + # Escape special chars from content + content =3D self.re_escape.sub(r"\\\1", w) + + print(f"- :ref:`{content} <{label}>`\n") + + users =3D v.get("users") + if users and users.strip(" \t\n"): + print(f"Users:\n\t{users.strip("\n").replace('\n', '\n\t')= }\n") + + def check_issues(self): + """Warn about duplicated ABI entries""" + + for what, v in self.what_symbols.items(): + files =3D v.get("file") + if not files: + # Should never happen if the parser works properly + self.log.warning("%s doesn't have a file associated", what) + continue + + if len(files) =3D=3D 1: + continue + + f =3D [] + for fname, lines in sorted(files.items()): + if not lines: + f.append(f"{fname}") + elif len(lines) =3D=3D 1: + f.append(f"{fname}:{lines[0]}") + else: + f.append(f"{fname} lines {", ".join(str(x) for x in li= nes)}") + + self.log.warning("%s is defined %d times: %s", what, len(f), "= ; ".join(f)) diff --git a/scripts/lib/abi/helpers.py b/scripts/lib/abi/helpers.py new file mode 100644 index 000000000000..84a253ed5058 --- /dev/null +++ b/scripts/lib/abi/helpers.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# pylint: disable=3DR0903 +# SPDX-License-Identifier: GPL-2.0 + +""" +Helper classes for ABI parser +""" + +ABI_DIR =3D "Documentation/ABI/" + + +class AbiDebug: + """Debug levels""" + + WHAT_PARSING =3D 1 + WHAT_OPEN =3D 2 + DUMP_ABI_STRUCTS =3D 4 + + +DEBUG_HELP =3D """ +Print debug information according with the level(s), +which is given by the following bitmask: + +1 - enable debug parsing logic +2 - enable debug messages on file open +4 - enable debug for ABI parse data +""" --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 C4CC31CAA88; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=I+E3mZDdUOsvTGUKiUcN1aopOeOCebq2dNlF90kU+V3FQUOWYiv1aBXlaxn2imAabO9wpxe40ndvzkWCTY/2pvCL+Q6vbNJ169PuXzFhMeoOkX5iuDpSAiM5Oa+fPpPm65jYINpZN3wpR8kHRtPPzahSD4xK6k77NvbbOsiDw3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=FlLRiN2V72fQvc3QqtN/JA2r//R7FqyHjc0oxGoo5k8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sUgF29wqVOXMaXqnK3NSGaT+D1UQqFhQ7YHqLeU7Ld1NkerKnN0vNEFjXP6fC1y/keo7owAh6e3KyS8nyJGWUSTwEEmbm4Op3U0ev61RXB4mDScAUlJnVX6ddQ6UZv1TrKuwtEmW1n2gc1v+dOyaEKFw1P4A6MCqCMN65H/wglg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GtPt9cUZ; 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="GtPt9cUZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12661C4CEF4; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=FlLRiN2V72fQvc3QqtN/JA2r//R7FqyHjc0oxGoo5k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GtPt9cUZeeRoYRN9XgG9wxoeSfdUzhPKM6mumAhz0FEpSb5IPDEXo7cguOAwMvEGf k+cT9WPhQjoXQarwQbs/5qOsk1bD3YJwWkd2frsFZ1pLCYSsWJHWmDUhY2gY9h5qef UhHgN3he0WmEajOrsNcEME/GWIbdhbz/OFuk7SZapEZ7+CDmkhlxWQevdB0JoXKBGJ IYmpnqlPSDK1LfvjfI8zSKJQB4CNvTRIJ6JQefVbOAkJ+MtlsIYfpesTYK98gSz+4G VaMV0niyA5Fv9J3edCQX1nVLVRYxOh1FDSNpRbv3vHcfSm9mEDo0RNeoRJM4Yqm9Fp D6cCElc+Ay/wg== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Ciq-0dv0; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 11/27] scripts/get_abi.py: add support for symbol search Date: Mon, 10 Feb 2025 11:18:00 +0100 Message-ID: <21b2c48657dde112d5417dcd7e0aa7cd383b9a0a.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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 support for searching symbols from Documentation/ABI using regular expressions to match the symbols' names. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/get_abi.py | 24 ++++++++++++++++ scripts/lib/abi/abi_parser.py | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/scripts/get_abi.py b/scripts/get_abi.py index bb17c54feeff..30439f21fdd0 100755 --- a/scripts/get_abi.py +++ b/scripts/get_abi.py @@ -85,6 +85,29 @@ class AbiValidate: parser.check_issues() =20 =20 +class AbiSearch: + """Initialize an argparse subparser for ABI search""" + + def __init__(self, subparsers): + """Initialize argparse subparsers""" + + parser =3D subparsers.add_parser("search", + formatter_class=3Dargparse.Argument= DefaultsHelpFormatter, + description=3D"Search ABI using a r= egular expression") + + parser.add_argument("expression", + help=3D"Case-insensitive search pattern for th= e ABI symbol") + + parser.set_defaults(func=3Dself.run) + + def run(self, args): + """Run subparser""" + + parser =3D AbiParser(args.dir, debug=3Dargs.debug) + parser.parse_abi() + parser.search_symbols(args.expression) + + def main(): """Main program""" =20 @@ -97,6 +120,7 @@ def main(): =20 AbiRest(subparsers) AbiValidate(subparsers) + AbiSearch(subparsers) =20 args =3D parser.parse_args() =20 diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index b3fa70eee412..bea7f1a76165 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -510,3 +510,55 @@ class AbiParser: f.append(f"{fname} lines {", ".join(str(x) for x in li= nes)}") =20 self.log.warning("%s is defined %d times: %s", what, len(f), "= ; ".join(f)) + + def search_symbols(self, expr): + """ Searches for ABI symbols """ + + regex =3D re.compile(expr, re.I) + + found_keys =3D 0 + for t in sorted(self.data.items(), key=3Dlambda x: [0]): + v =3D t[1] + + wtype =3D v.get("type", "") + if wtype =3D=3D "File": + continue + + for what in v.get("what", [""]): + if regex.search(what): + found_keys +=3D 1 + + kernelversion =3D v.get("kernelversion", "").strip(" \= t\n") + date =3D v.get("date", "").strip(" \t\n") + contact =3D v.get("contact", "").strip(" \t\n") + users =3D v.get("users", "").strip(" \t\n") + desc =3D v.get("description", "").strip(" \t\n") + + files =3D [] + for f in v.get("file", ()): + files.append(f[0]) + + what =3D str(found_keys) + ". " + what + title_tag =3D "-" * len(what) + + print(f"\n{what}\n{title_tag}\n") + + if kernelversion: + print(f"Kernel version:\t\t{kernelversion}") + + if date: + print(f"Date:\t\t\t{date}") + + if contact: + print(f"Contact:\t\t{contact}") + + if users: + print(f"Users:\t\t\t{users}") + + print(f"Defined on file{'s'[:len(files) ^ 1]}:\t{", ".= join(files)}") + + if desc: + print(f"\n{desc.strip("\n")}\n") + + if not found_keys: + print(f"Regular expression /{expr}/ not found.") --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 C4D4B1CAA89; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=baJrTDTBnAL+HAD1ZlGYVJE0apy3PQAImf6+tKWw1DceKxPf1qtGIPtip0vhSYpXsMzZJby1gzY5dDQLujO3w7uqQn8Sx5eRJyw4cwNz5bNZdODMeb/uKXTuP24O786V560ON432VhRDhqPluUiATXZnVdP84F0UIruXl4Yo1mg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=fVsQktr66AfeetC6nV7WwKf2PIcVVQSSKpg1lW8+WR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Afpe5d/+Vxyrn2BKkfpgxjiu6JaYQy21M8b628NYoqqTITVyXqigT2nNfoJLW/980pF5gHcZi1PfiVL5jl9AqaEzG2xfellYf7/baOcZdlUT5LlzORtJAPsi8tVLBzzTy8/E8CqGTF6q4SRx5SbzmX18M1TUQBTJjgrob9A4lmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LSpR8XzD; 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="LSpR8XzD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 178C0C4CEF6; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=fVsQktr66AfeetC6nV7WwKf2PIcVVQSSKpg1lW8+WR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LSpR8XzDKI/9YW/6Qu9AhPc9P1fgfSg9wB1i7yyKWMY1NSQdOwdq2PLCmanqAx+1Q c/hB3+Y0E/pqF2zGum4RybakxWINpBu7XxkdZBPSju3ch6qzR+wp1ZIDFRhwICRX/8 D1Qza7mz5Wut0yP7gXoM+A/GbTD9dMx6E4530YVBzsCRMV60ZLZwfB1UdLU8wcZH3G ZljBFkyh0lPpRqsZTdpCnqQXMq5EqEsl2EBBtBxSRWrAPM1n8cyd3w4eD8HJrOzg6X 9ZDmfhWmYQxRa1zrc70fdMgkX744xgskrtkFJCFm9GwzN0vQwHpEKu7klyVL5h8a+z UCfAaCbmgSSxA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Ciu-0kiM; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 12/27] docs: use get_abi.py for ABI generation Date: Mon, 10 Feb 2025 11:18:01 +0100 Message-ID: X-Mailer: git-send-email 2.48.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" Use the new script instead of the old one when generating ABI docs. For now, execute it via exec. Future changes will better integrate it by using the class defined there directly. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/admin-guide/abi-obsolete.rst | 1 - Documentation/admin-guide/abi-removed.rst | 1 - Documentation/admin-guide/abi-stable.rst | 1 - Documentation/admin-guide/abi-testing.rst | 1 - Documentation/sphinx/kernel_abi.py | 10 +++------- 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Documentation/admin-guide/abi-obsolete.rst b/Documentation/adm= in-guide/abi-obsolete.rst index b655615917f1..6d4d9ab7b8c3 100644 --- a/Documentation/admin-guide/abi-obsolete.rst +++ b/Documentation/admin-guide/abi-obsolete.rst @@ -10,4 +10,3 @@ The description of the interface will document the reason= why it is obsolete and when it can be expected to be removed. =20 .. kernel-abi:: ABI/obsolete - :rst: diff --git a/Documentation/admin-guide/abi-removed.rst b/Documentation/admi= n-guide/abi-removed.rst index ba941c1af178..9fc78af6f077 100644 --- a/Documentation/admin-guide/abi-removed.rst +++ b/Documentation/admin-guide/abi-removed.rst @@ -4,4 +4,3 @@ ABI removed symbols =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 .. kernel-abi:: ABI/removed - :rst: diff --git a/Documentation/admin-guide/abi-stable.rst b/Documentation/admin= -guide/abi-stable.rst index 5d738f345333..c47c2a295865 100644 --- a/Documentation/admin-guide/abi-stable.rst +++ b/Documentation/admin-guide/abi-stable.rst @@ -13,4 +13,3 @@ Most interfaces (like syscalls) are expected to never cha= nge and always be available. =20 .. kernel-abi:: ABI/stable - :rst: diff --git a/Documentation/admin-guide/abi-testing.rst b/Documentation/admi= n-guide/abi-testing.rst index a867e6578bf7..40b31985e587 100644 --- a/Documentation/admin-guide/abi-testing.rst +++ b/Documentation/admin-guide/abi-testing.rst @@ -19,4 +19,3 @@ name to the description of these interfaces, so that the = kernel developers can easily notify them if any changes occur. =20 .. kernel-abi:: ABI/testing - :rst: diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index 38653f5706c0..f314b888d3de 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -14,7 +14,7 @@ u""" :license: GPL Version 2, June 1991 see Linux/COPYING for details. =20 The ``kernel-abi`` (:py:class:`KernelCmd`) directive calls the - scripts/get_abi.pl script to parse the Kernel ABI files. + scripts/get_abi.py script to parse the Kernel ABI files. =20 Overview of directive's argument and options. =20 @@ -67,7 +67,6 @@ class KernelCmd(Directive): =20 option_spec =3D { "debug" : directives.flag, - "rst" : directives.unchanged } =20 def run(self): @@ -78,15 +77,12 @@ class KernelCmd(Directive): srctree =3D os.path.abspath(os.environ["srctree"]) =20 args =3D [ - os.path.join(srctree, 'scripts/get_abi.pl'), + os.path.join(srctree, 'scripts/get_abi.py'), + '-D', os.path.join(srctree, 'Documentation', self.arguments[0]= ), 'rest', '--enable-lineno', - '--dir', os.path.join(srctree, 'Documentation', self.arguments= [0]), ] =20 - if 'rst' in self.options: - args.append('--rst-source') - lines =3D subprocess.check_output(args, cwd=3Dos.path.dirname(doc.= current_source)).decode('utf-8') nodeList =3D self.nestedParse(lines, self.arguments[0]) return nodeList --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 E1BBA1CCB40; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=IpJNuKZkpPjikkUFypInyxFZ2WNAI3YaUeA5+zbWtfi/HniS80GP56KIcL+iQbS9DeY1mYr4tPoANpTbrU08jiAPkTbEAUgWji4heFnTlB6fjrmv6e82nMcjt1tCPdII9EX+dxEdQcH7iaxTL7jn+lmSXrJ0DaKpogRIZqzGKLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=RqzmVDLNe9DdW+lbrE2RQgi36O2JCG3KESmSozKEG4s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V8ht8Wo7JtRsKXZ692q28J3/WwmxMGousRzSf2IDTCm9G7tpKokSuhSFGm2D8q6y6+VDOJzVxZIE5RADLI7Bj0ec+eqsx8qJO8tyaNrlerXxmpCGk7z5149xDhj8AwQi3AMbUvUo3LOovmRAYKsDVXNZEQQ60Dsj7jo/jntErck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G91Fp+XL; 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="G91Fp+XL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 189D6C4CEF9; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=RqzmVDLNe9DdW+lbrE2RQgi36O2JCG3KESmSozKEG4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G91Fp+XLtfedHi6Zewz592FKCmP4rMMopCwUIRiPRSh8372fdUOlfikEvMZQuuJXT bGLHa60vFYRdDzxFjRnqd7K8YNe3gX3QiUL/6HB73A9wqju1s/p8Q3dc/VM8JT/H2/ Rf3Ha5iPfFiR+z94RBYIAIi2sRCoHWjaflG7gwgaxME4EIr0+MZsXMbv+VNTfAsJVc RCQftOSZatn8xb94lyer5FPXJnyK0gX6RYLRvc5K1YhqXzAV7kOseL8CAnwO+mazA8 N4GnmyasNEEOz1kIefNCVwVq+5W0SPOtwfke9sD0O0BEtfHP8udFolHZTqFex2AIVS 7vsxURIY3WK7A== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Ciy-0rae; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 13/27] scripts/lib/abi/abi_parser.py: optimize parse_abi() function Date: Mon, 10 Feb 2025 11:18:02 +0100 Message-ID: <190dd358897017ed82c56f1e263192215ffbae43.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Instead of using glob, use a recursive function to parse all files. Such change reduces the total excecution time by 15% with my SSD disks. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/lib/abi/abi_parser.py | 57 +++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index bea7f1a76165..6052a8aec443 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -12,7 +12,6 @@ import logging import os import re =20 -from glob import glob from pprint import pformat from random import randrange, seed =20 @@ -46,7 +45,11 @@ class AbiParser: self.file_refs =3D {} self.what_refs =3D {} =20 + # Ignore files that contain such suffixes + self.ignore_suffixes =3D (".rej", ".org", ".orig", ".bak", "~") + # Regular expressions used on parser + self.re_abi_dir =3D re.compile(r"(.*)" + ABI_DIR) self.re_tag =3D re.compile(r"(\S+)(:\s*)(.*)", re.I) self.re_valid =3D re.compile(self.TAGS) self.re_start_spc =3D re.compile(r"(\s*)(\S.*)") @@ -322,26 +325,42 @@ class AbiParser: for w in fdata.what: self.add_symbol(what=3Dw, fname=3Dfname, xref=3Dfdata.= key) =20 - def parse_abi(self): + def _parse_abi(self, root=3DNone): + """Internal function to parse documentation ABI recursively""" + + if not root: + root =3D self.directory + + with os.scandir(root) as obj: + for entry in obj: + name =3D os.path.join(root, entry.name) + + if entry.is_dir(): + self.parse_abi(name) + continue + + if not entry.is_file(): + continue + + basename =3D os.path.basename(name) + + if basename =3D=3D "README": + continue + + if basename.startswith("."): + continue + + if basename.endswith(self.ignore_suffixes): + continue + + path =3D self.re_abi_dir.sub("", os.path.dirname(name)) + + self.parse_file(name, path, basename) + + def parse_abi(self, root=3DNone): """Parse documentation ABI""" =20 - ignore_suffixes =3D ("rej", "org", "orig", "bak", "~") - re_abi =3D re.compile(r".*" + ABI_DIR) - - for fname in glob(os.path.join(self.directory, "**"), recursive=3D= True): - if os.path.isdir(fname): - continue - - basename =3D os.path.basename(fname) - - if basename =3D=3D "README": - continue - if basename.startswith(".") or basename.endswith(ignore_suffix= es): - continue - - path =3D re_abi.sub("", os.path.dirname(fname)) - - self.parse_file(fname, path, basename) + self._parse_abi(root) =20 if self.debug & AbiDebug.DUMP_ABI_STRUCTS: self.log.debug(pformat(self.data)) --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 E1C7B1CCB4B; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=vCQYpFw6LQyD4e0xWpid2SLytpv77uGU/kTh2YCepRmFstYtyqpJ6w9ixBa5kWurpZeIEcgJ/0TOIK9m85cRNXD7ETUwWJCbfdNbDP5KlLCD4ZQkm1e9i9KKfxxYjJLWpzwqpc8RbCObmaO/cYHhRGkm5Dtx/3Y2xuQg3jBAgrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=KxOyE5BKUrI++h92xXMIAQUn0Quywt6iwaXVifE22IU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qDJ2QeMqznPxk3PuIQLGSy+DPG5Ok6Ga8oL3TauVg7dlR8tJUa1K2aKVmGz5JLlPGyFtHDdKYJOjL7S1kkySV/Oq2iMa8y1BlLEMM0WN5BaTcEuXEclxxvNQ/2MDWMK32BTCdhUmAj4Pvzk1Pnv4iaYS8tXNRRtkSu8ERZIftZM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kGnFr2Tm; 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="kGnFr2Tm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FE2DC4CEFC; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=KxOyE5BKUrI++h92xXMIAQUn0Quywt6iwaXVifE22IU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kGnFr2TmOi9BceEGxRqxrSwwheR2Z8q4ipWc6QfQLUp7/6EdIV0EbQTwr/JTOwVQY sPj7+w7EA2U4pirQ1osH8iy7md3MOW3qrJW2eImbYa4tPlhwHGxxHgv6mEd5ODg1NH pTSKVjSoZ0kA6DrNwosyvNK46FAxMI3JKJsU25zwtXHE4V9srWm5ibVyMd24Hf0Kxq TVPZcvSxmg1/q/XaU07dJUyMA1Sl3wddsnA6Ylc02YoN0+Cjnz2CLrpqX+zSvlIplF m/7j3xwv4b2xGkyX7MRirKvl4BTfxOmrsn1hERNeJ5VB5+C4H/VD3dlCJOd8OXSeLC aq/s7PWs0W7yw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cj2-0ySU; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 14/27] scripts/lib/abi/abi_parser.py: use an interactor for ReST output Date: Mon, 10 Feb 2025 11:18:03 +0100 Message-ID: X-Mailer: git-send-email 2.48.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" Instead of printing all results line per line, use an interactor to return each variable as a separate message. This won't change much when using it via command line, but it will help Sphinx integration by providing an interactor that could be used there to handle ABI symbol by symbol. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/get_abi.py | 3 ++- scripts/lib/abi/abi_parser.py | 48 +++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/scripts/get_abi.py b/scripts/get_abi.py index 30439f21fdd0..93b973bc07ed 100755 --- a/scripts/get_abi.py +++ b/scripts/get_abi.py @@ -62,8 +62,9 @@ class AbiRest: parser =3D AbiParser(args.dir, debug=3Dargs.debug) parser.parse_abi() parser.check_issues() - parser.print_data(args.enable_lineno, args.raw, not args.no_file) =20 + for msg in parser.doc(args.enable_lineno, args.raw, not args.no_fi= le): + print(msg) =20 class AbiValidate: """Initialize an argparse subparser for ABI validation""" diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index 6052a8aec443..960e27161c26 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -336,7 +336,7 @@ class AbiParser: name =3D os.path.join(root, entry.name) =20 if entry.is_dir(): - self.parse_abi(name) + self._parse_abi(name) continue =20 if not entry.is_file(): @@ -365,14 +365,14 @@ class AbiParser: if self.debug & AbiDebug.DUMP_ABI_STRUCTS: self.log.debug(pformat(self.data)) =20 - def print_desc_txt(self, desc): + def desc_txt(self, desc): """Print description as found inside ABI files""" =20 desc =3D desc.strip(" \t\n") =20 - print(desc + "\n") + return desc + "\n\n" =20 - def print_desc_rst(self, desc): + def desc_rst(self, desc): """Enrich ReST output by creating cross-references""" =20 # Remove title markups from the description @@ -425,9 +425,9 @@ class AbiParser: =20 new_desc +=3D d + "\n" =20 - print(new_desc + "\n") + return new_desc + "\n\n" =20 - def print_data(self, enable_lineno, output_in_txt, show_file=3DFalse): + def doc(self, enable_lineno, output_in_txt, show_file=3DFalse): """Print ABI at stdout""" =20 part =3D None @@ -442,9 +442,11 @@ class AbiParser: if not show_file and wtype =3D=3D "File": continue =20 + msg =3D "" + if enable_lineno: ln =3D v.get("line_no", 1) - print(f".. LINENO {file_ref[0][0]}#{ln}\n") + msg +=3D f".. LINENO {file_ref[0][0]}#{ln}\n\n" =20 if wtype !=3D "File": cur_part =3D names[0] @@ -456,9 +458,9 @@ class AbiParser: =20 if cur_part and cur_part !=3D part: part =3D cur_part - print(f"{part}\n{"-" * len(part)}\n") + msg +=3D f"{part}\n{"-" * len(part)}\n\n" =20 - print(f".. _{key}:\n") + msg +=3D f".. _{key}:\n\n" =20 max_len =3D 0 for i in range(0, len(names)): # pylint: disable= =3DC0200 @@ -466,45 +468,47 @@ class AbiParser: =20 max_len =3D max(max_len, len(names[i])) =20 - print("+-" + "-" * max_len + "-+") + msg +=3D "+-" + "-" * max_len + "-+\n" for name in names: - print(f"| {name}" + " " * (max_len - len(name)) + " |") - print("+-" + "-" * max_len + "-+") - print() + msg +=3D f"| {name}" + " " * (max_len - len(name)) + "= |\n" + msg +=3D "+-" + "-" * max_len + "-+\n" + msg +=3D "\n" =20 for ref in file_ref: if wtype =3D=3D "File": - print(f".. _{ref[1]}:\n") + msg +=3D f".. _{ref[1]}:\n\n" else: base =3D os.path.basename(ref[0]) - print(f"Defined on file :ref:`{base} <{ref[1]}>`\n") + msg +=3D f"Defined on file :ref:`{base} <{ref[1]}>`\n\= n" =20 if wtype =3D=3D "File": - print(f"{names[0]}\n{"-" * len(names[0])}\n") + msg +=3D f"{names[0]}\n{"-" * len(names[0])}\n\n" =20 desc =3D v.get("description") if not desc and wtype !=3D "File": - print(f"DESCRIPTION MISSING for {names[0]}\n") + msg +=3D f"DESCRIPTION MISSING for {names[0]}\n\n" =20 if desc: if output_in_txt: - self.print_desc_txt(desc) + msg +=3D self.desc_txt(desc) else: - self.print_desc_rst(desc) + msg +=3D self.desc_rst(desc) =20 symbols =3D v.get("symbols") if symbols: - print("Has the following ABI:\n") + msg +=3D "Has the following ABI:\n\n" =20 for w, label in symbols: # Escape special chars from content content =3D self.re_escape.sub(r"\\\1", w) =20 - print(f"- :ref:`{content} <{label}>`\n") + msg +=3D f"- :ref:`{content} <{label}>`\n\n" =20 users =3D v.get("users") if users and users.strip(" \t\n"): - print(f"Users:\n\t{users.strip("\n").replace('\n', '\n\t')= }\n") + msg +=3D f"Users:\n\t{users.strip("\n").replace('\n', '\n\= t')}\n\n" + + yield msg =20 def check_issues(self): """Warn about duplicated ABI entries""" --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 BDCC11CAA7A; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=mBK3zLTuSYvSjw7SlD8yfNMLiYRfyI+k8JhirAF3GJMKitbQS7ETKf58MOKLXG9/IUMt9pD6Ap8PAWDY2ZdboebTLU5lLrs4wjTzkwyLV+dqHMgj+F2ocbUtaoHnJDNhgYsEp/iZCAzcr9lHA9vrKqfhkcfKDd/afDfYwuDHajs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=8ojMHW8Q6tiPmLZTDPQndwgQBu/KcQi5oueWVj1yJmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iyhacLhuoTtoI9HKL9agKDE7HWzm48G1soP/PTCe98y6Tejo6jbnZrgv3rILY+dOuXm8PAB+be54cQ8kKmfW8k1pCOeR999DRIn4IngGWJhGbggeHPMT4cJvLupkcC/sj+IUXA3bQ61IIW87HAC5DkE8kPBaEEWzFaztwkVShls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cdlPgqRS; 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="cdlPgqRS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1975BC4AF09; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=8ojMHW8Q6tiPmLZTDPQndwgQBu/KcQi5oueWVj1yJmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cdlPgqRS2id7zpcwaBSWHXeaD0qIJ0MTg7rNdzs6+DKFpXua/tOaQlswCNe5gB39D 7wJ9ninW1zRhv+g8U0Tmdri1ZhcB93Pr7/pD3+A29a/+Dsz2DGfLLhGxx1Ljov9dWY bFvBTNedR1VG44yDdGI/cOfSxuGkcfs+iLV2Znzkf0L/wHpcJCnXaDjLLU2CYQTdsC MsPLlZRlAtka42AG3jf/QBFF0f3cGdRfjdpKzPvxyfGL17EBWfDZAsyYdutnWFXDDm stbw5C8incz8xsYxEpqBLkNYClrrMNCojejdAXvzHSHEPC2ZFYf2FmgGhtXnAdPJ3W KaiYSD9Nx7eCQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cj6-15I6; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 15/27] docs: sphinx/kernel_abi: use AbiParser directly Date: Mon, 10 Feb 2025 11:18:04 +0100 Message-ID: <8dbc244dcda97112c1b694e2512a5d600e62873b.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Instead of running get_abi.py script, import AbiParser class and handle messages directly there using an interactor. This shold save some memory, as there's no need to exec python inside the Sphinx python extension. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/sphinx/kernel_abi.py | 29 ++++++++++++++++------------- scripts/lib/abi/abi_parser.py | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index f314b888d3de..f7b22abebcf4 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -34,7 +34,6 @@ u""" =20 import os import re -import subprocess import sys =20 from docutils import nodes @@ -43,6 +42,11 @@ from docutils.parsers.rst import directives, Directive from sphinx.util.docutils import switch_source_input from sphinx.util import logging =20 +srctree =3D os.path.abspath(os.environ["srctree"]) +sys.path.insert(0, os.path.join(srctree, "scripts/lib/abi")) + +from abi_parser import AbiParser + __version__ =3D "1.0" =20 =20 @@ -66,7 +70,7 @@ class KernelCmd(Directive): logger =3D logging.getLogger('kernel_abi') =20 option_spec =3D { - "debug" : directives.flag, + "debug": directives.flag, } =20 def run(self): @@ -74,20 +78,19 @@ class KernelCmd(Directive): if not doc.settings.file_insertion_enabled: raise self.warning("docutils: file insertion disabled") =20 - srctree =3D os.path.abspath(os.environ["srctree"]) + path =3D os.path.join(srctree, "Documentation", self.arguments[0]) + parser =3D AbiParser(path, logger=3Dself.logger) + parser.parse_abi() + parser.check_issues() =20 - args =3D [ - os.path.join(srctree, 'scripts/get_abi.py'), - '-D', os.path.join(srctree, 'Documentation', self.arguments[0]= ), - 'rest', - '--enable-lineno', - ] + msg =3D "" + for m in parser.doc(enable_lineno=3DTrue, show_file=3DTrue): + msg +=3D m =20 - lines =3D subprocess.check_output(args, cwd=3Dos.path.dirname(doc.= current_source)).decode('utf-8') - nodeList =3D self.nestedParse(lines, self.arguments[0]) - return nodeList + node =3D self.nested_parse(msg, self.arguments[0]) + return node =20 - def nestedParse(self, lines, fname): + def nested_parse(self, lines, fname): env =3D self.state.document.settings.env content =3D ViewList() node =3D nodes.section() diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index 960e27161c26..57c125fd40a5 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -427,7 +427,7 @@ class AbiParser: =20 return new_desc + "\n\n" =20 - def doc(self, enable_lineno, output_in_txt, show_file=3DFalse): + def doc(self, enable_lineno, output_in_txt=3DFalse, show_file=3DFalse): """Print ABI at stdout""" =20 part =3D None --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 D9EFB1CC89D; Mon, 10 Feb 2025 10:18: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=1739182704; cv=none; b=TvH2BfRCD9mIg+2wzg18yjj8L9rjjTNzIlWdbJoXLkOv+oUPGMA6wGG35pm8gNlJffqn/KOmx0Rt/mUKL9TsvCwWq0LoyeDUaW/cZWg4B6oINV0RYqkDRdY+HNK73s9bSJ7jSskeJa82VNfSUaTAZAthnhGipaLD4LLB3srLUL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182704; c=relaxed/simple; bh=bfKfMaG0D1WbSBuzEfJe/4GnAC91X+Ok5ClCL/aAjU0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EeoiBykLLA/SveLcbmUKgmM90ISTwAsbnp4wuM6ze1deiTyR9VAvzStfGN0tpPLHCj88tVhe96y47izKQQCxpC2wcUui/VKdwjH+w805VOYY4VN3wvht1FfVfJ5eDvAQZiG/3EdtzN40HApkLXV4P5ptLayg+EuJAbKXOnfa+fo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gFb6k2Rq; 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="gFb6k2Rq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 239F6C4CED1; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=bfKfMaG0D1WbSBuzEfJe/4GnAC91X+Ok5ClCL/aAjU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFb6k2Rqcz7UnLmVJH59Cly+ky8GaUG/RbvfnUykDVKMowdtyASr67XsRCoA0q0e2 bMStNL3LLwyHPjI0HZBAHkLeXdJsX0RAQT/nhf3Bjm3zfq29s/DgqcLI6vI1E1JnnQ 3YrEyg18Z6XQ1M1J5ieiYo2hHEAQXM4OiB0tOSddVZeCc0cda6KFuLVuL91d1pDYCf Oc59PuylGd4Y97426E+2WCMfQxlCXGFNGwfDjH41xGo54RWb6rBqPyDvBV8rVjvTLn vQPse6LMjp3jId5jfhzG1CJWL8xs/vHgwuvDpkluxm1RUF5RhTD16KMTENiYq+0maT CxtPy6U3vMBDA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006CjA-1CQh; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 16/27] docs: sphinx/kernel_abi: reduce buffer usage for ABI messages Date: Mon, 10 Feb 2025 11:18:05 +0100 Message-ID: <15be22955e3c6df49d7256c8fd24f62b397ad0ff.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Instead of producing a big message with all ABI contents and then parse as a whole, simplify the code by handling each ABI symbol in separate. As an additional benefit, there's no need to place file/line nubers inlined at the data and use a regex to convert them. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/sphinx/kernel_abi.py | 76 +++++++++++++++--------------- scripts/get_abi.py | 7 ++- scripts/lib/abi/abi_parser.py | 10 ++-- 3 files changed, 48 insertions(+), 45 deletions(-) diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index f7b22abebcf4..742ebd35454f 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -68,6 +68,7 @@ class KernelCmd(Directive): has_content =3D False final_argument_whitespace =3D True logger =3D logging.getLogger('kernel_abi') + parser =3D None =20 option_spec =3D { "debug": directives.flag, @@ -79,59 +80,60 @@ class KernelCmd(Directive): raise self.warning("docutils: file insertion disabled") =20 path =3D os.path.join(srctree, "Documentation", self.arguments[0]) - parser =3D AbiParser(path, logger=3Dself.logger) - parser.parse_abi() - parser.check_issues() + self.parser =3D AbiParser(path, logger=3Dself.logger) + self.parser.parse_abi() + self.parser.check_issues() =20 - msg =3D "" - for m in parser.doc(enable_lineno=3DTrue, show_file=3DTrue): - msg +=3D m - - node =3D self.nested_parse(msg, self.arguments[0]) + node =3D self.nested_parse(None, self.arguments[0]) return node =20 - def nested_parse(self, lines, fname): + def nested_parse(self, data, fname): env =3D self.state.document.settings.env content =3D ViewList() node =3D nodes.section() =20 - if "debug" in self.options: - code_block =3D "\n\n.. code-block:: rst\n :linenos:\n" - for line in lines.split("\n"): - code_block +=3D "\n " + line - lines =3D code_block + "\n\n" + if data is not None: + # Handles the .rst file + for line in data.split("\n"): + content.append(line, fname, 0) =20 - line_regex =3D re.compile(r"^\.\. LINENO (\S+)\#([0-9]+)$") - ln =3D 0 - n =3D 0 - f =3D fname + self.do_parse(content, node) =20 - for line in lines.split("\n"): - n =3D n + 1 - match =3D line_regex.search(line) - if match: - new_f =3D match.group(1) + else: + # Handles the ABI parser content, symbol by symbol =20 - # Sphinx parser is lazy: it stops parsing contents in the - # middle, if it is too big. So, handle it per input file - if new_f !=3D f and content: - self.do_parse(content, node) - content =3D ViewList() + old_f =3D fname + n =3D 0 + for msg, f, ln in self.parser.doc(): + msg_list =3D msg.split("\n") + if "debug" in self.options: + lines =3D [ + "", "", ".. code-block:: rst", + " :linenos:", "" + ] + for m in msg_list: + lines.append(" " + m) + else: + lines =3D msg_list =20 + for line in lines: + # sphinx counts lines from 0 + content.append(line, f, ln - 1) + n +=3D 1 + + if f !=3D old_f: # Add the file to Sphinx build dependencies env.note_dependency(os.path.abspath(f)) =20 - f =3D new_f + old_f =3D f =20 - # sphinx counts lines from 0 - ln =3D int(match.group(2)) - 1 - else: - content.append(line, f, ln) + # Sphinx doesn't like to parse big messages. So, let's + # add content symbol by symbol + if content: + self.do_parse(content, node) + content =3D ViewList() =20 - self.logger.info("%s: parsed %i lines" % (fname, n)) - - if content: - self.do_parse(content, node) + self.logger.info("%s: parsed %i lines" % (fname, n)) =20 return node.children =20 diff --git a/scripts/get_abi.py b/scripts/get_abi.py index 93b973bc07ed..19f78d6aa407 100755 --- a/scripts/get_abi.py +++ b/scripts/get_abi.py @@ -63,8 +63,11 @@ class AbiRest: parser.parse_abi() parser.check_issues() =20 - for msg in parser.doc(args.enable_lineno, args.raw, not args.no_fi= le): - print(msg) + for t in parser.doc(args.raw, not args.no_file): + if args.enable_lineno: + print (f".. LINENO {t[1]}#{t[2]}\n\n") + + print(t[0]) =20 class AbiValidate: """Initialize an argparse subparser for ABI validation""" diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index 57c125fd40a5..1db6c54fc65a 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -427,7 +427,7 @@ class AbiParser: =20 return new_desc + "\n\n" =20 - def doc(self, enable_lineno, output_in_txt=3DFalse, show_file=3DFalse): + def doc(self, output_in_txt=3DFalse, show_file=3DTrue): """Print ABI at stdout""" =20 part =3D None @@ -444,10 +444,6 @@ class AbiParser: =20 msg =3D "" =20 - if enable_lineno: - ln =3D v.get("line_no", 1) - msg +=3D f".. LINENO {file_ref[0][0]}#{ln}\n\n" - if wtype !=3D "File": cur_part =3D names[0] if cur_part.find("/") >=3D 0: @@ -508,7 +504,9 @@ class AbiParser: if users and users.strip(" \t\n"): msg +=3D f"Users:\n\t{users.strip("\n").replace('\n', '\n\= t')}\n\n" =20 - yield msg + ln =3D v.get("line_no", 1) + + yield (msg, file_ref[0][0], ln) =20 def check_issues(self): """Warn about duplicated ABI entries""" --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 E59921CCEF0; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=DqczleZ9U4kpG/hbKLTcIUEpMoXxaawBCX1LIajbEFVwgAy0zVsCyO5Te3fwTmFV2jy3AmuLQJ4fC8Td5jwYPhRQThMnv/1bvYYllYIng0QVjQn4r5ASl7Twrqy3A3qzyYgMzSdekuhj/KPcczv6GTJfPW2uWjvK5demeA3N6ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=spRvL9h02iTAJSEHfQOVuBNItXh/grPCVfWPr/wssWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J8gLj+h6h2dBubt8k3FDFCkBgTXcTPsZsMW3lNUhNFdc0WjBnOBiec6iorKAmZVVqrmArfdD7cEcyI0D/1SdIanfgxExoUzhq94JkqqQcPvj5bHutMy7qSsyXU9DS5Z28WL2grTo+745Tz2Ic6APE9H0d9qPhk9oe9vedShsB14= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IHo34MQI; 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="IHo34MQI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34B1FC4CEFB; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=spRvL9h02iTAJSEHfQOVuBNItXh/grPCVfWPr/wssWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IHo34MQIYvI4tRCMSCstmstYvqbBEfTHMQXmKUIGTec6Yrl9EsfwMehg16PPsfcyM 0XlLnySYsqBKvs2hKTxDbcNtZLoZoU8yFd/cPQbddJyEzjHdKPvZPATc5XgdXfCJif 0VEkmRoSAUcoVTQJLf/CS7TVndRl3/0rfafbg3sSb673cgLL1tor+BoIGyR+knusdh 0rq0rBdmf1/jm0F8eUIZ74ZLROSIt/HhY+d2UQGRD2w8ux8Wb8RUe/NWrCyvTAcdst jJorHi3+H4lBnEckXCLEqpDOyhRfLP/V8yLTtZ6r492QlAKTvgOUKPAo4OkkVBVZrg PnrynWeeWfC0g== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006CjE-1Ivf; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 17/27] docs: sphinx/kernel_abi: properly split lines Date: Mon, 10 Feb 2025 11:18:06 +0100 Message-ID: X-Mailer: git-send-email 2.48.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" Sphinx doesn't like to have lines split with str.split("\n"). Instead, it uses its own splitter, with handles line breaks the way Spinx expects. Not using it cause issues at the output files. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/sphinx/kernel_abi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index 742ebd35454f..0a4057183208 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -36,7 +36,7 @@ import os import re import sys =20 -from docutils import nodes +from docutils import nodes, statemachine from docutils.statemachine import ViewList from docutils.parsers.rst import directives, Directive from sphinx.util.docutils import switch_source_input @@ -105,7 +105,8 @@ class KernelCmd(Directive): old_f =3D fname n =3D 0 for msg, f, ln in self.parser.doc(): - msg_list =3D msg.split("\n") + msg_list =3D statemachine.string2lines(msg, tab_width, + convert_whitespace=3D= True) if "debug" in self.options: lines =3D [ "", "", ".. code-block:: rst", --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 F0C181CEE8D; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=QIUktodGyE2/X51BFsdvYDRoadyM/3zB5sOVwmNSFhRKxzZ2v9qN1W+T44WRHtammJUhNaiB31rpcuFimmkqyd24tgY7M0RJbmcJM+0hu8GqVwdy7ILb++dmQnxOhEMk+pfXHFLGClQcbtihdiM+ySKzWWfA/4vbQIBntg82kME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=ioH67mGmMrR7TV2QvHCqqT6mvSN3es7X+oI3VVv4IjM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ABGP6tIMw9pBFaZCKDyg/cqcyVo1wVok/PsGr8kETcz7UD6oFFiDqY37WvbugE9eMFYnJYXVIP2DY1TTnJRSCe2Cy4o4HrARVuWH5plSj6W48NcQ7igapst/W/NLkI7H2XdhrTFduK0YnoI0+zR1Wnw5o1oosqWXuzIzPtJoGdQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fwdoaYtC; 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="fwdoaYtC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3577CC4CEFF; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=ioH67mGmMrR7TV2QvHCqqT6mvSN3es7X+oI3VVv4IjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fwdoaYtCc+OirL8GqRT1NghqS9E2w2ZR5RR3fxw7lsS97vO4TirSEaAEMCKJZwmDb InealSIMP6amc6kBOzISZ0pR/X78zIiVB580WxYWU1UM+fw7VJykB61cY3Yro8pdiT DADYVLrRWeO58wRzjXrkxT0nWWWCvuhGoG6e+Tkq94auRqhjwQ/e1+IlpR7LCh2P3O lT3fcIoIUQBO6liwIqQ6jW35d843UYapg6oi/eH8AuM1beQbUZafiQdJBuua22xc7/ ahKFh5bLHnC6QSixfK8YPyGda79H44rhwdkBuPBlHUFDFczQZUloNKCoYxIxKLmV3s UuEzLIqFGtjOw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006CjI-1PFj; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 18/27] scripts/get_abi.pl: Add filtering capabilities to rest output Date: Mon, 10 Feb 2025 11:18:07 +0100 Message-ID: <41e108e816e46434aa596e5c0d25d227cb9f0fe5.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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 way, Sphinx ABI extension can parse symbols only once, while keep displaying results in separate files. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/lib/abi/abi_parser.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index 1db6c54fc65a..b20d5c9d920e 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -160,6 +160,7 @@ class AbiParser: self.data[fdata.key] =3D { "what": [content], "file": [fdata.file_ref], + "path": fdata.ftype, "line_no": fdata.ln, } =20 @@ -182,8 +183,6 @@ class AbiParser: if new_what: fdata.label =3D "" =20 - self.data[fdata.key]["type"] =3D fdata.ftype - if "description" in self.data[fdata.key]: self.data[fdata.key]["description"] +=3D "\n\n" =20 @@ -299,6 +298,7 @@ class AbiParser: fdata.nametag =3D {} fdata.nametag["what"] =3D [f"File {path}/{basename}"] fdata.nametag["type"] =3D "File" + fdata.nametag["path"] =3D fdata.ftype fdata.nametag["file"] =3D [fdata.file_ref] fdata.nametag["line_no"] =3D 1 fdata.nametag["description"] =3D "" @@ -427,7 +427,8 @@ class AbiParser: =20 return new_desc + "\n\n" =20 - def doc(self, output_in_txt=3DFalse, show_file=3DTrue): + def doc(self, output_in_txt=3DFalse, show_symbols=3DTrue, show_file=3D= True, + filter_path=3DNone): """Print ABI at stdout""" =20 part =3D None @@ -435,12 +436,20 @@ class AbiParser: key=3Dlambda x: (x[1].get("type", ""), x[1].get("what"))): =20 - wtype =3D v.get("type", "Var") + wtype =3D v.get("type", "Symbol") file_ref =3D v.get("file") names =3D v.get("what", [""]) =20 - if not show_file and wtype =3D=3D "File": - continue + if wtype =3D=3D "File": + if not show_file: + continue + else: + if not show_symbols: + continue + + if filter_path: + if v.get("path") !=3D filter_path: + continue =20 msg =3D "" =20 --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 EE59C1CDA14; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=RljsdDD8OGa3W8Uvx1Mh3xFrPzAHJNnzU5Nyf6hDuGkdHpvQkIGqHCzW9OQQK99LlwxeG6B34nozbdHgQaw1VY/Q27XUnuJ20zVXcxejqT7ZaOBHvn/WrPcfYX1w0GAJUVs3D50t7WWcwnnyWTLT/ACUgT02hzZ11j89imTQOzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=Bg/135c3/sCX1BS6OU1mn7NTkAkZ/Ldfy6wpxAGy82o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bOAP1ow+tIwd9H5H6t66Z6TksWsjxmV4lh/KiM1pV1vAWW5H7Li7NQ2FqtUBDb+6fX+sqrWNXugIW9sHOMMme0yJNlhXE2n6EYFg+/WM9D6NHfYySSBnZOkycZTifjAny06HNeN4gBrT7HpyM0TTyxX1LmJm5Cl2t1VhqaWTrZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mk1NaiDX; 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="mk1NaiDX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 365F0C4AF0B; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=Bg/135c3/sCX1BS6OU1mn7NTkAkZ/Ldfy6wpxAGy82o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mk1NaiDX/yrCZ0RD6jrz0EXGmJAE3iGKfhgO90RFeVGW8YLD2T3FKnZdE7a/dIACe EJvsNKpMbkFkfdomvWqQ/38mTC1DAncomdT6aftLB8FKgSjEN3NeoE0qBBLwpryXGK sxQVrVfhottBTq0zclIR4KLVzyKgzH8IVVSjQlhFJCq9Jk+taQBnKpj7U87sWiPFYE O6xxnMuiU0VujKW0pYqBo94jRWv5QLPF/qfBQ3yqXrHw8T/93PR9aB6gxqOUpPpIWJ 2ixRvajbpzv8f97UBYRfLTTYU9npMigCjfmleX8ug+ZjAKI+LpjzJEm5A9idCiXYkP EE2akiEkJWccA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006CjM-1VwB; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 19/27] scripts/get_abi.pl: add support to parse ABI README file Date: Mon, 10 Feb 2025 11:18:08 +0100 Message-ID: X-Mailer: git-send-email 2.48.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 Documentation/ABI/README file is currently outside the documentation tree. Yet, it may still provide some useful information. Add it to the documentation parsing. As a plus, this avoids a warning when detecting missing cross-references. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/lib/abi/abi_parser.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index b20d5c9d920e..6fac461d794c 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -263,6 +263,16 @@ class AbiParser: if content: self.warn(fdata, "Unexpected content", line) =20 + def parse_readme(self, nametag, fname): + """Parse ABI README file""" + + with open(fname, "r", encoding=3D"utf8", errors=3D"backslashreplac= e") as fp: + nametag["description"] =3D "```\n" + for line in fp: + nametag["description"] +=3D " " + line + + nametag["description"] +=3D "```\n" + def parse_file(self, fname, path, basename): """Parse a single file""" =20 @@ -309,6 +319,10 @@ class AbiParser: if self.debug & AbiDebug.WHAT_OPEN: self.log.debug("Opening file %s", fname) =20 + if basename =3D=3D "README": + self.parse_readme(fdata.nametag, fname) + return + with open(fname, "r", encoding=3D"utf8", errors=3D"backslashreplac= e") as fp: for line in fp: fdata.ln +=3D 1 @@ -344,9 +358,6 @@ class AbiParser: =20 basename =3D os.path.basename(name) =20 - if basename =3D=3D "README": - continue - if basename.startswith("."): continue =20 @@ -448,8 +459,12 @@ class AbiParser: continue =20 if filter_path: - if v.get("path") !=3D filter_path: - continue + if filter_path =3D=3D "README": + if not names[0].endswith("README"): + continue + else: + if v.get("path") !=3D filter_path: + continue =20 msg =3D "" =20 --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 3C1751DE88C; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=YIztloD1iAvrVfRRiMcGIbeZNXrH8WbtEXu7fL05KfIoMpLdTfqNX8IZOY7q/muK25ECUhbwjwhqXigbxRBF4si481v6S9ssKmxJg2+c4mJA5Ay37dU3WMFjaIttUuVumkN257ruAqFih5gXr0n2QVrvb8F3CCaCabwrAjZJxuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=AgZgjsWlXG6CLe0lkuaH95ZdpSYmb1IEeyegxlm7uno=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J2hHHPu2NZa1dEqWohchMW2m4zd3NIhUIaCaswmAThIppcNxzUf8OCw6/erCruTYU3mKIr70H6MnAV7Mqem5Yj6mZYtu5IA1D+7LeRS9rZN2NholVmwXCn+VrvDSglSoZgAaEKktlNujRysJeAV+4v8cocezzrDGCRAODBS4WoA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PSuyVYxs; 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="PSuyVYxs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3569CC4CEFE; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=AgZgjsWlXG6CLe0lkuaH95ZdpSYmb1IEeyegxlm7uno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSuyVYxsCe57ajvGphKwFMfxv95i4EQhsqHxLKP3zMy8yBLV82VsvM4yK1V4snjcx VYZuf95Ts35b5AsFHbU19H7AIw1+Iqo8SJ8fwKG5cEJWEwmXYMCFJYfuGhETlZsj4c bpdYAg8QcMGqa2UWe1LuuFZyXuc76dmxLGEV8p9VtBUdRCOC5/dPYqgdz90tVmQ3lt LSHR6tNBKvNjHfIPb5J0EPinj7/niJ2TWqGYope2yzFgufCHWUjplfzMqoYkvQhMlc PGKy+W2cPSlxgDLLrbyrR7U/ImrvF4NuK602BetNeMNgWxf4YMsBmDcZav5i7xVZ3v ut1eMrE6LZa8g== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006CjQ-1cfu; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 20/27] docs: sphinx/kernel_abi: parse ABI files only once Date: Mon, 10 Feb 2025 11:18:09 +0100 Message-ID: <5205c53838b6ea25f4cdd4cc1e3d17c0141e75a6.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Right now, the logic parses ABI files on 4 steps, one for each directory. While this is fine in principle, by doing that, not all symbol cross-references will be created. Change the logic to do the parsing only once in order to get a global dictionary to be used when creating ABI cross-references. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/admin-guide/abi-obsolete.rst | 2 +- Documentation/admin-guide/abi-removed.rst | 2 +- Documentation/admin-guide/abi-stable.rst | 2 +- Documentation/admin-guide/abi-testing.rst | 2 +- Documentation/sphinx/kernel_abi.py | 115 ++++++++++++--------- scripts/lib/abi/abi_parser.py | 22 ++-- 6 files changed, 81 insertions(+), 64 deletions(-) diff --git a/Documentation/admin-guide/abi-obsolete.rst b/Documentation/adm= in-guide/abi-obsolete.rst index 6d4d9ab7b8c3..bdef91d2cea4 100644 --- a/Documentation/admin-guide/abi-obsolete.rst +++ b/Documentation/admin-guide/abi-obsolete.rst @@ -9,4 +9,4 @@ marked to be removed at some later point in time. The description of the interface will document the reason why it is obsolete and when it can be expected to be removed. =20 -.. kernel-abi:: ABI/obsolete +.. kernel-abi:: obsolete diff --git a/Documentation/admin-guide/abi-removed.rst b/Documentation/admi= n-guide/abi-removed.rst index 9fc78af6f077..bea0608b8442 100644 --- a/Documentation/admin-guide/abi-removed.rst +++ b/Documentation/admin-guide/abi-removed.rst @@ -3,4 +3,4 @@ ABI removed symbols =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -.. kernel-abi:: ABI/removed +.. kernel-abi:: removed diff --git a/Documentation/admin-guide/abi-stable.rst b/Documentation/admin= -guide/abi-stable.rst index c47c2a295865..33637c0d4fd5 100644 --- a/Documentation/admin-guide/abi-stable.rst +++ b/Documentation/admin-guide/abi-stable.rst @@ -12,4 +12,4 @@ for at least 2 years. Most interfaces (like syscalls) are expected to never change and always be available. =20 -.. kernel-abi:: ABI/stable +.. kernel-abi:: stable diff --git a/Documentation/admin-guide/abi-testing.rst b/Documentation/admi= n-guide/abi-testing.rst index 40b31985e587..55054985a8ff 100644 --- a/Documentation/admin-guide/abi-testing.rst +++ b/Documentation/admin-guide/abi-testing.rst @@ -18,4 +18,4 @@ Programs that use these interfaces are strongly encourage= d to add their name to the description of these interfaces, so that the kernel developers can easily notify them if any changes occur. =20 -.. kernel-abi:: ABI/testing +.. kernel-abi:: testing diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index 0a4057183208..964f586de171 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -49,6 +49,13 @@ from abi_parser import AbiParser =20 __version__ =3D "1.0" =20 +logger =3D logging.getLogger('kernel_abi') +path =3D os.path.join(srctree, "Documentation/ABI") + +# Parse ABI symbols only once +kernel_abi =3D AbiParser(path, logger=3Dlogger) +kernel_abi.parse_abi() +kernel_abi.check_issues() =20 def setup(app): =20 @@ -64,14 +71,15 @@ class KernelCmd(Directive): u"""KernelABI (``kernel-abi``) directive""" =20 required_arguments =3D 1 - optional_arguments =3D 2 + optional_arguments =3D 3 has_content =3D False final_argument_whitespace =3D True - logger =3D logging.getLogger('kernel_abi') parser =3D None =20 option_spec =3D { "debug": directives.flag, + "no-symbols": directives.flag, + "no-files": directives.flag, } =20 def run(self): @@ -79,62 +87,67 @@ class KernelCmd(Directive): if not doc.settings.file_insertion_enabled: raise self.warning("docutils: file insertion disabled") =20 - path =3D os.path.join(srctree, "Documentation", self.arguments[0]) - self.parser =3D AbiParser(path, logger=3Dself.logger) - self.parser.parse_abi() - self.parser.check_issues() - - node =3D self.nested_parse(None, self.arguments[0]) - return node - - def nested_parse(self, data, fname): env =3D self.state.document.settings.env content =3D ViewList() node =3D nodes.section() =20 - if data is not None: - # Handles the .rst file - for line in data.split("\n"): - content.append(line, fname, 0) + abi_type =3D self.arguments[0] =20 - self.do_parse(content, node) + if "no-symbols" in self.options: + show_symbols =3D False + else: + show_symbols =3D True =20 + if "no-files" in self.options: + show_file =3D False + else: + show_file =3D True + + tab_width =3D self.options.get('tab-width', + self.state.document.settings.tab_widt= h) + + old_f =3D None + n =3D 0 + n_sym =3D 0 + for msg, f, ln in kernel_abi.doc(show_file=3Dshow_file, + show_symbols=3Dshow_symbols, + filter_path=3Dabi_type): + n_sym +=3D 1 + msg_list =3D statemachine.string2lines(msg, tab_width, + convert_whitespace=3DTrue) + if "debug" in self.options: + lines =3D [ + "", "", ".. code-block:: rst", + " :linenos:", "" + ] + for m in msg_list: + lines.append(" " + m) + else: + lines =3D msg_list + + for line in lines: + # sphinx counts lines from 0 + content.append(line, f, ln - 1) + n +=3D 1 + + if f !=3D old_f: + # Add the file to Sphinx build dependencies + env.note_dependency(os.path.abspath(f)) + + old_f =3D f + + # Sphinx doesn't like to parse big messages. So, let's + # add content symbol by symbol + if content: + self.do_parse(content, node) + content =3D ViewList() + + if show_symbols and not show_file: + logger.verbose("%s ABI: %i symbols (%i ReST lines)" % (abi_typ= e, n_sym, n)) + elif not show_symbols and show_file: + logger.verbose("%s ABI: %i files (%i ReST lines)" % (abi_type,= n_sym, n)) else: - # Handles the ABI parser content, symbol by symbol - - old_f =3D fname - n =3D 0 - for msg, f, ln in self.parser.doc(): - msg_list =3D statemachine.string2lines(msg, tab_width, - convert_whitespace=3D= True) - if "debug" in self.options: - lines =3D [ - "", "", ".. code-block:: rst", - " :linenos:", "" - ] - for m in msg_list: - lines.append(" " + m) - else: - lines =3D msg_list - - for line in lines: - # sphinx counts lines from 0 - content.append(line, f, ln - 1) - n +=3D 1 - - if f !=3D old_f: - # Add the file to Sphinx build dependencies - env.note_dependency(os.path.abspath(f)) - - old_f =3D f - - # Sphinx doesn't like to parse big messages. So, let's - # add content symbol by symbol - if content: - self.do_parse(content, node) - content =3D ViewList() - - self.logger.info("%s: parsed %i lines" % (fname, n)) + logger.verbose("%s ABI: %i data (%i ReST lines)" % (abi_type, = n_sym, n)) =20 return node.children =20 diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index 6fac461d794c..87d1b9e14bb3 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -266,12 +266,20 @@ class AbiParser: def parse_readme(self, nametag, fname): """Parse ABI README file""" =20 + nametag["what"] =3D ["ABI file contents"] + nametag["path"] =3D "README" with open(fname, "r", encoding=3D"utf8", errors=3D"backslashreplac= e") as fp: - nametag["description"] =3D "```\n" for line in fp: - nametag["description"] +=3D " " + line + match =3D self.re_tag.match(line) + if match: + new =3D match.group(1).lower() =20 - nametag["description"] +=3D "```\n" + match =3D self.re_valid.search(new) + if match: + nametag["description"] +=3D "\n:" + line + continue + + nametag["description"] +=3D line =20 def parse_file(self, fname, path, basename): """Parse a single file""" @@ -459,12 +467,8 @@ class AbiParser: continue =20 if filter_path: - if filter_path =3D=3D "README": - if not names[0].endswith("README"): - continue - else: - if v.get("path") !=3D filter_path: - continue + if v.get("path") !=3D filter_path: + continue =20 msg =3D "" =20 --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 150EA1D5CE8; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=VSe50Kj5rBhcjRyhIfKRKopqgjVKV68Ob4IKBzOuDzUuUIhfPGYQ0TVwgvlc4TRxTLxkCh0MZN0BIWDmv1aiTlbsn+FQHsqglgC8+tMnvGhLLEdRv7TIPiivcNgNG+t2vb73Qvf4lHGRkj7f7aJemrnYWf49qb/lJ7sXV0aNHO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=5Ehk+UnXsY+f4nC8KlN3P04pRtl7e+QgRfiunel5DWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EXkeOOziBPdgN5w/gZq0ckSevCY5ddGq6LAcEP9k3qfwW+eGOwJ/42gDZmSfGk8XnisNpMalNnURGAsbTf8ll+MADaDQO9CbmeXa4rJscf4xJnsm56cZvAdOj2jkVpMIYVZz3OsSCnfOwTWH8XiffVaRHGrwvdRCnqJWQBIgL0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JOB2SwnE; 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="JOB2SwnE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E829C116D0; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=5Ehk+UnXsY+f4nC8KlN3P04pRtl7e+QgRfiunel5DWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JOB2SwnEwLEat9BCdCQ8eJtn2FdkoUJfMDpEMoohH34xD34BjnamPjqmgBlDcWt98 prp8/UxdPNnmXBLmLb6x8arPl2Hze3U777bjN/nUdU9xd+1xqRxQpGFN7LEYIeFb8F tzZwmjj2eWVehRDGp5ODZL+PJrvRBAyWCE79LbvL8P2TIKHVKRzFxZpKWgE99YIHIw 0ns9HKVw/Y1KyPH4co5CDxJ+OpNEWKomsjj7ElFbQzRtVPCccls+r/Oz2m4x/pKYC5 vlmkt2UlcclHvSBkPNIDQomkIq98qtPIkqD7blIqbTWxWHHi7pev4xcgVvrZESq9tI iEfsO0+170dUA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006CjU-1jh5; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 21/27] docs: admin-guide/abi: split files from symbols Date: Mon, 10 Feb 2025 11:18:10 +0100 Message-ID: <30e3cf2a8aeef23ca889de60a90f7de141e0dc0e.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Now that get_abi has gained support for filtering its output, split ABI symbols from files at the html output. That makes pages smaller and easier to navigate. As an additional bonus, as it will paralelize files handling, it gives an additional performance improvement. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/admin-guide/abi-obsolete-files.rst | 7 +++++++ Documentation/admin-guide/abi-obsolete.rst | 1 + Documentation/admin-guide/abi-readme-file.rst | 6 ++++++ Documentation/admin-guide/abi-removed-files.rst | 7 +++++++ Documentation/admin-guide/abi-removed.rst | 1 + Documentation/admin-guide/abi-stable-files.rst | 7 +++++++ Documentation/admin-guide/abi-stable.rst | 1 + Documentation/admin-guide/abi-testing-files.rst | 7 +++++++ Documentation/admin-guide/abi-testing.rst | 1 + Documentation/admin-guide/abi.rst | 15 +++++++++++++++ 10 files changed, 53 insertions(+) create mode 100644 Documentation/admin-guide/abi-obsolete-files.rst create mode 100644 Documentation/admin-guide/abi-readme-file.rst create mode 100644 Documentation/admin-guide/abi-removed-files.rst create mode 100644 Documentation/admin-guide/abi-stable-files.rst create mode 100644 Documentation/admin-guide/abi-testing-files.rst diff --git a/Documentation/admin-guide/abi-obsolete-files.rst b/Documentati= on/admin-guide/abi-obsolete-files.rst new file mode 100644 index 000000000000..3061a916b4b5 --- /dev/null +++ b/Documentation/admin-guide/abi-obsolete-files.rst @@ -0,0 +1,7 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Obsolete ABI Files +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. kernel-abi:: obsolete + :no-symbols: diff --git a/Documentation/admin-guide/abi-obsolete.rst b/Documentation/adm= in-guide/abi-obsolete.rst index bdef91d2cea4..640f3903e847 100644 --- a/Documentation/admin-guide/abi-obsolete.rst +++ b/Documentation/admin-guide/abi-obsolete.rst @@ -10,3 +10,4 @@ The description of the interface will document the reason= why it is obsolete and when it can be expected to be removed. =20 .. kernel-abi:: obsolete + :no-files: diff --git a/Documentation/admin-guide/abi-readme-file.rst b/Documentation/= admin-guide/abi-readme-file.rst new file mode 100644 index 000000000000..6172e4ccbda2 --- /dev/null +++ b/Documentation/admin-guide/abi-readme-file.rst @@ -0,0 +1,6 @@ +.. SPDX-License-Identifier: GPL-2.0 + +ABI README +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. kernel-abi:: README diff --git a/Documentation/admin-guide/abi-removed-files.rst b/Documentatio= n/admin-guide/abi-removed-files.rst new file mode 100644 index 000000000000..f1bdfadd2ec4 --- /dev/null +++ b/Documentation/admin-guide/abi-removed-files.rst @@ -0,0 +1,7 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Removed ABI Files +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. kernel-abi:: removed + :no-symbols: diff --git a/Documentation/admin-guide/abi-removed.rst b/Documentation/admi= n-guide/abi-removed.rst index bea0608b8442..88832d3eacd6 100644 --- a/Documentation/admin-guide/abi-removed.rst +++ b/Documentation/admin-guide/abi-removed.rst @@ -4,3 +4,4 @@ ABI removed symbols =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 .. kernel-abi:: removed + :no-files: diff --git a/Documentation/admin-guide/abi-stable-files.rst b/Documentation= /admin-guide/abi-stable-files.rst new file mode 100644 index 000000000000..f867738fc178 --- /dev/null +++ b/Documentation/admin-guide/abi-stable-files.rst @@ -0,0 +1,7 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Stable ABI Files +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. kernel-abi:: stable + :no-symbols: diff --git a/Documentation/admin-guide/abi-stable.rst b/Documentation/admin= -guide/abi-stable.rst index 33637c0d4fd5..528c68401f4b 100644 --- a/Documentation/admin-guide/abi-stable.rst +++ b/Documentation/admin-guide/abi-stable.rst @@ -13,3 +13,4 @@ Most interfaces (like syscalls) are expected to never cha= nge and always be available. =20 .. kernel-abi:: stable + :no-files: diff --git a/Documentation/admin-guide/abi-testing-files.rst b/Documentatio= n/admin-guide/abi-testing-files.rst new file mode 100644 index 000000000000..1da868e42fdb --- /dev/null +++ b/Documentation/admin-guide/abi-testing-files.rst @@ -0,0 +1,7 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Testing ABI Files +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. kernel-abi:: testing + :no-symbols: diff --git a/Documentation/admin-guide/abi-testing.rst b/Documentation/admi= n-guide/abi-testing.rst index 55054985a8ff..6153ebd38e2d 100644 --- a/Documentation/admin-guide/abi-testing.rst +++ b/Documentation/admin-guide/abi-testing.rst @@ -19,3 +19,4 @@ name to the description of these interfaces, so that the = kernel developers can easily notify them if any changes occur. =20 .. kernel-abi:: testing + :no-files: diff --git a/Documentation/admin-guide/abi.rst b/Documentation/admin-guide/= abi.rst index 64e772bde943..15a2dcb1388c 100644 --- a/Documentation/admin-guide/abi.rst +++ b/Documentation/admin-guide/abi.rst @@ -4,6 +4,9 @@ Linux ABI description =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 +ABI symbols +----------- + .. toctree:: :maxdepth: 2 =20 @@ -11,3 +14,15 @@ Linux ABI description abi-testing abi-obsolete abi-removed + +ABI files +--------- + +.. toctree:: + :maxdepth: 2 + + abi-readme-file + abi-stable-files + abi-testing-files + abi-obsolete-files + abi-removed-files --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 062B51D47C7; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=Di5gelxnKprxJGyNpssRRI8l5eT1BeMQw8suDitz0bPklotoP2u9k/xBDQLGF0AQqxI8hOeA2znt63g60MTjFKM+FJ0xiAZwFD2F39O31kN64KhOqN5s/AStHZWkRN7zvjnKXgKToSmSjBJ0tmAhHxmz2eYjdA8GV3DchlkQG80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=46VkCE+flgH9rmSfTBFYALbsFaY062haAmepJLiR/ao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NUFnP5vxM3rEz12Ej1fSEY0Uf4PI5GFpTrDgnAvQF/jYI2kkO4Q0LnZHR6x012m17IHQaOw5LS1O28g3p+EnUJxsmegKXIE+HjtQCoPLKle0rvsJAXi4FPIH0g8X5iUFKMfxZWmXaNPmxVasR7kL0WWiZUVPzvoi0+sbUlBJkw0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DQXEyYTB; 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="DQXEyYTB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D861C113D0; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=46VkCE+flgH9rmSfTBFYALbsFaY062haAmepJLiR/ao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DQXEyYTBVm07E5TFqOQWVk/sA7lDBI+d2dMnRqxPSs44FDXm8HB7rmuqqdW/KRAwh 0so+ZfmZV5dVhcsaJLeDLm/DNC6otcJDns1wq6/jTW2hLsH+dVo5pui5uO7vDHfzw1 REVBVF11KxFuA3PRyWaZ3RHQdTxl/ijmUQLBayFZg2jL5ICLLt2zUKxNh3gLN2CVuM kFWDF6UyojZTb5jzodJOji2asu4GpJuyW7iUNjXgBMZnK63VCj6+z15HxESHTULdSq Vj7COfLD6hldbwdwqINNs1swzk27xvJB89QHngd+4YZcCD9Cb7duz8T0vlaSV00bnU IgXgc+SWGug8A== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006CjY-1qI5; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 22/27] docs: sphinx/automarkup: add cross-references for ABI Date: Mon, 10 Feb 2025 11:18:11 +0100 Message-ID: <0b97a51b68b1c20127ad4a6a55658557fe0848d0.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Now that all ABI files are handled together, we can add a feature at automarkup for it to generate cross-references for ABI symbols. The cross-reference logic can produce references for all existing files, except for README (as this is not parsed). For symbols, they need to be an exact match of what it is described at the docs, which is not always true due to wildcards. If symbols at /sys /proc and /config are identical, a cross-reference will be used. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/sphinx/automarkup.py | 45 ++++++++++++++++++++++++++++++ scripts/lib/abi/abi_parser.py | 11 ++++++++ 2 files changed, 56 insertions(+) diff --git a/Documentation/sphinx/automarkup.py b/Documentation/sphinx/auto= markup.py index a413f8dd5115..7d91c39b4ca6 100644 --- a/Documentation/sphinx/automarkup.py +++ b/Documentation/sphinx/automarkup.py @@ -11,6 +11,8 @@ from sphinx.errors import NoUri import re from itertools import chain =20 +from kernel_abi import kernel_abi + # # Python 2 lacks re.ASCII... # @@ -48,6 +50,8 @@ RE_typedef =3D re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)'= , flags=3Dascii_p3) # an optional extension # RE_doc =3D re.compile(r'(\bDocumentation/)?((\.\./)*[\w\-/]+)\.(rst|txt)') +RE_abi_file =3D re.compile(r'(\bDocumentation/ABI/[\w\-/]+)') +RE_abi_symbol =3D re.compile(r'(\b/(sys|config|proc)/[\w\-/]+)') =20 RE_namespace =3D re.compile(r'^\s*..\s*c:namespace::\s*(\S+)\s*$') =20 @@ -84,10 +88,14 @@ def markup_refs(docname, app, node): # Associate each regex with the function that will markup its matches # markup_func_sphinx2 =3D {RE_doc: markup_doc_ref, + RE_abi_file: markup_abi_ref, + RE_abi_symbol: markup_abi_ref, RE_function: markup_c_ref, RE_generic_type: markup_c_ref} =20 markup_func_sphinx3 =3D {RE_doc: markup_doc_ref, + RE_abi_file: markup_abi_ref, + RE_abi_symbol: markup_abi_ref, RE_function: markup_func_ref_sphinx3, RE_struct: markup_c_ref, RE_union: markup_c_ref, @@ -270,6 +278,43 @@ def markup_doc_ref(docname, app, match): else: return nodes.Text(match.group(0)) =20 +# +# Try to replace a documentation reference of the form Documentation/ABI/.= .. +# with a cross reference to that page +# +def markup_abi_ref(docname, app, match): + stddom =3D app.env.domains['std'] + # + # Go through the dance of getting an xref out of the std domain + # + fname =3D match.group(1) + target =3D kernel_abi.xref(fname) + + # Kernel ABI doesn't describe such file or symbol + if not target: + return nodes.Text(match.group(0)) + + pxref =3D addnodes.pending_xref('', refdomain =3D 'std', reftype =3D '= ref', + reftarget =3D target, modname =3D None, + classname =3D None, refexplicit =3D Fals= e) + + # + # XXX The Latex builder will throw NoUri exceptions here, + # work around that by ignoring them. + # + try: + xref =3D stddom.resolve_xref(app.env, docname, app.builder, 'ref', + target, pxref, None) + except NoUri: + xref =3D None + # + # Return the xref if we got it; otherwise just return the plain text. + # + if xref: + return xref + else: + return nodes.Text(match.group(0)) + def get_c_namespace(app, docname): source =3D app.env.doc2path(docname) with open(source) as f: diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index 87d1b9e14bb3..3b1ab4c0bdd7 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -391,6 +391,17 @@ class AbiParser: =20 return desc + "\n\n" =20 + def xref(self, fname): + """ + Converts a Documentation/ABI + basename into a ReST cross-reference + """ + + xref =3D self.file_refs.get(fname) + if not xref: + return None + else: + return xref + def desc_rst(self, desc): """Enrich ReST output by creating cross-references""" =20 --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 1CEB21DDC3F; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=DC5XrgXcKoJE1FpTO1oflpDeXh5dVdTtj8Qa68I1WkK1Z6qyE/RZu2l50bY8sYqZBeYpb5ayXKXiEUuuHSXcXmxcLnzlUqyFjuRVKQc7jLO7jdAB8IK9Uzh1z0K9rm3QugrQll7lXMNYdRIsJO8mgOACmPDz7AebOSFn14J8/mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=W0QttvocLbg9MNZjjCOsNJWUuoYSXbcWqR4OJBpGkhQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OGJoA9uis7TQhEkzO3sRjSaPQqE4KiotP8WWpeIOSCGPVTzepUWlLHt+qluQE2VaVkAgX6MaQkgo03qWQ44V8ktPwFSAPvdLOOk2Iie628/V6lMWDexBb8xRYD9lmaLR2aTWkVDUtDZKYBAnuIzMvDx0dcae9KGQa/yNPnzzABM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mhUZnr96; 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="mhUZnr96" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47B5DC16AAE; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=W0QttvocLbg9MNZjjCOsNJWUuoYSXbcWqR4OJBpGkhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhUZnr96S+xMDkzTvbHS2MbxPqMZVlejlkMMudpueCt5lRYcTJpEmYh1mGIjtXPTh 6SXzVCOFRgSWBQyEWLllz+1/BqvG40WWETuW1hpTzo5nXWjtUACVU/Gf6x149UZjKX hrDWk3tTK19ptCy2pNF5l3NjDLpskjswGbzZfEj+G2ucOp8bMxz/IJrkKMwmqfh7PA eDgUS8bkPyzvKp4imevNBN1ua57b6uB9RfRa67Z1UqhKSYwZo88/V7w6HMmMRInIDg xIiC3yfnZoOSwKCdhNzUVmIu1bQsckGSNHBXjYB31uTCLqZ/BmRREs1zEvTiuX1dZH 12W2YtGbXRt8A== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cjc-1wlv; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 23/27] docs: sphinx/kernel_abi: avoid warnings during Sphinx module init Date: Mon, 10 Feb 2025 11:18:12 +0100 Message-ID: X-Mailer: git-send-email 2.48.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" Sphinx logging system doesn't like warnings during module load, as it understands that such logs are produced at the wrong time: WARNING: while setting up extension automarkup: /sys/devices/system/cpu/cp= uX/topology/physical_package_id is defined 2 times: /new_devel/v4l/docs/Doc= umentation/ABI/stable/sysfs-devices-system-cpu:27; /new_devel/v4l/docs/Docu= mentation/ABI/testing/sysfs-devices-system-cpu:70 WARNING: while setting up extension automarkup: /sys/devices/system/cpu/cp= uX/topology/ppin is defined 2 times: /new_devel/v4l/docs/Documentation/ABI/= stable/sysfs-devices-system-cpu:89; /new_devel/v4l/docs/Documentation/ABI/t= esting/sysfs-devices-system-cpu:70 So, use a function to allocate/process ABI files and use it to be called at kernel_abi.py, as automarkup also needs it to produce the right cross-references. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- Documentation/sphinx/automarkup.py | 4 +++- Documentation/sphinx/kernel_abi.py | 23 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Documentation/sphinx/automarkup.py b/Documentation/sphinx/auto= markup.py index 7d91c39b4ca6..22defc18d6d2 100644 --- a/Documentation/sphinx/automarkup.py +++ b/Documentation/sphinx/automarkup.py @@ -11,7 +11,7 @@ from sphinx.errors import NoUri import re from itertools import chain =20 -from kernel_abi import kernel_abi +from kernel_abi import get_kernel_abi =20 # # Python 2 lacks re.ASCII... @@ -287,6 +287,8 @@ def markup_abi_ref(docname, app, match): # # Go through the dance of getting an xref out of the std domain # + kernel_abi =3D get_kernel_abi() + fname =3D match.group(1) target =3D kernel_abi.xref(fname) =20 diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kern= el_abi.py index 964f586de171..e017b0299953 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -52,10 +52,23 @@ __version__ =3D "1.0" logger =3D logging.getLogger('kernel_abi') path =3D os.path.join(srctree, "Documentation/ABI") =20 -# Parse ABI symbols only once -kernel_abi =3D AbiParser(path, logger=3Dlogger) -kernel_abi.parse_abi() -kernel_abi.check_issues() +_kernel_abi =3D None + +def get_kernel_abi(): + u""" + Initialize kernel_abi global var, if not initialized yet. + + This is needed to avoid warnings during Sphinx module initialization. + """ + global _kernel_abi + + if not _kernel_abi: + # Parse ABI symbols only once + _kernel_abi =3D AbiParser(path, logger=3Dlogger) + _kernel_abi.parse_abi() + _kernel_abi.check_issues() + + return _kernel_abi =20 def setup(app): =20 @@ -83,6 +96,8 @@ class KernelCmd(Directive): } =20 def run(self): + kernel_abi =3D get_kernel_abi() + doc =3D self.state.document if not doc.settings.file_insertion_enabled: raise self.warning("docutils: file insertion disabled") --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 2F56D1DE4D0; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=P47Cq9C8805xThG8L4Tmxb4f8w2jEl19rxPPtM8C5AjTcdSKSmuHPlT6MFyj5fmKToLl21bhYNaY/y7U8npSlwEqEC+PQE45fMTTFuwQdhkLkfVFXEG/9O++eCCo0D/LHxt4Cv6Xxm5UPhUhfF1HQUcflYV5uTZIXeCxSPoHGtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=Wn8MIfDAfzH7a7LQ/69qSLfVvfWFib1jkshB7oN/Uz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dd0ZuIuqTlZvpowZT5dzb0Do696QfgBT/ln0+mcZb5F4s8o4QgLHIv2Uv+F4VXDRKTetLXpLguhnRC9OgxhmQqkEQm1x5/i3HvGyCR124ztZh0BBjBeCj7SjtSFnTo+WQtP65Y12RhXTg4QR6vVrYbGdQI1ryGWMDVNlAs1MocM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n515/V1P; 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="n515/V1P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51102C19422; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=Wn8MIfDAfzH7a7LQ/69qSLfVvfWFib1jkshB7oN/Uz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n515/V1PBJv/UTXId3e7ITd10fxIj+LzLt29t6QO5YHRPwGnm0Kgnhb3dif+xys0K Fvd49NitwT3GB0yVlulkMkFlLRnf51VyPTAJ3aSqNtm/1QDQpmzERCAhEOTt5v1DCH AdXKqyOoMmVhDGR2xpsAFeTKq8zYJTKDwa/AQvlgo4zGvFKbGPDw6eAcpQV15kRSPS VX0AlYyExhoXg1FGMtN5TC3kEBJRy6pZjm5uOEBtMDCHcyr6lMygVFKv0/xEgE1fYt a8mth/QjojZa2o/PDMlRRxK3KhwxMugmpx+GVd4TaPy7La2hxFe9gto9UZkvowg/vy dX4a7lqgxywTA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cjg-23TZ; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 24/27] scripts/lib/abi/abi_parser.py: Rename title name for ABI files Date: Mon, 10 Feb 2025 11:18:13 +0100 Message-ID: X-Mailer: git-send-email 2.48.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 makes them look better when generating cross-references. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/lib/abi/abi_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index 3b1ab4c0bdd7..0c3837e52afa 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -314,7 +314,7 @@ class AbiParser: fdata.ftype =3D path.split("/")[0] =20 fdata.nametag =3D {} - fdata.nametag["what"] =3D [f"File {path}/{basename}"] + fdata.nametag["what"] =3D [f"ABI file {path}/{basename}"] fdata.nametag["type"] =3D "File" fdata.nametag["path"] =3D fdata.ftype fdata.nametag["file"] =3D [fdata.file_ref] --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 1C4DF1DDC14; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=ievwm1KLWHpr3ybawQV+2CRAGc7tKTtDooRruq5I/HStchIudm6Cug7jcm7NV8ugnirUQuMEzwmTND1haXQW2enlQyQQHeiKo+OXKYuvr6moltQKhifXw1d1JDDTgmE1bQJJcNmoy/k3WnwkOj6nnJelLETWLIH6YFGa/sliUes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=C6C05wogDAu+3jTlaZMOMRiURyiScHA+qoQYLRb96Z8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iRSA31tSOq7f9S4elMt1jurNp6Ct7R7I/g3gdlLj0jf4UZj9ldwz1YO3OKItgSzLH+Pe3Jw6oU2mRMZVPMGkse0KkRtCUbRZRQNinzjGhFI3hUAQycYeMTu6MTz5j7BKBblmZsPLeYUjQUG5SE2fRwqJSkosKo2xvwGMTVQKth8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lyCwp/mE; 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="lyCwp/mE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4422EC19421; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=C6C05wogDAu+3jTlaZMOMRiURyiScHA+qoQYLRb96Z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyCwp/mEpEKPVc9GuFIMV2RYIEM646Fn1/G/VWVLj3GFrwf7eKYzaUVrBYNJKx/rC DF7N2adXwEWsRsDwJtxiDUtVFpIgul55a18Jc2JocDMiigdR+9Jbd7Fmva0rvaqE2R WTJXbKAooNTgHUXsCU07BQhQ/lsr54iZhLVcv8JjKwZZvmPK7iVmyZzz5ZAOIIbtbs pgd11/jr/vLzMJuy2SBFRFDkZeHm4RzMKhxi9Jbtxw71lgQWhbgFr3JMZyUk0qDrA3 ZMsNTYaPgYmsmIr37X4fNRxPtuGQvSgNUpUXbGYlM5jkesJPVj7rIGIHvSm79XVmEi 9dv8YxvyjjYEQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cjk-2AR6; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org, Akira Yokosawa Subject: [PATCH 25/27] scripts/lib/abi/abi_parser.py: make it backward-compatible with Python 3.6 Date: Mon, 10 Feb 2025 11:18:14 +0100 Message-ID: <41d2f85df134a46db46fed73a0f9697a3d2ae9ba.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" Despite being introduced on Python 3.6, the original implementation was too limited: it doesn't accept anything but the argument. Even on python 3.10.12, support was still limited, as more complex operations cause SyntaxError: Exception occurred: File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in from get_abi import AbiParser File ".../linux/scripts/lib/abi/abi_parser.py", line 525 msg +=3D f"{part}\n{"-" * len(part)}\n\n" ^ SyntaxError: f-string: expecting '}' Replace f-strings by normal string concatenation when it doesn't work on Python 3.6. Reported-by: Akira Yokosawa Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/lib/abi/abi_parser.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py index 0c3837e52afa..f08de6d3bf7c 100644 --- a/scripts/lib/abi/abi_parser.py +++ b/scripts/lib/abi/abi_parser.py @@ -493,7 +493,7 @@ class AbiParser: =20 if cur_part and cur_part !=3D part: part =3D cur_part - msg +=3D f"{part}\n{"-" * len(part)}\n\n" + msg +=3D part + "\n"+ "-" * len(part) +"\n\n" =20 msg +=3D f".. _{key}:\n\n" =20 @@ -517,7 +517,7 @@ class AbiParser: msg +=3D f"Defined on file :ref:`{base} <{ref[1]}>`\n\= n" =20 if wtype =3D=3D "File": - msg +=3D f"{names[0]}\n{"-" * len(names[0])}\n\n" + msg +=3D names[0] +"\n" + "-" * len(names[0]) +"\n\n" =20 desc =3D v.get("description") if not desc and wtype !=3D "File": @@ -541,7 +541,8 @@ class AbiParser: =20 users =3D v.get("users") if users and users.strip(" \t\n"): - msg +=3D f"Users:\n\t{users.strip("\n").replace('\n', '\n\= t')}\n\n" + users =3D users.strip("\n").replace('\n', '\n\t') + msg +=3D f"Users:\n\t{users}\n\n" =20 ln =3D v.get("line_no", 1) =20 @@ -567,7 +568,9 @@ class AbiParser: elif len(lines) =3D=3D 1: f.append(f"{fname}:{lines[0]}") else: - f.append(f"{fname} lines {", ".join(str(x) for x in li= nes)}") + m =3D fname + "lines " + m +=3D ", ".join(str(x) for x in lines) + f.append(m) =20 self.log.warning("%s is defined %d times: %s", what, len(f), "= ; ".join(f)) =20 @@ -615,10 +618,11 @@ class AbiParser: if users: print(f"Users:\t\t\t{users}") =20 - print(f"Defined on file{'s'[:len(files) ^ 1]}:\t{", ".= join(files)}") + print("Defined on file(s):\t" + ", ".join(files)) =20 if desc: - print(f"\n{desc.strip("\n")}\n") + desc =3D desc.strip("\n") + print(f"\n{desc}\n") =20 if not found_keys: print(f"Regular expression /{expr}/ not found.") --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 4150E1DE8A6; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=p4zikGdXanZUwXXI5wp9qzVk6hxVM48ytOb4yeP6FeecHwMKDxGtf/fLku0wqrXEMgVmHwtdR+hw5L4fFvR1Q7t2KJXZ0ZV0beAChGDamcMZs9jObCvZywOj+fwokhXpVlUCkIBqyZ1+IhW2Jd1B7FhPp6TDCPm7Uqa/hnEltV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=G4Ao1AS7x1gxC+qfXgw6zg9b3k3cUZLk9tkKvro3lOs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EwEEaA+NfTMmE9NRUmXWBZZdxb4HnpboA/LuTtTC2KGV3D3//rDBSWWK0xnEv2eWVmLGyFkyT/CPN+zsEtPOl6tLxg5akw3AziANe498r7p/g3VnNjMYhJllNSqF1lnP4rO1vQqBdj1co/gjUrhV3uPiFlECZTOZmnICLrjTJcU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gpevRi7+; 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="gpevRi7+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D42DC4CEEF; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=G4Ao1AS7x1gxC+qfXgw6zg9b3k3cUZLk9tkKvro3lOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gpevRi7+sd5JkIn6v8XPmLemxtBNYOmDZEXSi4jLr80GRvCO95fAQpKIC7+b7uAEq 47MWJMhDW7v3cpsUCrIo2polMUTotTJtaP0y3eACX39hddOkIm8NhQfwSBqetki7Hm YAoazGazcFphIQeqQwJrGvCFhI395FElQ8Y2Nfp1aZBFyFrRer+/dCs7KPGQSSD/7C m0Mfmp1adjkfC4Rx/Pl1s9D3lLVH2yxjYo1sZQ8wNlP+2X3RGL5chMOgusuIYA3I7J CGZtUhyD7l+XIacR0Cko5lhzuqHZB0ZmaaSIF255s7UiWzD141ByGzu/quqnIv0Tbt +VL846pSUrRSg== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cjo-2HRu; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Guilherme G. Piccoli" , "Jonathan Corbet" , "Mauro Carvalho Chehab" , Kees Cook , Tony Luck , bpf@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 26/27] scripts/get_abi.py: add support for undefined ABIs Date: Mon, 10 Feb 2025 11:18:15 +0100 Message-ID: <1529c255845d117696d5af57d8dc05554663afdf.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab The undefined logic is complex and has lots of magic on it. Implement it, using the same algorithm we have at get_abi.pl. Yet, some tweaks to optimize performance and to make the code simpler were added here: - at the perl version, the tree graph had loops, so we had to use BFS to traverse it. On this version, the graph is a tree, so, it simplifies the what group for sysfs aliases; - the logic which splits regular expressions into subgroups was re-written to make it faster; - it may optionally use multiple processes to search for symbol matches; - it has some additional debug levels. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/get_abi.py | 68 ++++++ scripts/lib/abi/abi_regex.py | 234 ++++++++++++++++++ scripts/lib/abi/helpers.py | 16 +- scripts/lib/abi/system_symbols.py | 378 ++++++++++++++++++++++++++++++ 4 files changed, 693 insertions(+), 3 deletions(-) create mode 100644 scripts/lib/abi/abi_regex.py create mode 100644 scripts/lib/abi/system_symbols.py diff --git a/scripts/get_abi.py b/scripts/get_abi.py index 19f78d6aa407..7ce4748a46d2 100755 --- a/scripts/get_abi.py +++ b/scripts/get_abi.py @@ -20,7 +20,9 @@ SRC_DIR =3D os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) =20 from abi_parser import AbiParser # pylint: disable=3DC0413 +from abi_regex import AbiRegex # pylint: disable=3DC0413 from helpers import ABI_DIR, DEBUG_HELP # pylint: disable=3DC0413 +from system_symbols import SystemSymbols # pylint: disable=3DC0413 =20 # Command line classes =20 @@ -111,6 +113,71 @@ class AbiSearch: parser.parse_abi() parser.search_symbols(args.expression) =20 +UNDEFINED_DESC=3D""" +Check undefined ABIs on local machine. + +Read sysfs devnodes and check if the devnodes there are defined inside +ABI documentation. + +The search logic tries to minimize the number of regular expressions to +search per each symbol. + +By default, it runs on a single CPU, as Python support for CPU threads +is still experimental, and multi-process runs on Python is very slow. + +On experimental tests, if the number of ABI symbols to search per devnode +is contained on a limit of ~150 regular expressions, using a single CPU +is a lot faster than using multiple processes. However, if the number of +regular expressions to check is at the order of ~30000, using multiple +CPUs speeds up the check. +""" + +class AbiUndefined: + """ + Initialize an argparse subparser for logic to check undefined ABI at + the current machine's sysfs + """ + + def __init__(self, subparsers): + """Initialize argparse subparsers""" + + parser =3D subparsers.add_parser("undefined", + formatter_class=3Dargparse.RawTextH= elpFormatter, + description=3DUNDEFINED_DESC) + + parser.add_argument("-S", "--sysfs-dir", default=3D"/sys", + help=3D"directory where sysfs is mounted") + parser.add_argument("-s", "--search-string", + help=3D"search string regular expression to li= mit symbol search") + parser.add_argument("-H", "--show-hints", action=3D"store_true", + help=3D"Hints about definitions for missing AB= I symbols.") + parser.add_argument("-j", "--jobs", "--max-workers", type=3Dint, d= efault=3D1, + help=3D"If bigger than one, enables multiproce= ssing.") + parser.add_argument("-c", "--max-chunk-size", type=3Dint, default= =3D50, + help=3D"Maximum number of chunk size") + parser.add_argument("-f", "--found", action=3D"store_true", + help=3D"Also show found items. " + "Helpful to debug the parser."), + parser.add_argument("-d", "--dry-run", action=3D"store_true", + help=3D"Don't actually search for undefined. " + "Helpful to debug the parser."), + + parser.set_defaults(func=3Dself.run) + + def run(self, args): + """Run subparser""" + + abi =3D AbiRegex(args.dir, debug=3Dargs.debug, + search_string=3Dargs.search_string) + + abi_symbols =3D SystemSymbols(abi=3Dabi, hints=3Dargs.show_hints, + sysfs=3Dargs.sysfs_dir) + + abi_symbols.check_undefined_symbols(dry_run=3Dargs.dry_run, + found=3Dargs.found, + max_workers=3Dargs.jobs, + chunk_size=3Dargs.max_chunk_si= ze) + =20 def main(): """Main program""" @@ -125,6 +192,7 @@ def main(): AbiRest(subparsers) AbiValidate(subparsers) AbiSearch(subparsers) + AbiUndefined(subparsers) =20 args =3D parser.parse_args() =20 diff --git a/scripts/lib/abi/abi_regex.py b/scripts/lib/abi/abi_regex.py new file mode 100644 index 000000000000..8a57846cbc69 --- /dev/null +++ b/scripts/lib/abi/abi_regex.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +# xxpylint: disable=3DR0903 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# SPDX-License-Identifier: GPL-2.0 + +""" +Convert ABI what into regular expressions +""" + +import re +import sys + +from pprint import pformat + +from abi_parser import AbiParser +from helpers import AbiDebug + +class AbiRegex(AbiParser): + """Extends AbiParser to search ABI nodes with regular expressions""" + + # Escape only ASCII visible characters + escape_symbols =3D r"([\x21-\x29\x2b-\x2d\x3a-\x40\x5c\x60\x7b-\x7e])" + leave_others =3D "others" + + # Tuples with regular expressions to be compiled and replacement data + re_whats =3D [ + # Drop escape characters that might exist + (re.compile("\\\\"), ""), + + # Temporarily escape dot characters + (re.compile(r"\."), "\xf6"), + + # Temporarily change [0-9]+ type of patterns + (re.compile(r"\[0\-9\]\+"), "\xff"), + + # Temporarily change [\d+-\d+] type of patterns + (re.compile(r"\[0\-\d+\]"), "\xff"), + (re.compile(r"\[0:\d+\]"), "\xff"), + (re.compile(r"\[(\d+)\]"), "\xf4\\\\d+\xf5"), + + # Temporarily change [0-9] type of patterns + (re.compile(r"\[(\d)\-(\d)\]"), "\xf4\1-\2\xf5"), + + # Handle multiple option patterns + (re.compile(r"[\{\<\[]([\w_]+)(?:[,|]+([\w_]+)){1,}[\}\>\]]"), r"(= \1|\2)"), + + # Handle wildcards + (re.compile(r"([^\/])\*"), "\\1\\\\w\xf7"), + (re.compile(r"/\*/"), "/.*/"), + (re.compile(r"/\xf6\xf6\xf6"), "/.*"), + (re.compile(r"\<[^\>]+\>"), "\\\\w\xf7"), + (re.compile(r"\{[^\}]+\}"), "\\\\w\xf7"), + (re.compile(r"\[[^\]]+\]"), "\\\\w\xf7"), + + (re.compile(r"XX+"), "\\\\w\xf7"), + (re.compile(r"([^A-Z])[XYZ]([^A-Z])"), "\\1\\\\w\xf7\\2"), + (re.compile(r"([^A-Z])[XYZ]$"), "\\1\\\\w\xf7"), + (re.compile(r"_[AB]_"), "_\\\\w\xf7_"), + + # Recover [0-9] type of patterns + (re.compile(r"\xf4"), "["), + (re.compile(r"\xf5"), "]"), + + # Remove duplicated spaces + (re.compile(r"\s+"), r" "), + + # Special case: drop comparison as in: + # What: foo =3D + # (this happens on a few IIO definitions) + (re.compile(r"\s*\=3D.*$"), ""), + + # Escape all other symbols + (re.compile(escape_symbols), r"\\\1"), + (re.compile(r"\\\\"), r"\\"), + (re.compile(r"\\([\[\]\(\)\|])"), r"\1"), + (re.compile(r"(\d+)\\(-\d+)"), r"\1\2"), + + (re.compile(r"\xff"), r"\\d+"), + + # Special case: IIO ABI which a parenthesis. + (re.compile(r"sqrt(.*)"), r"sqrt(.*)"), + + # Simplify regexes with multiple .* + (re.compile(r"(?:\.\*){2,}"), ""), + + # Recover dot characters + (re.compile(r"\xf6"), "\\."), + # Recover plus characters + (re.compile(r"\xf7"), "+"), + ] + re_has_num =3D re.compile(r"\\d") + + # Symbol name after escape_chars that are considered a devnode basename + re_symbol_name =3D re.compile(r"(\w|\\[\.\-\:])+$") + + # List of popular group names to be skipped to minimize regex group si= ze + # Use AbiDebug.SUBGROUP_SIZE to detect those + skip_names =3D set(["devices", "hwmon"]) + + def regex_append(self, what, new): + """ + Get a search group for a subset of regular expressions. + + As ABI may have thousands of symbols, using a for to search all + regular expressions is at least O(n^2). When there are wildcards, + the complexity increases substantially, eventually becoming expone= ntial. + + To avoid spending too much time on them, use a logic to split + them into groups. The smaller the group, the better, as it would + mean that searches will be confined to a small number of regular + expressions. + + The conversion to a regex subset is tricky, as we need something + that can be easily obtained from the sysfs symbol and from the + regular expression. So, we need to discard nodes that have + wildcards. + + If it can't obtain a subgroup, place the regular expression inside + a special group (self.leave_others). + """ + + search_group =3D None + + for search_group in reversed(new.split("/")): + if not search_group or search_group in self.skip_names: + continue + if self.re_symbol_name.match(search_group): + break + + if not search_group: + search_group =3D self.leave_others + + if self.debug & AbiDebug.SUBGROUP_MAP: + self.log.debug("%s: mapped as %s", what, search_group) + + try: + if search_group not in self.regex_group: + self.regex_group[search_group] =3D [] + + self.regex_group[search_group].append(re.compile(new)) + if self.search_string: + if what.find(self.search_string) >=3D 0: + print(f"What: {what}") + except re.PatternError: + self.log.warning("Ignoring '%s' as it produced an invalid rege= x:\n" + " '%s'", what, new) + + def get_regexes(self, what): + """ + Given an ABI devnode, return a list of all regular expressions that + may match it, based on the sub-groups created by regex_append() + """ + + re_list =3D [] + + patches =3D what.split("/") + patches.reverse() + patches.append(self.leave_others) + + for search_group in patches: + if search_group in self.regex_group: + re_list +=3D self.regex_group[search_group] + + return re_list + + def __init__(self, *args, **kwargs): + """ + Override init method to get verbose argument + """ + + self.regex_group =3D None + self.search_string =3D None + self.re_string =3D None + + if "search_string" in kwargs: + self.search_string =3D kwargs.get("search_string") + del kwargs["search_string"] + + if self.search_string: + + try: + self.re_string =3D re.compile(self.search_string) + except re.PatternError as e: + msg =3D f"{self.search_string} is not a valid regular = expression" + raise ValueError(msg) from e + + super().__init__(*args, **kwargs) + + def parse_abi(self, *args, **kwargs): + + super().parse_abi(*args, **kwargs) + + self.regex_group =3D {} + + print("Converting ABI What fields into regexes...", file=3Dsys.std= err) + + for t in sorted(self.data.items(), key=3Dlambda x: x[0]): + v =3D t[1] + if v.get("type") =3D=3D "File": + continue + + v["regex"] =3D [] + + for what in v.get("what", []): + if not what.startswith("/sys"): + continue + + new =3D what + for r, s in self.re_whats: + try: + new =3D r.sub(s, new) + except re.PatternError as e: + # Help debugging troubles with new regexes + raise re.PatternError(f"{e}\nwhile re.sub('{r.patt= ern}', {s}, str)") from e + + v["regex"].append(new) + + if self.debug & AbiDebug.REGEX: + self.log.debug("%-90s <=3D=3D %s", new, what) + + # Store regex into a subgroup to speedup searches + self.regex_append(what, new) + + if self.debug & AbiDebug.SUBGROUP_DICT: + self.log.debug("%s", pformat(self.regex_group)) + + if self.debug & AbiDebug.SUBGROUP_SIZE: + biggestd_keys =3D sorted(self.regex_group.keys(), + key=3D lambda k: len(self.regex_group[k= ]), + reverse=3DTrue) + + print("Top regex subgroups:", file=3Dsys.stderr) + for k in biggestd_keys[:10]: + print(f"{k} has {len(self.regex_group[k])} elements", file= =3Dsys.stderr) diff --git a/scripts/lib/abi/helpers.py b/scripts/lib/abi/helpers.py index 84a253ed5058..639b23e4ca33 100644 --- a/scripts/lib/abi/helpers.py +++ b/scripts/lib/abi/helpers.py @@ -16,13 +16,23 @@ class AbiDebug: WHAT_PARSING =3D 1 WHAT_OPEN =3D 2 DUMP_ABI_STRUCTS =3D 4 + UNDEFINED =3D 8 + REGEX =3D 16 + SUBGROUP_MAP =3D 32 + SUBGROUP_DICT =3D 64 + SUBGROUP_SIZE =3D 128 + GRAPH =3D 256 =20 =20 DEBUG_HELP =3D """ -Print debug information according with the level(s), -which is given by the following bitmask: - 1 - enable debug parsing logic 2 - enable debug messages on file open 4 - enable debug for ABI parse data +8 - enable extra debug information to identify troubles + with ABI symbols found at the local machine that + weren't found on ABI documentation (used only for + undefined subcommand) +16 - enable debug for what to regex conversion +32 - enable debug for symbol regex subgroups +64 - enable debug for sysfs graph tree variable """ diff --git a/scripts/lib/abi/system_symbols.py b/scripts/lib/abi/system_sym= bols.py new file mode 100644 index 000000000000..f15c94a6e33c --- /dev/null +++ b/scripts/lib/abi/system_symbols.py @@ -0,0 +1,378 @@ +#!/usr/bin/env python3 +# pylint: disable=3DR0902,R0912,R0914,R0915,R1702 +# Copyright(c) 2025: Mauro Carvalho Chehab . +# SPDX-License-Identifier: GPL-2.0 + +""" +Parse ABI documentation and produce results from it. +""" + +import os +import re +import sys + +from concurrent import futures +from datetime import datetime +from random import shuffle + +from helpers import AbiDebug + +class SystemSymbols: + """Stores arguments for the class and initialize class vars""" + + def graph_add_file(self, path, link=3DNone): + """ + add a file path to the sysfs graph stored at self.root + """ + + if path in self.files: + return + + name =3D "" + ref =3D self.root + for edge in path.split("/"): + name +=3D edge + "/" + if edge not in ref: + ref[edge] =3D {"__name": [name.rstrip("/")]} + + ref =3D ref[edge] + + if link and link not in ref["__name"]: + ref["__name"].append(link.rstrip("/")) + + self.files.add(path) + + def print_graph(self, root_prefix=3D"", root=3DNone, level=3D0): + """Prints a reference tree graph using UTF-8 characters""" + + if not root: + root =3D self.root + level =3D 0 + + # Prevent endless traverse + if level > 5: + return + + if level > 0: + prefix =3D "=E2=94=9C=E2=94=80=E2=94=80" + last_prefix =3D "=E2=94=94=E2=94=80=E2=94=80" + else: + prefix =3D "" + last_prefix =3D "" + + items =3D list(root.items()) + + names =3D root.get("__name", []) + for k, edge in items: + if k =3D=3D "__name": + continue + + if not k: + k =3D "/" + + if len(names) > 1: + k +=3D " links: " + ",".join(names[1:]) + + if edge =3D=3D items[-1][1]: + print(root_prefix + last_prefix + k) + p =3D root_prefix + if level > 0: + p +=3D " " + self.print_graph(p, edge, level + 1) + else: + print(root_prefix + prefix + k) + p =3D root_prefix + "=E2=94=82 " + self.print_graph(p, edge, level + 1) + + def _walk(self, root): + """ + Walk through sysfs to get all devnodes that aren't ignored. + + By default, uses /sys as sysfs mounting point. If another + directory is used, it replaces them to /sys at the patches. + """ + + with os.scandir(root) as obj: + for entry in obj: + path =3D os.path.join(root, entry.name) + if self.sysfs: + p =3D path.replace(self.sysfs, "/sys", count=3D1) + else: + p =3D path + + if self.re_ignore.search(p): + return + + # Handle link first to avoid directory recursion + if entry.is_symlink(): + real =3D os.path.realpath(path) + if not self.sysfs: + self.aliases[path] =3D real + else: + real =3D real.replace(self.sysfs, "/sys", count=3D= 1) + + # Add absfile location to graph if it doesn't exist + if not self.re_ignore.search(real): + # Add link to the graph + self.graph_add_file(real, p) + + elif entry.is_file(): + self.graph_add_file(p) + + elif entry.is_dir(): + self._walk(path) + + def __init__(self, abi, sysfs=3D"/sys", hints=3DFalse): + """ + Initialize internal variables and get a list of all files inside + sysfs that can currently be parsed. + + Please notice that there are several entries on sysfs that aren't + documented as ABI. Ignore those. + + The real paths will be stored under self.files. Aliases will be + stored in separate, as self.aliases. + """ + + self.abi =3D abi + self.log =3D abi.log + + if sysfs !=3D "/sys": + self.sysfs =3D sysfs.rstrip("/") + else: + self.sysfs =3D None + + self.hints =3D hints + + self.root =3D {} + self.aliases =3D {} + self.files =3D set() + + dont_walk =3D [ + # Those require root access and aren't documented at ABI + f"^{sysfs}/kernel/debug", + f"^{sysfs}/kernel/tracing", + f"^{sysfs}/fs/pstore", + f"^{sysfs}/fs/bpf", + f"^{sysfs}/fs/fuse", + + # This is not documented at ABI + f"^{sysfs}/module", + + f"^{sysfs}/fs/cgroup", # this is big and has zero docs under = ABI + f"^{sysfs}/firmware", # documented elsewhere: ACPI, DT bindi= ngs + "sections|notes", # aren't actually part of ABI + + # kernel-parameters.txt - not easy to parse + "parameters", + ] + + self.re_ignore =3D re.compile("|".join(dont_walk)) + + print(f"Reading {sysfs} directory contents...", file=3Dsys.stderr) + self._walk(sysfs) + + def check_file(self, refs, found): + """Check missing ABI symbols for a given sysfs file""" + + res_list =3D [] + + try: + for names in refs: + fname =3D names[0] + + res =3D { + "found": False, + "fname": fname, + "msg": "", + } + res_list.append(res) + + re_what =3D self.abi.get_regexes(fname) + if not re_what: + self.abi.log.warning(f"missing rules for {fname}") + continue + + for name in names: + for r in re_what: + if self.abi.debug & AbiDebug.UNDEFINED: + self.log.debug("check if %s matches '%s'", nam= e, r.pattern) + if r.match(name): + res["found"] =3D True + if found: + res["msg"] +=3D f" {fname}: regex:\n\t" + continue + + if self.hints and not res["found"]: + res["msg"] +=3D f" {fname} not found. Tested regexes:= \n" + for r in re_what: + res["msg"] +=3D " " + r.pattern + "\n" + + except KeyboardInterrupt: + pass + + return res_list + + def _ref_interactor(self, root): + """Recursive function to interact over the sysfs tree""" + + for k, v in root.items(): + if isinstance(v, dict): + yield from self._ref_interactor(v) + + if root =3D=3D self.root or k =3D=3D "__name": + continue + + if self.abi.re_string: + fname =3D v["__name"][0] + if self.abi.re_string.search(fname): + yield v + else: + yield v + + + def get_fileref(self, all_refs, chunk_size): + """Interactor to group refs into chunks""" + + n =3D 0 + refs =3D [] + + for ref in all_refs: + refs.append(ref) + + n +=3D 1 + if n >=3D chunk_size: + yield refs + n =3D 0 + refs =3D [] + + yield refs + + def check_undefined_symbols(self, max_workers=3DNone, chunk_size=3D50, + found=3DNone, dry_run=3DNone): + """Seach ABI for sysfs symbols missing documentation""" + + self.abi.parse_abi() + + if self.abi.debug & AbiDebug.GRAPH: + self.print_graph() + + all_refs =3D [] + for ref in self._ref_interactor(self.root): + all_refs.append(ref["__name"]) + + if dry_run: + print("Would check", file=3Dsys.stderr) + for ref in all_refs: + print(", ".join(ref)) + + return + + print("Starting to search symbols (it may take several minutes):", + file=3Dsys.stderr) + start =3D datetime.now() + old_elapsed =3D None + + # Python doesn't support multithreading due to limitations on its + # global lock (GIL). While Python 3.13 finally made GIL optional, + # there are still issues related to it. Also, we want to have + # backward compatibility with older versions of Python. + # + # So, use instead multiprocess. However, Python is very slow passi= ng + # data from/to multiple processes. Also, it may consume lots of me= mory + # if the data to be shared is not small. So, we need to group wor= kload + # in chunks that are big enough to generate performance gains while + # not being so big that would cause out-of-memory. + + num_refs =3D len(all_refs) + print(f"Number of references to parse: {num_refs}", file=3Dsys.std= err) + + if not max_workers: + max_workers =3D os.cpu_count() + elif max_workers > os.cpu_count(): + max_workers =3D os.cpu_count() + + max_workers =3D max(max_workers, 1) + + max_chunk_size =3D int((num_refs + max_workers - 1) / max_workers) + chunk_size =3D min(chunk_size, max_chunk_size) + chunk_size =3D max(1, chunk_size) + + if max_workers > 1: + executor =3D futures.ProcessPoolExecutor + + # Place references in a random order. This may help improving + # performance, by mixing complex/simple expressions when creat= ing + # chunks + shuffle(all_refs) + else: + # Python has a high overhead with processes. When there's just + # one worker, it is faster to not create a new process. + # Yet, User still deserves to have a progress print. So, use + # python's "thread", which is actually a single process, using + # an internal schedule to switch between tasks. No performance + # gains for non-IO tasks, but still it can be quickly interrup= ted + # from time to time to display progress. + executor =3D futures.ThreadPoolExecutor + + not_found =3D [] + f_list =3D [] + with executor(max_workers=3Dmax_workers) as exe: + for refs in self.get_fileref(all_refs, chunk_size): + if refs: + try: + f_list.append(exe.submit(self.check_file, refs, fo= und)) + + except KeyboardInterrupt: + return + + total =3D len(f_list) + + if not total: + if self.abi.re_string: + print(f"No ABI symbol matches {self.abi.search_string}= ") + else: + self.abi.log.warning("No ABI symbols found") + return + + print(f"{len(f_list):6d} jobs queued on {max_workers} workers", + file=3Dsys.stderr) + + while f_list: + try: + t =3D futures.wait(f_list, timeout=3D1, + return_when=3Dfutures.FIRST_COMPLETED) + + done =3D t[0] + + for fut in done: + res_list =3D fut.result() + + for res in res_list: + if not res["found"]: + not_found.append(res["fname"]) + if res["msg"]: + print(res["msg"]) + + f_list.remove(fut) + except KeyboardInterrupt: + return + + except RuntimeError as e: + self.abi.log.warning(f"Future: {e}") + break + + if sys.stderr.isatty(): + elapsed =3D str(datetime.now() - start).split(".", max= split=3D1)[0] + if len(f_list) < total: + elapsed +=3D f" ({total - len(f_list)}/{total} job= s completed). " + if elapsed !=3D old_elapsed: + print(elapsed + "\r", end=3D"", flush=3DTrue, + file=3Dsys.stderr) + old_elapsed =3D elapsed + + elapsed =3D str(datetime.now() - start).split(".", maxsplit=3D1)[0] + print(elapsed, file=3Dsys.stderr) + + for f in sorted(not_found): + print(f"{f} not found.") --=20 2.48.1 From nobody Tue Dec 16 22:10:39 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 4712B1DED63; Mon, 10 Feb 2025 10:18: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=1739182705; cv=none; b=Pv8xxHX0uPFZ3haaN51QkuvdhlPy312lmlg/0t4wJkWMUo0MloOFz/cPs8zfFHn+uY0dWvq874ksjGuhDF835rNGA+AKPX1ISm0o6MHkwqV/T6VcyBhvITeWCMyUXljtklzKnwPJbjlEc4iaxQ0JZrkgh3cte/KOBpKDmhGymro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739182705; c=relaxed/simple; bh=sCuTz3zxaa3V2tY51057fBvBcrlzP04scyPpCe0UiUk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HkjZOxJ1BYDP+jIVyqrSFyMEIYe8iUHXkMsMcEbQ7phHr8zW/C+FlkDGBeMXniMFVKxKbgkIX815vP0KTcetWZTu1wypUojIypCb23/ewUVBYekfcRa0idPsOqU/feGNAlbw5WDyhzzFTt/wKArx8maWROhZMNSoMEywInBy/wE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MLZjQNMj; 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="MLZjQNMj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B3CBC2BCB2; Mon, 10 Feb 2025 10:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739182704; bh=sCuTz3zxaa3V2tY51057fBvBcrlzP04scyPpCe0UiUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MLZjQNMjHHzoyAfoDi7A1lOZldyuqNYOm+b5ILtFKI5JUanNLnJDHxoryBFzIjNLH hD9C6UMvzwr02jrHNjQbGcSpvI4ZSR6hTSg4p+D5rkiRhsV7IS833chcTYh4j5ozq/ NPXHbldKV3UfThHP3XuOtxWvbgwDXspI1gS8o2rQWD6ozfG3YvDn9df794g39Q5Miu DQLcDr3SDMGI9fvZQeKTKlTmoPYLlVN+mFlP7iQm/pWTRTDK/r8q5KvyhO2DR+uUj+ AtbtSnneRpl30+kgV8ANozSIWYuQHx63DWfHOpxod+5EveHbblwP42XwOFhylTPQhU chdF+UNqJeIqQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1thQru-00000006Cjs-2P03; Mon, 10 Feb 2025 11:18:22 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Guilherme G. Piccoli" , "Jonathan Corbet" , "Mauro Carvalho Chehab" , Kees Cook , Tony Luck , bpf@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 27/27] scripts/get_abi.pl: drop now obsoleted script Date: Mon, 10 Feb 2025 11:18:16 +0100 Message-ID: <698ec258b36b63ccde5f7da1af9c97cf8df51050.1739182025.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.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" As all functionalities of it were migrated to get_abi.py, drop the now obsoleted script. Signed-off-by: Mauro Carvalho Chehab Suggested-by: Jonathan Corbet --- scripts/get_abi.pl | 1103 -------------------------------------------- 1 file changed, 1103 deletions(-) delete mode 100755 scripts/get_abi.pl diff --git a/scripts/get_abi.pl b/scripts/get_abi.pl deleted file mode 100755 index de1c0354b50c..000000000000 --- a/scripts/get_abi.pl +++ /dev/null @@ -1,1103 +0,0 @@ -#!/usr/bin/env perl -# SPDX-License-Identifier: GPL-2.0 - -BEGIN { $Pod::Usage::Formatter =3D 'Pod::Text::Termcap'; } - -use strict; -use warnings; -use utf8; -use Pod::Usage qw(pod2usage); -use Getopt::Long; -use File::Find; -use IO::Handle; -use Fcntl ':mode'; -use Cwd 'abs_path'; -use Data::Dumper; - -my $help =3D 0; -my $hint =3D 0; -my $man =3D 0; -my $debug =3D 0; -my $enable_lineno =3D 0; -my $show_warnings =3D 1; -my $prefix=3D"Documentation/ABI"; -my $sysfs_prefix=3D"/sys"; -my $search_string; - -# Debug options -my $dbg_what_parsing =3D 1; -my $dbg_what_open =3D 2; -my $dbg_dump_abi_structs =3D 4; -my $dbg_undefined =3D 8; - -$Data::Dumper::Indent =3D 1; -$Data::Dumper::Terse =3D 1; - -# -# If true, assumes that the description is formatted with ReST -# -my $description_is_rst =3D 1; - -GetOptions( - "debug=3Di" =3D> \$debug, - "enable-lineno" =3D> \$enable_lineno, - "rst-source!" =3D> \$description_is_rst, - "dir=3Ds" =3D> \$prefix, - 'help|?' =3D> \$help, - "show-hints" =3D> \$hint, - "search-string=3Ds" =3D> \$search_string, - man =3D> \$man -) or pod2usage(2); - -pod2usage(1) if $help; -pod2usage(-exitstatus =3D> 0, -noperldoc, -verbose =3D> 2) if $man; - -pod2usage(2) if (scalar @ARGV < 1 || @ARGV > 2); - -my ($cmd, $arg) =3D @ARGV; - -pod2usage(2) if ($cmd ne "search" && $cmd ne "rest" && $cmd ne "validate" = && $cmd ne "undefined"); -pod2usage(2) if ($cmd eq "search" && !$arg); - -require Data::Dumper if ($debug & $dbg_dump_abi_structs); - -my %data; -my %symbols; - -# -# Displays an error message, printing file name and line -# -sub parse_error($$$$) { - my ($file, $ln, $msg, $data) =3D @_; - - return if (!$show_warnings); - - $data =3D~ s/\s+$/\n/; - - print STDERR "Warning: file $file#$ln:\n\t$msg"; - - if ($data ne "") { - print STDERR ". Line\n\t\t$data"; - } else { - print STDERR "\n"; - } -} - -# -# Parse an ABI file, storing its contents at %data -# -sub parse_abi { - my $file =3D $File::Find::name; - - my $mode =3D (stat($file))[2]; - return if ($mode & S_IFDIR); - return if ($file =3D~ m,/README,); - return if ($file =3D~ m,/\.,); - return if ($file =3D~ m,\.(rej|org|orig|bak)$,); - - my $name =3D $file; - $name =3D~ s,.*/,,; - - my $fn =3D $file; - $fn =3D~ s,.*Documentation/ABI/,,; - - my $nametag =3D "File $fn"; - $data{$nametag}->{what} =3D "File $name"; - $data{$nametag}->{type} =3D "File"; - $data{$nametag}->{file} =3D $name; - $data{$nametag}->{filepath} =3D $file; - $data{$nametag}->{is_file} =3D 1; - $data{$nametag}->{line_no} =3D 1; - - my $type =3D $file; - $type =3D~ s,.*/(.*)/.*,$1,; - - my $what; - my $new_what; - my $tag =3D ""; - my $ln; - my $xrefs; - my $space; - my @labels; - my $label =3D ""; - - print STDERR "Opening $file\n" if ($debug & $dbg_what_open); - open IN, $file; - while() { - $ln++; - if (m/^(\S+)(:\s*)(.*)/i) { - my $new_tag =3D lc($1); - my $sep =3D $2; - my $content =3D $3; - - if (!($new_tag =3D~ m/(what|where|date|kernelversion|contact|descriptio= n|users)/)) { - if ($tag eq "description") { - # New "tag" is actually part of - # description. Don't consider it a tag - $new_tag =3D ""; - } elsif ($tag ne "") { - parse_error($file, $ln, "tag '$tag' is invalid", $_); - } - } - - # Invalid, but it is a common mistake - if ($new_tag eq "where") { - parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' ins= tead", ""); - $new_tag =3D "what"; - } - - if ($new_tag =3D~ m/what/) { - $space =3D ""; - $content =3D~ s/[,.;]$//; - - push @{$symbols{$content}->{file}}, " $file:" . ($ln - 1); - - if ($tag =3D~ m/what/) { - $what .=3D "\xac" . $content; - } else { - if ($what) { - parse_error($file, $ln, "What '$what' doesn't have a description", "= ") if (!$data{$what}->{description}); - - foreach my $w(split /\xac/, $what) { - $symbols{$w}->{xref} =3D $what; - }; - } - - $what =3D $content; - $label =3D $content; - $new_what =3D 1; - } - push @labels, [($content, $label)]; - $tag =3D $new_tag; - - push @{$data{$nametag}->{symbols}}, $content if ($data{$nametag}->{wha= t}); - next; - } - - if ($tag ne "" && $new_tag) { - $tag =3D $new_tag; - - if ($new_what) { - @{$data{$what}->{label_list}} =3D @labels if ($data{$nametag}->{what}= ); - @labels =3D (); - $label =3D ""; - $new_what =3D 0; - - $data{$what}->{type} =3D $type; - if (!defined($data{$what}->{file})) { - $data{$what}->{file} =3D $name; - $data{$what}->{filepath} =3D $file; - } else { - $data{$what}->{description} .=3D "\n\n" if (defined($data{$what}->{d= escription})); - if ($name ne $data{$what}->{file}) { - $data{$what}->{file} .=3D " " . $name; - $data{$what}->{filepath} .=3D " " . $file; - } - } - print STDERR "\twhat: $what\n" if ($debug & $dbg_what_parsing); - $data{$what}->{line_no} =3D $ln; - } else { - $data{$what}->{line_no} =3D $ln if (!defined($data{$what}->{line_no})= ); - } - - if (!$what) { - parse_error($file, $ln, "'What:' should come first:", $_); - next; - } - if ($new_tag eq "description") { - $sep =3D~ s,:, ,; - $content =3D ' ' x length($new_tag) . $sep . $content; - while ($content =3D~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e)= {} - if ($content =3D~ m/^(\s*)(\S.*)$/) { - # Preserve initial spaces for the first line - $space =3D $1; - $content =3D "$2\n"; - $data{$what}->{$tag} .=3D $content; - } else { - undef($space); - } - - } else { - $data{$what}->{$tag} =3D $content; - } - next; - } - } - - # Store any contents before tags at the database - if (!$tag && $data{$nametag}->{what}) { - $data{$nametag}->{description} .=3D $_; - next; - } - - if ($tag eq "description") { - my $content =3D $_; - while ($content =3D~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {} - if (m/^\s*\n/) { - $data{$what}->{$tag} .=3D "\n"; - next; - } - - if (!defined($space)) { - # Preserve initial spaces for the first line - if ($content =3D~ m/^(\s*)(\S.*)$/) { - $space =3D $1; - $content =3D "$2\n"; - } - } else { - $space =3D "" if (!($content =3D~ s/^($space)//)); - } - $data{$what}->{$tag} .=3D $content; - - next; - } - if (m/^\s*(.*)/) { - $data{$what}->{$tag} .=3D "\n$1"; - $data{$what}->{$tag} =3D~ s/\n+$//; - next; - } - - # Everything else is error - parse_error($file, $ln, "Unexpected content", $_); - } - $data{$nametag}->{description} =3D~ s/^\n+// if ($data{$nametag}->{descri= ption}); - if ($what) { - parse_error($file, $ln, "What '$what' doesn't have a description", "") i= f (!$data{$what}->{description}); - - foreach my $w(split /\xac/,$what) { - $symbols{$w}->{xref} =3D $what; - }; - } - close IN; -} - -sub create_labels { - my %labels; - - foreach my $what (keys %data) { - next if ($data{$what}->{file} eq "File"); - - foreach my $p (@{$data{$what}->{label_list}}) { - my ($content, $label) =3D @{$p}; - $label =3D "abi_" . $label . " "; - $label =3D~ tr/A-Z/a-z/; - - # Convert special chars to "_" - $label =3D~s/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xff])/_/g; - $label =3D~ s,_+,_,g; - $label =3D~ s,_$,,; - - # Avoid duplicated labels - while (defined($labels{$label})) { - my @chars =3D ("A".."Z", "a".."z"); - $label .=3D $chars[rand @chars]; - } - $labels{$label} =3D 1; - - $data{$what}->{label} =3D $label; - - # only one label is enough - last; - } - } -} - -# -# Outputs the book on ReST format -# - -# \b doesn't work well with paths. So, we need to define something else: -# Boundaries are punct characters, spaces and end-of-line -my $start =3D qr {(^|\s|\() }x; -my $bondary =3D qr { ([,.:;\)\s]|\z) }x; -my $xref_match =3D qr { $start(\/(sys|config|proc|dev|kvd)\/[^,.:;\)\s]+)$= bondary }x; -my $symbols =3D qr { ([\x01-\x08\x0e-\x1f\x21-\x2f\x3a-\x40\x7b-\xff]) }x; - -sub output_rest { - create_labels(); - - my $part =3D ""; - - foreach my $what (sort { - ($data{$a}->{type} eq "File") cmp ($data{$b}->{type} eq "File") || - $a cmp $b - } keys %data) { - my $type =3D $data{$what}->{type}; - - my @file =3D split / /, $data{$what}->{file}; - my @filepath =3D split / /, $data{$what}->{filepath}; - - if ($enable_lineno) { - printf ".. LINENO %s%s#%s\n\n", - $prefix, $file[0], - $data{$what}->{line_no}; - } - - my $w =3D $what; - - if ($type ne "File") { - my $cur_part =3D $what; - if ($what =3D~ '/') { - if ($what =3D~ m#^(\/?(?:[\w\-]+\/?){1,2})#) { - $cur_part =3D "Symbols under $1"; - $cur_part =3D~ s,/$,,; - } - } - - if ($cur_part ne "" && $part ne $cur_part) { - $part =3D $cur_part; - my $bar =3D $part; - $bar =3D~ s/./-/g; - print "$part\n$bar\n\n"; - } - - printf ".. _%s:\n\n", $data{$what}->{label}; - - my @names =3D split /\xac/,$w; - my $len =3D 0; - - foreach my $name (@names) { - $name =3D~ s/$symbols/\\$1/g; - $name =3D "**$name**"; - $len =3D length($name) if (length($name) > $len); - } - - print "+-" . "-" x $len . "-+\n"; - foreach my $name (@names) { - printf "| %s", $name . " " x ($len - length($name)) . " |\n"; - print "+-" . "-" x $len . "-+\n"; - } - - print "\n"; - } - - for (my $i =3D 0; $i < scalar(@filepath); $i++) { - my $path =3D $filepath[$i]; - my $f =3D $file[$i]; - - $path =3D~ s,.*/(.*/.*),$1,;; - $path =3D~ s,[/\-],_,g;; - my $fileref =3D "abi_file_".$path; - - if ($type eq "File") { - print ".. _$fileref:\n\n"; - } else { - print "Defined on file :ref:`$f <$fileref>`\n\n"; - } - } - - if ($type eq "File") { - my $bar =3D $w; - $bar =3D~ s/./-/g; - print "$w\n$bar\n\n"; - } - - my $desc =3D ""; - $desc =3D $data{$what}->{description} if (defined($data{$what}->{descrip= tion})); - $desc =3D~ s/\s+$/\n/; - - if (!($desc =3D~ /^\s*$/)) { - if ($description_is_rst) { - # Remove title markups from the description - # Having titles inside ABI files will only work if extra - # care would be taken in order to strictly follow the same - # level order for each markup. - $desc =3D~ s/\n[\-\*\=3D\^\~]+\n/\n\n/g; - - # Enrich text by creating cross-references - - my $new_desc =3D ""; - my $init_indent =3D -1; - my $literal_indent =3D -1; - - open(my $fh, "+<", \$desc); - while (my $d =3D <$fh>) { - my $indent =3D $d =3D~ m/^(\s+)/; - my $spaces =3D length($indent); - $init_indent =3D $indent if ($init_indent < 0); - if ($literal_indent >=3D 0) { - if ($spaces > $literal_indent) { - $new_desc .=3D $d; - next; - } else { - $literal_indent =3D -1; - } - } else { - if ($d =3D~ /()::$/ && !($d =3D~ /^\s*\.\./)) { - $literal_indent =3D $spaces; - } - } - - $d =3D~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g; - - my @matches =3D $d =3D~ m,Documentation/ABI/([\w\/\-]+),g; - foreach my $f (@matches) { - my $xref =3D $f; - my $path =3D $f; - $path =3D~ s,.*/(.*/.*),$1,;; - $path =3D~ s,[/\-],_,g;; - $xref .=3D " "; - $d =3D~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g; - } - - # Seek for cross reference symbols like /sys/... - @matches =3D $d =3D~ m/$xref_match/g; - - foreach my $s (@matches) { - next if (!($s =3D~ m,/,)); - if (defined($data{$s}) && defined($data{$s}->{label})) { - my $xref =3D $s; - - $xref =3D~ s/$symbols/\\$1/g; - $xref =3D ":ref:`$xref <" . $data{$s}->{label} . ">`"; - - $d =3D~ s,$start$s$bondary,$1$xref$2,g; - } - } - $new_desc .=3D $d; - } - close $fh; - - - print "$new_desc\n\n"; - } else { - $desc =3D~ s/^\s+//; - - # Remove title markups from the description, as they won't work - $desc =3D~ s/\n[\-\*\=3D\^\~]+\n/\n\n/g; - - if ($desc =3D~ m/\:\n/ || $desc =3D~ m/\n[\t ]+/ || $desc =3D~ m/[\x0= 0-\x08\x0b-\x1f\x7b-\xff]/) { - # put everything inside a code block - $desc =3D~ s/\n/\n /g; - - print "::\n\n"; - print " $desc\n\n"; - } else { - # Escape any special chars from description - $desc =3D~s/([\x00-\x08\x0b-\x1f\x21-\x2a\x2d\x2f\x3c-\x40\x5c\x5e-\x= 60\x7b-\xff])/\\$1/g; - print "$desc\n\n"; - } - } - } else { - print "DESCRIPTION MISSING for $what\n\n" if (!$data{$what}->{is_file}); - } - - if ($data{$what}->{symbols}) { - printf "Has the following ABI:\n\n"; - - foreach my $content(@{$data{$what}->{symbols}}) { - my $label =3D $data{$symbols{$content}->{xref}}->{label}; - - # Escape special chars from content - $content =3D~s/([\x00-\x1f\x21-\x2f\x3a-\x40\x7b-\xff])/\\$1/g; - - print "- :ref:`$content <$label>`\n\n"; - } - } - - if (defined($data{$what}->{users})) { - my $users =3D $data{$what}->{users}; - - $users =3D~ s/\n/\n\t/g; - printf "Users:\n\t%s\n\n", $users if ($users ne ""); - } - - } -} - -# -# Searches for ABI symbols -# -sub search_symbols { - foreach my $what (sort keys %data) { - next if (!($what =3D~ m/($arg)/)); - - my $type =3D $data{$what}->{type}; - next if ($type eq "File"); - - my $file =3D $data{$what}->{filepath}; - - $what =3D~ s/\xac/, /g; - my $bar =3D $what; - $bar =3D~ s/./-/g; - - print "\n$what\n$bar\n\n"; - - my $kernelversion =3D $data{$what}->{kernelversion} if (defined($data{$w= hat}->{kernelversion})); - my $contact =3D $data{$what}->{contact} if (defined($data{$what}->{conta= ct})); - my $users =3D $data{$what}->{users} if (defined($data{$what}->{users})); - my $date =3D $data{$what}->{date} if (defined($data{$what}->{date})); - my $desc =3D $data{$what}->{description} if (defined($data{$what}->{desc= ription})); - - $kernelversion =3D~ s/^\s+// if ($kernelversion); - $contact =3D~ s/^\s+// if ($contact); - if ($users) { - $users =3D~ s/^\s+//; - $users =3D~ s/\n//g; - } - $date =3D~ s/^\s+// if ($date); - $desc =3D~ s/^\s+// if ($desc); - - printf "Kernel version:\t\t%s\n", $kernelversion if ($kernelversion); - printf "Date:\t\t\t%s\n", $date if ($date); - printf "Contact:\t\t%s\n", $contact if ($contact); - printf "Users:\t\t\t%s\n", $users if ($users); - print "Defined on file(s):\t$file\n\n"; - print "Description:\n\n$desc"; - } -} - -# Exclude /sys/kernel/debug and /sys/kernel/tracing from the search path -sub dont_parse_special_attributes { - if (($File::Find::dir =3D~ m,^/sys/kernel,)) { - return grep {!/(debug|tracing)/ } @_; - } - - if (($File::Find::dir =3D~ m,^/sys/fs,)) { - return grep {!/(pstore|bpf|fuse)/ } @_; - } - - return @_ -} - -my %leaf; -my %aliases; -my @files; -my %root; - -sub graph_add_file { - my $file =3D shift; - my $type =3D shift; - - my $dir =3D $file; - $dir =3D~ s,^(.*/).*,$1,; - $file =3D~ s,.*/,,; - - my $name; - my $file_ref =3D \%root; - foreach my $edge(split "/", $dir) { - $name .=3D "$edge/"; - if (!defined ${$file_ref}{$edge}) { - ${$file_ref}{$edge} =3D { }; - } - $file_ref =3D \%{$$file_ref{$edge}}; - ${$file_ref}{"__name"} =3D [ $name ]; - } - $name .=3D "$file"; - ${$file_ref}{$file} =3D { - "__name" =3D> [ $name ] - }; - - return \%{$$file_ref{$file}}; -} - -sub graph_add_link { - my $file =3D shift; - my $link =3D shift; - - # Traverse graph to find the reference - my $file_ref =3D \%root; - foreach my $edge(split "/", $file) { - $file_ref =3D \%{$$file_ref{$edge}} || die "Missing node!"; - } - - # do a BFS - - my @queue; - my %seen; - my $st; - - push @queue, $file_ref; - $seen{$start}++; - - while (@queue) { - my $v =3D shift @queue; - my @child =3D keys(%{$v}); - - foreach my $c(@child) { - next if $seen{$$v{$c}}; - next if ($c eq "__name"); - - if (!defined($$v{$c}{"__name"})) { - printf STDERR "Error: Couldn't find a non-empty name on a children of = $file/.*: "; - print STDERR Dumper(%{$v}); - exit; - } - - # Add new name - my $name =3D @{$$v{$c}{"__name"}}[0]; - if ($name =3D~ s#^$file/#$link/#) { - push @{$$v{$c}{"__name"}}, $name; - } - # Add child to the queue and mark as seen - push @queue, $$v{$c}; - $seen{$c}++; - } - } -} - -my $escape_symbols =3D qr { ([\x01-\x08\x0e-\x1f\x21-\x29\x2b-\x2d\x3a-\x4= 0\x7b-\xfe]) }x; -sub parse_existing_sysfs { - my $file =3D $File::Find::name; - - my $mode =3D (lstat($file))[2]; - my $abs_file =3D abs_path($file); - - my @tmp; - push @tmp, $file; - push @tmp, $abs_file if ($abs_file ne $file); - - foreach my $f(@tmp) { - # Ignore cgroup, as this is big and has zero docs under ABI - return if ($f =3D~ m#^/sys/fs/cgroup/#); - - # Ignore firmware as it is documented elsewhere - # Either ACPI or under Documentation/devicetree/bindings/ - return if ($f =3D~ m#^/sys/firmware/#); - - # Ignore some sysfs nodes that aren't actually part of ABI - return if ($f =3D~ m#/sections|notes/#); - - # Would need to check at - # Documentation/admin-guide/kernel-parameters.txt, but this - # is not easily parseable. - return if ($f =3D~ m#/parameters/#); - } - - if (S_ISLNK($mode)) { - $aliases{$file} =3D $abs_file; - return; - } - - return if (S_ISDIR($mode)); - - # Trivial: file is defined exactly the same way at ABI What: - return if (defined($data{$file})); - return if (defined($data{$abs_file})); - - push @files, graph_add_file($abs_file, "file"); -} - -sub get_leave($) -{ - my $what =3D shift; - my $leave; - - my $l =3D $what; - my $stop =3D 1; - - $leave =3D $l; - $leave =3D~ s,/$,,; - $leave =3D~ s,.*/,,; - $leave =3D~ s/[\(\)]//g; - - # $leave is used to improve search performance at - # check_undefined_symbols, as the algorithm there can seek - # for a small number of "what". It also allows giving a - # hint about a leave with the same name somewhere else. - # However, there are a few occurences where the leave is - # either a wildcard or a number. Just group such cases - # altogether. - if ($leave =3D~ m/\.\*/ || $leave eq "" || $leave =3D~ /\\d/) { - $leave =3D "others"; - } - - return $leave; -} - -my @not_found; - -sub check_file($$) -{ - my $file_ref =3D shift; - my $names_ref =3D shift; - my @names =3D @{$names_ref}; - my $file =3D $names[0]; - - my $found_string; - - my $leave =3D get_leave($file); - if (!defined($leaf{$leave})) { - $leave =3D "others"; - } - my @expr =3D @{$leaf{$leave}->{expr}}; - die ("\rmissing rules for $leave") if (!defined($leaf{$leave})); - - my $path =3D $file; - $path =3D~ s,(.*/).*,$1,; - - if ($search_string) { - return if (!($file =3D~ m#$search_string#)); - $found_string =3D 1; - } - - for (my $i =3D 0; $i < @names; $i++) { - if ($found_string && $hint) { - if (!$i) { - print STDERR "--> $names[$i]\n"; - } else { - print STDERR " $names[$i]\n"; - } - } - foreach my $re (@expr) { - print STDERR "$names[$i] =3D~ /^$re\$/\n" if ($debug && $dbg_undefined); - if ($names[$i] =3D~ $re) { - return; - } - } - } - - if ($leave ne "others") { - my @expr =3D @{$leaf{"others"}->{expr}}; - for (my $i =3D 0; $i < @names; $i++) { - foreach my $re (@expr) { - print STDERR "$names[$i] =3D~ /^$re\$/\n" if ($debug && $dbg_undefined= ); - if ($names[$i] =3D~ $re) { - return; - } - } - } - } - - push @not_found, $file if (!$search_string || $found_string); - - if ($hint && (!$search_string || $found_string)) { - my $what =3D $leaf{$leave}->{what}; - $what =3D~ s/\xac/\n\t/g; - if ($leave ne "others") { - print STDERR "\r more likely regexes:\n\t$what\n"; - } else { - print STDERR "\r tested regexes:\n\t$what\n"; - } - } -} - -sub check_undefined_symbols { - my $num_files =3D scalar @files; - my $next_i =3D 0; - my $start_time =3D times; - - @files =3D sort @files; - - my $last_time =3D $start_time; - - # When either debug or hint is enabled, there's no sense showing - # progress, as the progress will be overriden. - if ($hint || ($debug && $dbg_undefined)) { - $next_i =3D $num_files; - } - - my $is_console; - $is_console =3D 1 if (-t STDERR); - - for (my $i =3D 0; $i < $num_files; $i++) { - my $file_ref =3D $files[$i]; - my @names =3D @{$$file_ref{"__name"}}; - - check_file($file_ref, \@names); - - my $cur_time =3D times; - - if ($i =3D=3D $next_i || $cur_time > $last_time + 1) { - my $percent =3D $i * 100 / $num_files; - - my $tm =3D $cur_time - $start_time; - my $time =3D sprintf "%d:%02d", int($tm), 60 * ($tm - int($tm)); - - printf STDERR "\33[2K\r", if ($is_console); - printf STDERR "%s: processing sysfs files... %i%%: $names[0]", $time, $= percent; - printf STDERR "\n", if (!$is_console); - STDERR->flush(); - - $next_i =3D int (($percent + 1) * $num_files / 100); - $last_time =3D $cur_time; - } - } - - my $cur_time =3D times; - my $tm =3D $cur_time - $start_time; - my $time =3D sprintf "%d:%02d", int($tm), 60 * ($tm - int($tm)); - - printf STDERR "\33[2K\r", if ($is_console); - printf STDERR "%s: processing sysfs files... done\n", $time; - - foreach my $file (@not_found) { - print "$file not found.\n"; - } -} - -sub undefined_symbols { - print STDERR "Reading $sysfs_prefix directory contents..."; - find({ - wanted =3D>\&parse_existing_sysfs, - preprocess =3D>\&dont_parse_special_attributes, - no_chdir =3D> 1 - }, $sysfs_prefix); - print STDERR "done.\n"; - - $leaf{"others"}->{what} =3D ""; - - print STDERR "Converting ABI What fields into regexes..."; - foreach my $w (sort keys %data) { - foreach my $what (split /\xac/,$w) { - next if (!($what =3D~ m/^$sysfs_prefix/)); - - # Convert what into regular expressions - - # Escape dot characters - $what =3D~ s/\./\xf6/g; - - # Temporarily change [0-9]+ type of patterns - $what =3D~ s/\[0\-9\]\+/\xff/g; - - # Temporarily change [\d+-\d+] type of patterns - $what =3D~ s/\[0\-\d+\]/\xff/g; - $what =3D~ s/\[(\d+)\]/\xf4$1\xf5/g; - - # Temporarily change [0-9] type of patterns - $what =3D~ s/\[(\d)\-(\d)\]/\xf4$1-$2\xf5/g; - - # Handle multiple option patterns - $what =3D~ s/[\{\<\[]([\w_]+)(?:[,|]+([\w_]+)){1,}[\}\>\]]/($1|$2)/g; - - # Handle wildcards - $what =3D~ s,\*,.*,g; - $what =3D~ s,/\xf6..,/.*,g; - $what =3D~ s/\<[^\>]+\>/.*/g; - $what =3D~ s/\{[^\}]+\}/.*/g; - $what =3D~ s/\[[^\]]+\]/.*/g; - - $what =3D~ s/[XYZ]/.*/g; - - # Recover [0-9] type of patterns - $what =3D~ s/\xf4/[/g; - $what =3D~ s/\xf5/]/g; - - # Remove duplicated spaces - $what =3D~ s/\s+/ /g; - - # Special case: this ABI has a parenthesis on it - $what =3D~ s/sqrt\(x^2\+y^2\+z^2\)/sqrt\(x^2\+y^2\+z^2\)/; - - # Special case: drop comparition as in: - # What: foo =3D - # (this happens on a few IIO definitions) - $what =3D~ s,\s*\=3D.*$,,; - - # Escape all other symbols - $what =3D~ s/$escape_symbols/\\$1/g; - $what =3D~ s/\\\\/\\/g; - $what =3D~ s/\\([\[\]\(\)\|])/$1/g; - $what =3D~ s/(\d+)\\(-\d+)/$1$2/g; - - $what =3D~ s/\xff/\\d+/g; - - # Special case: IIO ABI which a parenthesis. - $what =3D~ s/sqrt(.*)/sqrt\(.*\)/; - - # Simplify regexes with multiple .* - $what =3D~ s#(?:\.\*){2,}##g; -# $what =3D~ s#\.\*/\.\*#.*#g; - - # Recover dot characters - $what =3D~ s/\xf6/\./g; - - my $leave =3D get_leave($what); - - my $added =3D 0; - foreach my $l (split /\|/, $leave) { - if (defined($leaf{$l})) { - next if ($leaf{$l}->{what} =3D~ m/\b$what\b/); - $leaf{$l}->{what} .=3D "\xac" . $what; - $added =3D 1; - } else { - $leaf{$l}->{what} =3D $what; - $added =3D 1; - } - } - if ($search_string && $added) { - print STDERR "What: $what\n" if ($what =3D~ m#$search_string#); - } - - } - } - # Compile regexes - foreach my $l (sort keys %leaf) { - my @expr; - foreach my $w(sort split /\xac/, $leaf{$l}->{what}) { - push @expr, qr /^$w$/; - } - $leaf{$l}->{expr} =3D \@expr; - } - - # Take links into account - foreach my $link (sort keys %aliases) { - my $abs_file =3D $aliases{$link}; - graph_add_link($abs_file, $link); - } - print STDERR "done.\n"; - - check_undefined_symbols; -} - -# Ensure that the prefix will always end with a slash -# While this is not needed for find, it makes the patch nicer -# with --enable-lineno -$prefix =3D~ s,/?$,/,; - -if ($cmd eq "undefined" || $cmd eq "search") { - $show_warnings =3D 0; -} -# -# Parses all ABI files located at $prefix dir -# -find({wanted =3D>\&parse_abi, no_chdir =3D> 1}, $prefix); - -print STDERR Data::Dumper->Dump([\%data], [qw(*data)]) if ($debug & $dbg_d= ump_abi_structs); - -# -# Handles the command -# -if ($cmd eq "undefined") { - undefined_symbols; -} elsif ($cmd eq "search") { - search_symbols; -} else { - if ($cmd eq "rest") { - output_rest; - } - - # Warn about duplicated ABI entries - foreach my $what(sort keys %symbols) { - my @files =3D @{$symbols{$what}->{file}}; - - next if (scalar(@files) =3D=3D 1); - - printf STDERR "Warning: $what is defined %d times: @files\n", - scalar(@files); - } -} - -__END__ - -=3Dhead1 NAME - -get_abi.pl - parse the Linux ABI files and produce a ReST book. - -=3Dhead1 SYNOPSIS - -B [--debug ] [--enable-lineno] [--man] [--help] - [--(no-)rst-source] [--dir=3D] [--show-hints] - [--search-string ] - [] - -Where B can be: - -=3Dover 8 - -B I - search for I inside ABI - -B - output the ABI in ReST markup language - -B - validate the ABI contents - -B - existing symbols at the system that aren't - defined at Documentation/ABI - -=3Dback - -=3Dhead1 OPTIONS - -=3Dover 8 - -=3Ditem B<--dir> - -Changes the location of the ABI search. By default, it uses -the Documentation/ABI directory. - -=3Ditem B<--rst-source> and B<--no-rst-source> - -The input file may be using ReST syntax or not. Those two options allow -selecting between a rst-compliant source ABI (B<--rst-source>), or a -plain text that may be violating ReST spec, so it requres some escaping -logic (B<--no-rst-source>). - -=3Ditem B<--enable-lineno> - -Enable output of .. LINENO lines. - -=3Ditem B<--debug> I - -Print debug information according with the level, which is given by the -following bitmask: - - - 1: Debug parsing What entries from ABI files; - - 2: Shows what files are opened from ABI files; - - 4: Dump the structs used to store the contents of the ABI files. - -=3Ditem B<--show-hints> - -Show hints about possible definitions for the missing ABI symbols. -Used only when B. - -=3Ditem B<--search-string> I - -Show only occurences that match a search string. -Used only when B. - -=3Ditem B<--help> - -Prints a brief help message and exits. - -=3Ditem B<--man> - -Prints the manual page and exits. - -=3Dback - -=3Dhead1 DESCRIPTION - -Parse the Linux ABI files from ABI DIR (usually located at Documentation/A= BI), -allowing to search for ABI symbols or to produce a ReST book containing -the Linux ABI documentation. - -=3Dhead1 EXAMPLES - -Search for all stable symbols with the word "usb": - -=3Dover 8 - -$ scripts/get_abi.pl search usb --dir Documentation/ABI/stable - -=3Dback - -Search for all symbols that match the regex expression "usb.*cap": - -=3Dover 8 - -$ scripts/get_abi.pl search usb.*cap - -=3Dback - -Output all obsoleted symbols in ReST format - -=3Dover 8 - -$ scripts/get_abi.pl rest --dir Documentation/ABI/obsolete - -=3Dback - -=3Dhead1 BUGS - -Report bugs to Mauro Carvalho Chehab - -=3Dhead1 COPYRIGHT - -Copyright (c) 2016-2021 by Mauro Carvalho Chehab . - -License GPLv2: GNU GPL version 2 . - -This is free software: you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law. - -=3Dcut --=20 2.48.1