Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1079730pxb; Thu, 4 Mar 2021 02:43:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoSjaMagUJO6oh44jxfArz5gXyD9LixTiPEwk11v3eT5neaKO31To+2eAUhkqcnZROzebc X-Received: by 2002:a17:906:3917:: with SMTP id f23mr3577573eje.186.1614854595840; Thu, 04 Mar 2021 02:43:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614854595; cv=none; d=google.com; s=arc-20160816; b=KPLA3WZX2/UMQdpz2PIazQC0mAVlN4N6jm2O9+H/Nz3xhVqNOdGY8WPN/u7MaUKARM ILJkFTkaqDD/w3mkMh7PURfuA/sKITuOop1yJnTEh/EHMqO7GS89DtKVnM/8DXD8/QOh aF0L2ICrD/PV75EzZSDBR9mgETWY/7JXM3w+sggbwUST0vUtEZrSK3S1kCUejk914ttl XmkR8W6o7dn/o5btNuI3epzvlTWgZOWvQHSap5sxfPEyC9DBqYxfMoz4tuBKl5Ud0W06 O0S3A+pBocOnqQupRaX9kAaYjq+qUDgBHaFAWgRR0ZBzOatWVcfvVvm6lEALMapgGC/M Sr6A== 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=SDj6KB8QsGJ1otfDtk3E9E9YHh9KNc89UgQAeNpa458=; b=Atg1PALCZAGfUdzrR+VTZR3rKmHRGBw70VsIrWxOBkr4Q7JdvA+Em1tSdIImRsSCIk cNG6rY8GINSHHLfO67TOnfhRodxvYT8BhnY8Y2SnGKkXIL/ABmkL2l7Sr74ikDWCmiKF JkghgmaHwYXg1qo227bgphCDGqhldgn71s8JflLajoQ4isv9z2PIRjCdZfgI9hXbHTwt 7uHe45S2oVy8efyeGTMJl5xqwB5Vs6RDUDtnBpdjcvfKjTbY9dTMUUzqtlGl/PqjuThx oDJfU1VN6fraC1qOPP4paCy8MKGiuTFT+0kF+NJkV7Vv6O5ZXqx+O6Wm8eX8Pg1soshV niFg== 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 24si741961edv.533.2021.03.04.02.42.53; Thu, 04 Mar 2021 02:43:15 -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 S1385510AbhCCRUG (ORCPT + 99 others); Wed, 3 Mar 2021 12:20:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383004AbhCCNjf (ORCPT ); Wed, 3 Mar 2021 08:39:35 -0500 Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6146AC0617A9 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 baptiste.telenet-ops.be with bizsmtp id bpeo240064huzR801peouU; 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-004Q0l-Ky; Wed, 03 Mar 2021 14:38:47 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1lHRiA-00GWpc-U6; 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 1/2] docs: driver-model: device: Add DEVICE_ATTR_{RO,RW} examples Date: Wed, 3 Mar 2021 14:38:44 +0100 Message-Id: <20210303133845.3939403-2-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 bus.rst, driver.rst, and hwmon-kernel-api.rst refer to the DEVICE_ATTR_* macros for devices, but device.rst does not mention them. Add a paragraph about these helper macros, and use them in the examples. Retain the old description, as it is still useful for less common values of mode. Change the names of the example "show" and "store" methods, to match the expectations of the DEVICE_ATTR_* macros. Signed-off-by: Geert Uytterhoeven --- Documentation/driver-api/driver-model/device.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/driver-api/driver-model/device.rst b/Documentation/driver-api/driver-model/device.rst index b9b022371e856e83..41c819fafd9c1aee 100644 --- a/Documentation/driver-api/driver-model/device.rst +++ b/Documentation/driver-api/driver-model/device.rst @@ -63,8 +63,14 @@ Attributes are declared using a macro called DEVICE_ATTR:: Example::: - static DEVICE_ATTR(type, 0444, show_type, NULL); - static DEVICE_ATTR(power, 0644, show_power, store_power); + static DEVICE_ATTR(type, 0444, type_show, NULL); + static DEVICE_ATTR(power, 0644, power_show, power_store); + +Helper macros are available for common values of mode, so the above examples +can be simplified to::: + + static DEVICE_ATTR_RO(type); + static DEVICE_ATTR_RW(power); This declares two structures of type struct device_attribute with respective names 'dev_attr_type' and 'dev_attr_power'. These two attributes can be -- 2.25.1