Skip to content

Commit 91a3d6b

Browse files
rddunlapJonathan Corbet
authored andcommitted
doc-guide: kernel-doc: tell about object-like macros
Since 2014 kernel-doc has supported describing object-like macros but it is not documented anywhere. I should have required some documentation for it when I merged the patch. :( There are currently only 3 uses of this (all in DRM headers, in include/drm/*.h). Add object-like macro kernel-doc documentation now so that more may know about it and use it. Fixes: cbb4d3e ("scripts/kernel-doc: handle object-like macros") Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: linux-doc@vger.kernel.org Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/20240107012400.32587-1-rdunlap@infradead.org
1 parent d2a70e2 commit 91a3d6b

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Documentation/doc-guide/kernel-doc.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,51 @@ Typedefs with function prototypes can also be documented::
341341
*/
342342
typedef void (*type_name)(struct v4l2_ctrl *arg1, void *arg2);
343343

344+
Object-like macro documentation
345+
-------------------------------
346+
347+
Object-like macros are distinct from function-like macros. They are
348+
differentiated by whether the macro name is immediately followed by a
349+
left parenthesis ('(') for function-like macros or not followed by one
350+
for object-like macros.
351+
352+
Function-like macros are handled like functions by ``scripts/kernel-doc``.
353+
They may have a parameter list. Object-like macros have do not have a
354+
parameter list.
355+
356+
The general format of an object-like macro kernel-doc comment is::
357+
358+
/**
359+
* define object_name - Brief description.
360+
*
361+
* Description of the object.
362+
*/
363+
364+
Example::
365+
366+
/**
367+
* define MAX_ERRNO - maximum errno value that is supported
368+
*
369+
* Kernel pointers have redundant information, so we can use a
370+
* scheme where we can return either an error code or a normal
371+
* pointer with the same return value.
372+
*/
373+
#define MAX_ERRNO 4095
374+
375+
Example::
376+
377+
/**
378+
* define DRM_GEM_VRAM_PLANE_HELPER_FUNCS - \
379+
* Initializes struct drm_plane_helper_funcs for VRAM handling
380+
*
381+
* This macro initializes struct drm_plane_helper_funcs to use the
382+
* respective helper functions.
383+
*/
384+
#define DRM_GEM_VRAM_PLANE_HELPER_FUNCS \
385+
.prepare_fb = drm_gem_vram_plane_helper_prepare_fb, \
386+
.cleanup_fb = drm_gem_vram_plane_helper_cleanup_fb
387+
388+
344389
Highlights and cross-references
345390
-------------------------------
346391

0 commit comments

Comments
 (0)