From patchwork Fri Sep 22 11:16:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 143563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5769344vqi; Fri, 22 Sep 2023 11:00:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVy7kneMOUPy/+FB4L+YzYLhsjhLu3Ewthof0gV6MuJrCuF3As1Su/KRd40FFYQZOEIw8Y X-Received: by 2002:a05:6a00:190b:b0:690:2818:a4ce with SMTP id y11-20020a056a00190b00b006902818a4cemr179888pfi.7.1695405630463; Fri, 22 Sep 2023 11:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695405630; cv=none; d=google.com; s=arc-20160816; b=cdwRCSCzXY6tUjhW3IjAnSGjXRPoWbSCJp1eVyiG7eVaOel55/0eoZTLCS1LPLufGn uMcWXpFVaPwZd4txWAM7Oq5AAYg87Yu+W7mLVq9QJ2L6u839yz+vtUYKvdAluIGW0klL RdZU6RJSDjYfltxsnfbxW5kaq4jDAcJWFrA3bVs22rWicvZWDnG9stu3x+yvnCFYOCbM 00GVAMChks5COfF1YteAXM/wFOeYDpgP8MuqEhGk41jq5dtlKp3FWRrTx7wrJYPISakG JS2fBC+YHLFPcsOxkwJLg5B54MykfwfmnmtBEtUjnmfJG4v2ZJCK+kAo1ObdXxXcHtae HR7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rOmXlRHFjQZVNGJzWqKnGXST1HA75pZmn0pDpkT8XEA=; fh=+XkJcXOKJ4Dl6AYTln3UzvhZHjSiM5yCnDKdoCP8e7U=; b=Q8+CqwIJPulgTNmSsr0zg99AIwccdqeNI/HexSTnWjrdTT+nT71px12ClYF5dArZy5 zKGS5HGVSxc32JAi5gt6l5TzfJqzsYoH57iI1kuTi7Cgytm+8/XnWc5TAB0Bud1ZK1SS LJng4KpqzzOhpLeOfmv+rkOZVWqOInxPv1FppsxiLw+6AJHGj7yKiUI3rbyb3+5q6UNa zJR1wyKFXu525E8qa92fBBfm6KlnocH+Weuq1L7rhsAtPUaOhVD+YiL223xU1LGamKKh lhSInhr1HWpH8TBhNr2P69vKcMaOWAoDZjSMz3gLdwlpt/NAZnk4rrpodmKsHqy/YNCt rBBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Yzr1QRRE; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p24-20020a056a0026d800b0068fe810e8a2si4042721pfw.185.2023.09.22.11.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 11:00:30 -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=@gmail.com header.s=20230601 header.b=Yzr1QRRE; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B56E5828E0A4; Fri, 22 Sep 2023 04:17:17 -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 S233584AbjIVLRM (ORCPT + 30 others); Fri, 22 Sep 2023 07:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233378AbjIVLRL (ORCPT ); Fri, 22 Sep 2023 07:17:11 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97D1EAF; Fri, 22 Sep 2023 04:17:05 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2b95d5ee18dso34320681fa.1; Fri, 22 Sep 2023 04:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695381424; x=1695986224; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rOmXlRHFjQZVNGJzWqKnGXST1HA75pZmn0pDpkT8XEA=; b=Yzr1QRREIqQMan7zQS/B26XmynwrCHWPLSUm/sfxHIuCvHdLYA1FTZC+ecubj10Wyz AzQcqYJ56rZ5Lle8kSgaqU1Tvv94J3903y5+SqxhU9JzTCf6tmxDDuhegXtR498YLhS1 AqqP5VlW3BjSXDI5V4gKOePrHGnG5iWdNqd/JTH0gA1+SA2QpFjCGHY15eLCbUUzjPsM suGTEvh4O14NGoucQlJmDglF5zksNxPFGF4fJ4SocTiKVT4P29vusqW4NUP7fYd53IYL IYeEQZK5tr9Culqws8sK+9uv9esOF23STqa25ur/uYwEh1rf5XmC0z9OqfDCBvuvO3xw lZZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695381424; x=1695986224; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rOmXlRHFjQZVNGJzWqKnGXST1HA75pZmn0pDpkT8XEA=; b=Oct3SSLZLalsIvnfYd679iIKqos6WYltmVnBp0qbGaUHCtZqNC+QdkqnvnrOS42UXj 64Zn5dh5WoU0TJI7AI7Nm1gVP4WM0EC92rnejrzGJOJD5mDoYv5/XIbLEkXN87/SHD/N WN7veHTM1j7GxlWauGJ9sDUEW5o8TcOTzDDlVOHCZTEEtFwXJ0qOi17hsaPFzBVIOx5C 1z3uajh2+cjiLA0+sS+KHrHFVDE/jNDVbNEFQRRj+sfjoSeyLDGa1gPTgZDflc8q7MIx 93tQJZlr30Np4MLEQg7s1sCDj0XoD796DNZWxD1DHuMfXFlJhVLQL6uqGGDGi9U+DyeE xztQ== X-Gm-Message-State: AOJu0YwsiwJluaRQgE39+Iqyd+CBjYrdAxTPSf6APXe41tgIDV/Pu/kh qQQgOdECP0Gddhe8kDnJ6dA= X-Received: by 2002:a05:651c:1034:b0:2bc:d8cb:5a13 with SMTP id w20-20020a05651c103400b002bcd8cb5a13mr7176763ljm.42.1695381423636; Fri, 22 Sep 2023 04:17:03 -0700 (PDT) Received: from dc78bmyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc78bmyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f8:1500::1]) by smtp.gmail.com with ESMTPSA id v12-20020a2e960c000000b002b6ad323248sm868292ljh.10.2023.09.22.04.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 04:17:02 -0700 (PDT) Date: Fri, 22 Sep 2023 14:16:57 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , Andy Shevchenko , Angel Iglesias , Andreas Klinger , Christophe JAILLET , Benjamin Bara , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/6] iio: improve doc for available_scan_mask Message-ID: <74b66a5b9eee2fb7046f254928391e3da61aa3b2.1695380366.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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]); Fri, 22 Sep 2023 04:17:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777761654120307372 X-GMAIL-MSGID: 1777761654120307372 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 subset of channels are enabled, and 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 mask would be 'pressure and temperature' and 'pressure only'. When IIO seatchs 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 difference. We should 'prefer' reading just the pressure from the hardware (as it is cheaper operation than reading both pressure and temperature) over reading both pressure and temperature. Hence, we should set the 'only pressure' as first scan mask in available_scan_mask array. If we set the 'pressure and temperature' as first in 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 ordering of masks matters. Signed-off-by: Matti Vaittinen --- 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