From patchwork Tue Jul 2 16:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13720013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.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.lore.kernel.org (Postfix) with ESMTPS id 04567C30658 for ; Tue, 2 Jul 2024 16:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:Reply-To: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=10zJwQdsGuhDlsuIHv6vlHCfqT5ZnUjSUcTE/CIhTyg=; b=icjCxiPpN49m2sX+rbjQplRtGB jhoBKY6CZcX8NHQr75kltdJrh8EXNlGJRk635w19DVXEzxsDvBJCILwFDZPH4IcQH7gz/3P6gC7KV TrZIdpNlPOv+WgPLc+qLVNYNi3RTz39BwejB/STiDyvesRCjIqAgHqM/KAdWmVwPTjZ5Rg9J0JLzj +Qyc3jpB3F3jJXhZAECfu1r96kXjdPExZxxacJEpaFGitYiUlxzGOADwo6ajA59MfychGDHZ58/wH mbaZFLzAAioYE09SeTrrI9z0e4EBI3Pd8QedZlBuJDFqNbMCc1QmJTcZNW8r3feBvIFBpf4akhjB1 34ZUOPfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOfyu-00000007InI-3O9A; Tue, 02 Jul 2024 16:03:48 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOfxp-00000007IOK-2giV for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2024 16:02:44 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id D88BCCE14E7; Tue, 2 Jul 2024 16:02:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 13677C4AF0A; Tue, 2 Jul 2024 16:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719936159; bh=X9U2RqNBvqNInuBI9oKZcFsFepJn/tehK2K25jnqvTc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=bemJDZw+qLgJsnubBLLySuI0flI8N6XRBymD0l44shxoUyB4GuQnbBCWOrXjkP/mN ezzakjbZWke3Dg6HsD380rRn3XK0SGdBoKriDScl2wxZRbDBgDvjeqqNcq3PC+X2fx DCT+GuZECD2BlIdX2fIxz4FDXl7HJ8A6faOlVARtKNQHIEzxtUjg5N92mG+BMwcuTg 70Htz45XYPEfb6LGZfVE5GSQ/OxV+WQzwvmRExHJsZoFa/eQ+O5qIlTfeEVhIv/AV3 1QBrnf5NkklVwIf41REFxGym/7LEGqPdbFyScqXH5XhtkXHIbrtkXJKKZj3u1gnPC4 UDjtuJkjcZNvQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1AF8C30658; Tue, 2 Jul 2024 16:02:38 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Tue, 02 Jul 2024 18:02:33 +0200 Subject: [PATCH 01/20] iio: core: add accessors 'masklength' MIME-Version: 1.0 Message-Id: <20240702-dev-iio-masklength-private-v1-1-98193bf536a6@analog.com> References: <20240702-dev-iio-masklength-private-v1-0-98193bf536a6@analog.com> In-Reply-To: <20240702-dev-iio-masklength-private-v1-0-98193bf536a6@analog.com> To: linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1719936156; l=1677; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=EA7SSU5JCACZ9RbuyelW015qMw9c7NJ9Gp/LUGrm0oI=; b=WOeC8On1W5DCuG3LfamYH01OA5F0KKWMc0DWI3AWAeSbOQx46FElbbhV4CKkRfZy3+gYMQqWC lf31gWkzbbECs1Z5B21bh3N363YaVGrn7aRYnhS2HeqXObSmuYw+cFY X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240702_090242_495864_F13F9FE5 X-CRM114-Status: GOOD ( 11.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: nuno.sa@analog.com Cc: Alexandre Belloni , Lars-Peter Clausen , Michael Hennerich , Cosmin Tanislav , Claudiu Beznea , Guenter Roeck , Dmitry Rokosov , Benson Leung , Jonathan Cameron Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Nuno Sa 'masklength' is supposed to be an IIO private member. However, drivers (often in trigger handlers) need to access it to iterate over the enabled channels for example (there are other reasons). Hence, a couple of new accessors are being added: * iio_for_each_active_channel() - Iterates over the active channels; * iio_get_masklength() - Get length of the channels mask. The goal of these new accessors is to annotate 'masklength' as private as soon as all drivers accessing it are converted to use the new helpers. Signed-off-by: Nuno Sa Reviewed-by: Alexandru Ardelean --- include/linux/iio/iio.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 894309294182d..dd6bbc468283e 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -855,6 +855,24 @@ static inline const struct iio_scan_type return &chan->scan_type; } +/** + * iio_get_masklength - Get length of the channels mask + * @indio_dev: the IIO device to get the masklength for + */ +static inline unsigned int iio_get_masklength(const struct iio_dev *indio_dev) +{ + return indio_dev->masklength; +} + +/** + * iio_for_each_active_channel - Iterated over active channels + * @indio_dev: the IIO device + * @chan: Holds the index of the enabled channel + */ +#define iio_for_each_active_channel(indio_dev, chan) \ + for_each_set_bit((chan), (indio_dev)->active_scan_mask, \ + iio_get_masklength(indio_dev)) + ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals); int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer,