Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1078567pxb; Thu, 4 Mar 2021 02:41:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjax2gpfJioAI/snx+j1rE/iyLCYY2Ra9UJgk+2DBdj2ax8/XF6NXbUeOl7TCqqL9ivETb X-Received: by 2002:a05:6402:1517:: with SMTP id f23mr3680056edw.272.1614854477668; Thu, 04 Mar 2021 02:41:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614854477; cv=none; d=google.com; s=arc-20160816; b=C2KZzINHto8anDiRCguWiwspNEOnUAEZV2s9qr/XrkucgJBhf/BsQGNCCrUPa+KF7b /M+iPfdPJmhCdlqD8Q3gC2xtOKw1o8imS8PpZHhXdWLMrehsb/6y/tm2gNobkVBKloPR +cXBbO5Y7uuDc4P2ixOpqwOyRMJ/icZ8VBhgnMcb+O0BdqLX1eAWrkgFUnQGF7eGmUqQ FMOmdPQxj6YVKa3QxxovIVh+S46oiO9652koFCp79MSpRIjumT0vdcWEKaNfB4oGbIDp l4IR71PQPTRTTzpp62Zv5sIl0sb//+M2YioNyHyHthuGpeAp1a79npHr+bBRrRUq2jsl O8aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6tDOKFNHOSkphpFagdTfhqlN4RQfvCC9TPFhxYSHQ/A=; b=EQ7y4spATqXYleL3eJjeOMy/tQkMRy0OetrffJ7SErQQOZl+18Qx47+Ro0KaPffTTh 75KARTC+8+9b8YV/XVSDEAwmuuz7baBVyaVRHMWxqf+EM+R4hNogsu6PgnXcwvl1SAPI NsmKF/GpQLcqkCBAiOhcSYJsERloxb/Wc6St6a9sEml3u5ym/mtaHyAqas7E2hmc3DaP duykylO7H6EZl/tkoFYxxEKR4e9mHHNLotAnS6vJSvL1kBF/9VaajSz+IsIap4Iao8+A FS6Ka8djknmN7RdStmKxfAYI3t5GPKfpLd1s+73sVuWb217C1HGXti2NN/KEIGjOSZPr 0X4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si15868676edv.547.2021.03.04.02.40.55; Thu, 04 Mar 2021 02:41:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385502AbhCCRUA (ORCPT + 99 others); Wed, 3 Mar 2021 12:20:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383008AbhCCNjf (ORCPT ); Wed, 3 Mar 2021 08:39:35 -0500 Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658CDC061222 for ; Wed, 3 Mar 2021 05:38:50 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed20:cd47:42a6:c822:e50b]) by andre.telenet-ops.be with bizsmtp id bpen2400W4huzR801penop; Wed, 03 Mar 2021 14:38:48 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lHRiB-004Q0m-I5; Wed, 03 Mar 2021 14:38:47 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1lHRiA-00GWpg-Ui; Wed, 03 Mar 2021 14:38:46 +0100 From: Geert Uytterhoeven To: Jonathan Corbet , Greg Kroah-Hartman , "Rafael J . Wysocki" Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/2] docs: driver-model: device: Add ATTRIBUTE_GROUPS() example Date: Wed, 3 Mar 2021 14:38:45 +0100 Message-Id: <20210303133845.3939403-3-geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210303133845.3939403-1-geert+renesas@glider.be> References: <20210303133845.3939403-1-geert+renesas@glider.be> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a paragraph about the ATTRIBUTE_GROUPS() helper macro, and use it in the example. Retain the old description, as it is still useful in case of multiple groups. Change the names of the group(s) structures, to match the ATTRIBUTE_GROUPS() macro. Signed-off-by: Geert Uytterhoeven --- Documentation/driver-api/driver-model/device.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/driver-api/driver-model/device.rst b/Documentation/driver-api/driver-model/device.rst index 41c819fafd9c1aee..0833be568b06cace 100644 --- a/Documentation/driver-api/driver-model/device.rst +++ b/Documentation/driver-api/driver-model/device.rst @@ -82,19 +82,24 @@ organized as follows into a group:: NULL, }; - static struct attribute_group dev_attr_group = { + static struct attribute_group dev_group = { .attrs = dev_attrs, }; - static const struct attribute_group *dev_attr_groups[] = { - &dev_attr_group, + static const struct attribute_group *dev_groups[] = { + &dev_group, NULL, }; +A helper macro is available for the common case of a single group, so the +above two structures can be declared using::: + + ATTRIBUTE_GROUPS(dev); + This array of groups can then be associated with a device by setting the group pointer in struct device before device_register() is invoked:: - dev->groups = dev_attr_groups; + dev->groups = dev_groups; device_register(dev); The device_register() function will use the 'groups' pointer to create the -- 2.25.1