Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp430958rdb; Sat, 30 Sep 2023 09:54:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF21sGJfJwjrkRpiv33T1CQ7RKLhAFnsCtEKTiWlpGp9p5nW5X8gIh/hWy7WpfgWWpEo7hI X-Received: by 2002:a05:6a20:7349:b0:14d:e615:277c with SMTP id v9-20020a056a20734900b0014de615277cmr11020389pzc.11.1696092863639; Sat, 30 Sep 2023 09:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696092863; cv=none; d=google.com; s=arc-20160816; b=AktTCk2YqzewceHTiiSBMFPaVpFjUBCBfQMAWtSTKehCumm281C+IjdIA5iIsG5CLw UZxVrlk46o0GMi27VRSTamjNM0GYNvpoXOVI/QSXM6CenP/r9wyby1lJJavB4PMb7xAx Pu/R+llKnVUnr22CSBOZZ3x74kTfIWK+tj8lAwVWOoZFzysCbsu2uJUL6DO8b2Pu8pRv QtluKjU84Y7w/XJaaRRlmnmi/kFNn13TpZq4UBNyJoZD8LGoPk/YF7kjmYjMLBCiCLH5 EghXdBwIcxZh+B+W5cZLyG2VRJtKJqUpH6x9GiyShmS4I8FpySO/BYoIt6S2I/JJbUUY t/iA== 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:subject:cc:to:from:date :dkim-signature; bh=Pml+pB3qLL3nGLDrWR4uomu55L9WkwDvP+TBdsbDkHQ=; fh=t8LfS8hR9E0OwMR1w8uvnw3oI88ezO6P7Szil1UCEkw=; b=zFlHHfofWm0xA00TLkfp/5xjs1ROGM26FYgV3q5Y800IIsAC+iGJUQSR1epSKqOk+c yunYTWFkWelS0fTDN1vzDk4uYpglgwS9JMibJ2d1K9b0h/kKdVSW04mdJPoH9zTKHd6v +Kg6KUBvh3dQ92GZNwyM1QV58VAdjqv74PUwIE+i1imAE26a3hWsnKqrBOaQ1deZIgF0 WlL0YECdidETStyCQJpH8UsMJ5TSbuvuzdFXgVyvG6HBVc7UMuWHIxue934mZ22ogdHH bje9ZNJpeMEjYnmooGqaurRJEiYIpCNuuMpPu7cxMgW345P9Xvl8sR72yMKIatbgJ2ed rr4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kBH/u9Qr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00578b9fb24f1si5239165pgb.634.2023.09.30.09.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 09:54:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kBH/u9Qr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6270281A5AD6; Sat, 30 Sep 2023 09:54:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234576AbjI3QyJ (ORCPT + 99 others); Sat, 30 Sep 2023 12:54:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234461AbjI3QyI (ORCPT ); Sat, 30 Sep 2023 12:54:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3CC2DA; Sat, 30 Sep 2023 09:54:06 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 128B0C433C8; Sat, 30 Sep 2023 16:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696092846; bh=3FWZ2qW2Ezn08XF7jE/SiC+XcEI8boNjlLaX2s5XXj0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kBH/u9QrsdIL0Bc2HrdOfgtLT/lqXpGNTnTlP69fi8Ump94+jFCr03KYTSTcgwWqz D7aqfgDQ5XlSm9YyBQO2awR/goy7ZwHYh4JZRnmADYJo1L6yICx1oPxsnBpn8w3J5O ULJSYJQ3nAEHb8UklF1lAGbT+3l28/JWZwx2gcbUXX4RqPZ6Cx8MeoKo4Ra7aEjYy8 jChr7f1OByeRMIhuUiLftT2zRpa8m5IvY+x2/ncjIwT/q8ESLOLQlJCLKq9oILfSCc JP45pFa7h62dXuBF/uK2KGjFk/XdmAYdvoMTwagoHsaxuvQU7f+YgS9Z/6OuEqTYy4 mzqktP+JjH8Qw== Date: Sat, 30 Sep 2023 17:54:04 +0100 From: Jonathan Cameron To: Matti Vaittinen Cc: Matti Vaittinen , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Shevchenko , Angel Iglesias , Andreas Klinger , Benjamin Bara , Christophe JAILLET , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/5] iio: improve doc for available_scan_mask Message-ID: <20230930175404.033da19e@jic23-huawei> In-Reply-To: <4e43bf0186df5c8a56b470318b4827605f9cad6c.1695727471.git.mazziesaccount@gmail.com> References: <4e43bf0186df5c8a56b470318b4827605f9cad6c.1695727471.git.mazziesaccount@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 30 Sep 2023 09:54:21 -0700 (PDT) On Wed, 27 Sep 2023 11:27:41 +0300 Matti Vaittinen wrote: > The available_scan_mask is an array of bitmaps representing the channels > which can be simultaneously enabled by the driver. In many cases, the > hardware can offer more channels than what the user is interested in > obtaining. In such cases, it may be preferred that only a subset of > channels are enabled, and the driver reads only a subset of the channels > from the hardware. > > Some devices can't support all channel combinations. For example, the > BM1390 pressure sensor must always read the pressure data in order to > acknowledge the watermark IRQ, while reading temperature can be omitted. > So, the available scan masks would be 'pressure and temperature' and > 'pressure only'. > > When IIO searches for the scan mask it asks the driver to use, it will > pick the first suitable one from the 'available_scan_mask' array. Hence, > ordering the masks in the array makes a difference. We should 'prefer' > reading just the pressure from the hardware (as it is a cheaper operation > than reading both pressure and temperature) over reading both pressure > and temperature. Hence, we should set the 'only pressure' as the first > scan mask in available_scan_mask array. If we set the 'pressure and > temperature' as first in the array, then the 'only temperature' will never > get used as 'pressure and temperature' can always serve the user's > needs. > > Add (minimal) kerneldoc to the 'available_scan_mask' to hint the user > that the ordering of masks matters. > > Signed-off-by: Matti Vaittinen Applied this patch to the togreg branch of iio.git If you fancy turning the patch description into some more formal documentation under Documentation/... that might be a good thing in the long run. I always mean to spend some time working on that, but too manyt things to do :( Thanks, Jonathan > --- > include/linux/iio/iio.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h > index 202e55b0a28b..7bfa1b9bc8a2 100644 > --- a/include/linux/iio/iio.h > +++ b/include/linux/iio/iio.h > @@ -556,7 +556,9 @@ struct iio_buffer_setup_ops { > * and owner > * @buffer: [DRIVER] any buffer present > * @scan_bytes: [INTERN] num bytes captured to be fed to buffer demux > - * @available_scan_masks: [DRIVER] optional array of allowed bitmasks > + * @available_scan_masks: [DRIVER] optional array of allowed bitmasks. Sort the > + * array in order of preference, the most preferred > + * masks first. > * @masklength: [INTERN] the length of the mask established from > * channels > * @active_scan_mask: [INTERN] union of all scan masks requested by buffers