Linux Documentation
 help / color / mirror / Atom feed
* [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes
@ 2026-10-02  4:15 Omokefe Emmanuel Onanaroghene
  2026-10-02  4:28 ` Randy Dunlap
  2026-10-14 17:22 ` Jonathan Corbet
  0 siblings, 2 replies; 5+ messages in thread
From: Omokefe Emmanuel Onanaroghene @ 2026-10-02  4:15 UTC (permalink / raw)
  To: linux-doc, linux-kernel
  Cc: corbet, skhan, rdunlap, mchehab, aleksandr.loktionov, bvanassche,
	emmaonana18, tudor.ambarus

kernel-doc fails to parse functions whose names are wrapped in the
DOMAIN_NS() namespace macro, e.g. in
drivers/iommu/generic_pt/iommu_pt.h:217:

  ... expecting prototype for iova_to_phys(). Prototype was for
  DOMAIN_NS() instead

function_xforms is the designated place for unwrapping function-name
macros, but it has no entry for DOMAIN_NS(), so the macro name is kept
as the prototype and the real name leaks into the parameter list.

Add a transform expanding DOMAIN_NS(op) to op, following the existing
DEFINE_IDTENTRY_IRQ precedent.

Add a regression test for the wrapped iova_to_phys() declaration.

Signed-off-by: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
---
 tools/lib/python/kdoc/xforms_lists.py |  6 ++++++
 tools/unittests/test_kdoc_parser.py   | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/tools/lib/python/kdoc/xforms_lists.py b/tools/lib/python/kdoc/xforms_lists.py
index e3dda2fe8a53..5e8bd9117895 100644
--- a/tools/lib/python/kdoc/xforms_lists.py
+++ b/tools/lib/python/kdoc/xforms_lists.py
@@ -91,6 +91,12 @@ class CTransforms:
         (CMatch("__diagnose_as"), ""),
         (CMatch("DECL_BUCKET_PARAMS"), r"\1, \2"),
         (CMatch("DEFINE_IDTENTRY_IRQ"), r"static void \1(struct pt_regs *regs, u32 vector)"),
+        #
+        # DOMAIN_NS() wraps a function name with a namespace prefix
+        # (see drivers/iommu/generic_pt/iommu_pt.h). Unwrap it so the
+        # real function name is parsed.
+        #
+        (CMatch("DOMAIN_NS"), r"\1"),
         (CMatch("__cond_acquires"), ""),
         (CMatch("__cond_releases"), ""),
         (CMatch("__acquires"), ""),
diff --git a/tools/unittests/test_kdoc_parser.py b/tools/unittests/test_kdoc_parser.py
index c4a76ed13dbc..4b47a858824a 100755
--- a/tools/unittests/test_kdoc_parser.py
+++ b/tools/unittests/test_kdoc_parser.py
@@ -418,6 +418,28 @@ class TestSelfValidate(GenerateKdocItem):
         """
         self.run_test(self.SOURCE, [self.DEFAULT.copy()], self.EXPORTS)
 
+class TestDomainNs(GenerateKdocItem):
+    def test_domain_ns_wrapped_function(self):
+        source = """
+            /**
+             * iova_to_phys() - Return the output address for the given IOVA
+             * @domain: Table to query
+             * @iova: IO virtual address to query
+             */
+            phys_addr_t DOMAIN_NS(iova_to_phys)(struct iommu_domain *domain,
+                                                dma_addr_t iova);
+        """
+
+        kernel_doc = KernelDoc(self.config, "test.c", self.xforms)
+        patcher = patch('builtins.open', new_callable=mock_open,
+                        read_data=dedent(source))
+        with patcher:
+            _, entries = kernel_doc.parse_kdoc()
+
+        self.assertEqual(len(entries), 1)
+        self.assertEqual(entries[0].name, "iova_to_phys")
+        self.assertEqual(entries[0].warnings, [])
+
 #
 # Class and logic to create dynamic tests from YAML
 #
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes
  2026-10-02  4:15 [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes Omokefe Emmanuel Onanaroghene
@ 2026-10-02  4:28 ` Randy Dunlap
  2026-10-14 17:22 ` Jonathan Corbet
  1 sibling, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2026-10-02  4:28 UTC (permalink / raw)
  To: Omokefe Emmanuel Onanaroghene, linux-doc, linux-kernel
  Cc: corbet, skhan, mchehab, aleksandr.loktionov, bvanassche,
	tudor.ambarus



On 10/1/26 9:15 PM, Omokefe Emmanuel Onanaroghene wrote:
> kernel-doc fails to parse functions whose names are wrapped in the
> DOMAIN_NS() namespace macro, e.g. in
> drivers/iommu/generic_pt/iommu_pt.h:217:
> 
>   ... expecting prototype for iova_to_phys(). Prototype was for
>   DOMAIN_NS() instead
> 
> function_xforms is the designated place for unwrapping function-name
> macros, but it has no entry for DOMAIN_NS(), so the macro name is kept
> as the prototype and the real name leaks into the parameter list.
> 
> Add a transform expanding DOMAIN_NS(op) to op, following the existing
> DEFINE_IDTENTRY_IRQ precedent.
> 
> Add a regression test for the wrapped iova_to_phys() declaration.
> 
> Signed-off-by: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>

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

Thanks.

> ---
>  tools/lib/python/kdoc/xforms_lists.py |  6 ++++++
>  tools/unittests/test_kdoc_parser.py   | 22 ++++++++++++++++++++++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/tools/lib/python/kdoc/xforms_lists.py b/tools/lib/python/kdoc/xforms_lists.py
> index e3dda2fe8a53..5e8bd9117895 100644
> --- a/tools/lib/python/kdoc/xforms_lists.py
> +++ b/tools/lib/python/kdoc/xforms_lists.py
> @@ -91,6 +91,12 @@ class CTransforms:
>          (CMatch("__diagnose_as"), ""),
>          (CMatch("DECL_BUCKET_PARAMS"), r"\1, \2"),
>          (CMatch("DEFINE_IDTENTRY_IRQ"), r"static void \1(struct pt_regs *regs, u32 vector)"),
> +        #
> +        # DOMAIN_NS() wraps a function name with a namespace prefix
> +        # (see drivers/iommu/generic_pt/iommu_pt.h). Unwrap it so the
> +        # real function name is parsed.
> +        #
> +        (CMatch("DOMAIN_NS"), r"\1"),
>          (CMatch("__cond_acquires"), ""),
>          (CMatch("__cond_releases"), ""),
>          (CMatch("__acquires"), ""),
> diff --git a/tools/unittests/test_kdoc_parser.py b/tools/unittests/test_kdoc_parser.py
> index c4a76ed13dbc..4b47a858824a 100755
> --- a/tools/unittests/test_kdoc_parser.py
> +++ b/tools/unittests/test_kdoc_parser.py
> @@ -418,6 +418,28 @@ class TestSelfValidate(GenerateKdocItem):
>          """
>          self.run_test(self.SOURCE, [self.DEFAULT.copy()], self.EXPORTS)
>  
> +class TestDomainNs(GenerateKdocItem):
> +    def test_domain_ns_wrapped_function(self):
> +        source = """
> +            /**
> +             * iova_to_phys() - Return the output address for the given IOVA
> +             * @domain: Table to query
> +             * @iova: IO virtual address to query
> +             */
> +            phys_addr_t DOMAIN_NS(iova_to_phys)(struct iommu_domain *domain,
> +                                                dma_addr_t iova);
> +        """
> +
> +        kernel_doc = KernelDoc(self.config, "test.c", self.xforms)
> +        patcher = patch('builtins.open', new_callable=mock_open,
> +                        read_data=dedent(source))
> +        with patcher:
> +            _, entries = kernel_doc.parse_kdoc()
> +
> +        self.assertEqual(len(entries), 1)
> +        self.assertEqual(entries[0].name, "iova_to_phys")
> +        self.assertEqual(entries[0].warnings, [])
> +
>  #
>  # Class and logic to create dynamic tests from YAML
>  #

-- 
~Randy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes
  2026-10-02  4:15 [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes Omokefe Emmanuel Onanaroghene
  2026-10-02  4:28 ` Randy Dunlap
@ 2026-10-14 17:22 ` Jonathan Corbet
  2026-10-14 22:47   ` Omokefe Emmanuel Onanaroghene
  1 sibling, 1 reply; 5+ messages in thread
From: Jonathan Corbet @ 2026-10-14 17:22 UTC (permalink / raw)
  To: Omokefe Emmanuel Onanaroghene, linux-doc, linux-kernel
  Cc: skhan, rdunlap, mchehab, aleksandr.loktionov, bvanassche,
	emmaonana18, tudor.ambarus

Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com> writes:

> kernel-doc fails to parse functions whose names are wrapped in the
> DOMAIN_NS() namespace macro, e.g. in
> drivers/iommu/generic_pt/iommu_pt.h:217:
>
>   ... expecting prototype for iova_to_phys(). Prototype was for
>   DOMAIN_NS() instead
>
> function_xforms is the designated place for unwrapping function-name
> macros, but it has no entry for DOMAIN_NS(), so the macro name is kept
> as the prototype and the real name leaks into the parameter list.
>
> Add a transform expanding DOMAIN_NS(op) to op, following the existing
> DEFINE_IDTENTRY_IRQ precedent.
>
> Add a regression test for the wrapped iova_to_phys() declaration.
>
> Signed-off-by: Omokefe Emmanuel Onanaroghene <emmaonana18@gmail.com>
> ---
>  tools/lib/python/kdoc/xforms_lists.py |  6 ++++++
>  tools/unittests/test_kdoc_parser.py   | 22 ++++++++++++++++++++++
>  2 files changed, 28 insertions(+)

Neither of these patches applies to docs-next...what did you base them
on?

jon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes
  2026-10-14 17:22 ` Jonathan Corbet
@ 2026-10-14 22:47   ` Omokefe Emmanuel Onanaroghene
  2026-10-15  0:53     ` Omokefe Emmanuel Onanaroghene
  0 siblings, 1 reply; 5+ messages in thread
From: Omokefe Emmanuel Onanaroghene @ 2026-10-14 22:47 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: linux-doc, linux-kernel, skhan, rdunlap, mchehab,
	aleksandr.loktionov, bvanassche, tudor.ambarus, emmaonana18

On Wed, 14 Oct 2026 11:22:02 -0600, Jonathan Corbet <corbet@lwn.net> wrote:
> Neither of these patches applies to docs-next...what did you base them
> on?

Hi Jon,

I had based both patches on mainline rather than docs-next. I have
rebased both patches on top of docs-next and sent a v2 for both:

- https://lore.kernel.org/all/20261014223134.14772-1-emmaonana18@gmail.com/
- https://lore.kernel.org/all/20261014223437.16164-1-emmaonana18@gmail.com/

Apologies for the inconvenience.

Thanks,
Omokefe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes
  2026-10-14 22:47   ` Omokefe Emmanuel Onanaroghene
@ 2026-10-15  0:53     ` Omokefe Emmanuel Onanaroghene
  0 siblings, 0 replies; 5+ messages in thread
From: Omokefe Emmanuel Onanaroghene @ 2026-10-15  0:53 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: linux-doc, linux-kernel, skhan, rdunlap, mchehab,
	aleksandr.loktionov, bvanassche, tudor.ambarus, emmaonana18

On Wed, 14 Oct 2026 11:22:02 -0600, Jonathan Corbet <corbet@lwn.net> wrote:
>> Neither of these patches applies to docs-next...what did you base them
>> on?
>
> Hi Jon,
>
> I had mistakenly based both patches on mainline rather than docs-next.
> I have rebased both on top of docs-next and sent a v2 for each:
>
> - docs: kdoc: handle TRACE_EVENT_FN() family in tracepoint parser:
>   https://lore.kernel.org/all/20261014223134.14772-1-emmaonana18@gmail.com/
>
> - docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes:
>   https://lore.kernel.org/all/20261014223437.16164-1-emmaonana18@gmail.com/
>

I just noticed another mistake on my part, because I prepared
the two v2 patches on separate independent branches off docs-next, both
patches add their regression test at the exact same location in
tools/unittests/test_kdoc_parser.py (line 444). Applying them sequentially will
cause a merge conflict

I didn't realize that patches modifying the exact same context in a file
should be stacked sequentially on a single branch as a patch series
rather than developed on separate branches.

Should I respin them as a 2-patch series against docs-next,
or would you prefer to resolve when applying?

Thanks,
Omokefe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-15  0:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02  4:15 [PATCH] docs: kdoc: strip DOMAIN_NS() wrapper in function prototypes Omokefe Emmanuel Onanaroghene
2026-10-02  4:28 ` Randy Dunlap
2026-10-14 17:22 ` Jonathan Corbet
2026-10-14 22:47   ` Omokefe Emmanuel Onanaroghene
2026-10-15  0:53     ` Omokefe Emmanuel Onanaroghene

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox