From patchwork Sun Jan 7 01:24:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randy Dunlap X-Patchwork-Id: 185705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp350421dyq; Sat, 6 Jan 2024 17:24:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKeq3Us8C3iJBfJVr8OvBR7aGoGAtg/ritTqX8nNYCaBvU2ZQN0tVgaY+IBlXbnriU+aNW X-Received: by 2002:a05:6e02:1a8d:b0:35e:6ef0:6b04 with SMTP id k13-20020a056e021a8d00b0035e6ef06b04mr2908550ilv.68.1704590659107; Sat, 06 Jan 2024 17:24:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704590659; cv=none; d=google.com; s=arc-20160816; b=K4S0h5yo920YKQpUeVG1wI28sZ950xuhXV1AyWdjb3/1BQPgwh2oJM2mQg1pCoEC/Z tWgPUHskyf2/yVU4v9DeiWlZ38rec+3+5xub2vs6m7icjXKgt/XEuxZ4Z6XM3wKTdz7S McYw53kHUl5lSVKF0G0KYD+LTrk1GUF5b1qmGdr88pSlTgFsSF2c4KfsN629H3IbfH/E w5c3kqU921JnnpUF30GBBQYgPQO7uMRvAd1xVQ4ilD8IaaXZQI1uVuAaoA2CIezsmKo7 j3yPkLrjMvY9k5C7PFNjXFMkyUL2/YBa6XW4AKBSu7uDmOMf5MGzvlbYO6ku8SkmRjqW 6jNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=dCyDGSEioYdeunZdzZB63ylJy1g1gtQtPEDXYg17y5k=; fh=Gt5JS598BYSpTXO95MfIQFb7GsHjBSuareMMdhO+8I8=; b=GbF707QlVribpamyD6Oua8Cy9z04IAJluTefyuNSTQGpKh2iL3QPYAUXuL+GlR57cJ xstCrQUpbzsJN61GNpnkqSTzFpbi7tuHFZxTKY5oknQdd4KjSxpHVkEOMsYNqhnAPRUt 6xkrY8v1yAVNZrv6Sg8VfOAShoondVjOWoUAa/KChOQtN4aJS6wqoiaI6/4+KyB1e0bi tm8+MxsnSZiI9tD948YODHgTmxwZIhlgznustyIrQyhsIP1jxj54aMZdP5FG/y/wSaTF 0VYwCxg1/5iEkFuwN0XdUvMWPkhCN3oNeu89se/nOTVaolt+CNrGabOW8EbNvLEFQwN7 EPCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="yGrCQ/6Y"; spf=pass (google.com: domain of linux-kernel+bounces-18755-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18755-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l18-20020a170903245200b001d4725c1109si3865334pls.379.2024.01.06.17.24.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 17:24:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18755-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="yGrCQ/6Y"; spf=pass (google.com: domain of linux-kernel+bounces-18755-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18755-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D3118282AF9 for ; Sun, 7 Jan 2024 01:24:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 702E11FDF; Sun, 7 Jan 2024 01:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="yGrCQ/6Y" X-Original-To: linux-kernel@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A0757137F; Sun, 7 Jan 2024 01:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=dCyDGSEioYdeunZdzZB63ylJy1g1gtQtPEDXYg17y5k=; b=yGrCQ/6YuI72KR9g8WruJKwNfU nZphzMlcefoLZ3wj56NJM+8tbynOoIvZC+vyyVrNVI5XfYznrZ5YQOtWV7BLhPlbTemIRquQtEpui 251EeFXwCTVZ7VTrLknyY6+IadTA8Z28oZHlGiCQ2jz/WN6Zg4VhV7eqr4971ENWWUNztCPz1LxFN F/kPsjl+ma0mb4qmPC14huP1wN3AlnwU1eWrvTmyjoccVjd7TWDHb7ShFfwVnZHvu2M24yX/YJYqD QErk65d2EiXG6MjdFuXi88EMYLPT36oFXmGC0428FIgwFlae27VFQhboPRden9ttXgW1j5oP83VrG DCxux4GA==; Received: from [50.53.46.231] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rMHtQ-002A6e-2r; Sun, 07 Jan 2024 01:24:00 +0000 From: Randy Dunlap To: linux-kernel@vger.kernel.org Cc: Randy Dunlap , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH v2] doc-guide: kernel-doc: tell about object-like macros Date: Sat, 6 Jan 2024 17:24:00 -0800 Message-ID: <20240107012400.32587-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787315951649487320 X-GMAIL-MSGID: 1787392855298312237 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: cbb4d3e6510b ("scripts/kernel-doc: handle object-like macros") Signed-off-by: Randy Dunlap Cc: Jonathan Corbet Cc: linux-doc@vger.kernel.org Acked-by: Daniel Vetter --- v2: Previous attempts to use kernel-doc were for data definitions, not macros, so remove that comment. Remove a duplicate word in the patch description. Add examples. Documentation/doc-guide/kernel-doc.rst | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff -- a/Documentation/doc-guide/kernel-doc.rst b/Documentation/doc-guide/kernel-doc.rst --- a/Documentation/doc-guide/kernel-doc.rst +++ b/Documentation/doc-guide/kernel-doc.rst @@ -341,6 +341,51 @@ Typedefs with function prototypes can al */ typedef void (*type_name)(struct v4l2_ctrl *arg1, void *arg2); +Object-like macro documentation +------------------------------- + +Object-like macros are distinct from function-like macros. They are +differentiated by whether the macro name is immediately followed by a +left parenthesis ('(') for function-like macros or not followed by one +for object-like macros. + +Function-like macros are handled like functions by ``scripts/kernel-doc``. +They may have a parameter list. Object-like macros have do not have a +parameter list. + +The general format of an object-like macro kernel-doc comment is:: + + /** + * define object_name - Brief description. + * + * Description of the object. + */ + +Example:: + + /** + * define MAX_ERRNO - maximum errno value that is supported + * + * Kernel pointers have redundant information, so we can use a + * scheme where we can return either an error code or a normal + * pointer with the same return value. + */ + #define MAX_ERRNO 4095 + +Example:: + + /** + * define DRM_GEM_VRAM_PLANE_HELPER_FUNCS - \ + * Initializes struct drm_plane_helper_funcs for VRAM handling + * + * This macro initializes struct drm_plane_helper_funcs to use the + * respective helper functions. + */ + #define DRM_GEM_VRAM_PLANE_HELPER_FUNCS \ + .prepare_fb = drm_gem_vram_plane_helper_prepare_fb, \ + .cleanup_fb = drm_gem_vram_plane_helper_cleanup_fb + + Highlights and cross-references -------------------------------