From patchwork Wed Sep 27 08:27:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 145675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3014012vqu; Wed, 27 Sep 2023 18:48:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMXgOpR3tFmb+SNNfJqgbpqh6s7s1DO436XJcC51EhBNW4snsjXmgC+KNZTm6CL787mnSD X-Received: by 2002:a0d:e8c2:0:b0:59b:a2a:2131 with SMTP id r185-20020a0de8c2000000b0059b0a2a2131mr3759543ywe.31.1695865684984; Wed, 27 Sep 2023 18:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695865684; cv=none; d=google.com; s=arc-20160816; b=I4JwWHcvtOOwVNiRYYC1m2WxaMw668SPmuZvT8sv7G799Z4RUOxDIe5JZuJEbReigm w6jxz0Ny2P0nGbfJlbnCKNXEtEZjdSkGwvy4At6h/PpMpensMuFipSGa+DwBz8hjhU/j 15CTACXWcMu43F6xeV0N+iz40j2xTXU9GzWX8465owJK4/JjbXUHOVsDEu0b1TWjxwco 89eDD1GrR3Ofoi7VlpbCI32v2oPxsy43RrxopooF2nw28scGet9XqcF4QECeb2epxzGG XfhmHAzjRrHYdtTrNowYg42YwixgMJy/KzMx4YGcHjd8i0R99+M9uPuWEE27aG+PRNtt sqSA== 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=Hj1fAt2POw3G1BVuIsXBKGLxebPu14W+cyBpSJ0ZvcI=; fh=UdmbWaEkiZjiE5aS9fW0BpH9MhEg6tNeE+OQ6eH7yzc=; b=KCNkW2PBsykGsTwXcdKxV54+QgvKwLgucl7pDhkPiSxB+4qYqWWbARkjmooOQqNxqQ LcL9YltTHCubz3kJ6iUQsDLuEcIDihK7D09NcuMir0rnJqov+SFai4fVYCO+BHBC0sSS 5L9qXHRwEAHVh8KF8Fuh/JZkcyzJrnKrptbj0dkUdFScLtkiL/ZwNzVeKTy+sFkUvj9a s78/1nKlpiJ4YaM6ayXCnF5N+ABzy+sDhGkBHxprsGVrCPjYcL3ByAdF8pqHqdvjzkhy tWM3gfNARo/kyyYHWE76n/jjTV2aljJ9wDrGXT/pVQ0+FeIK2w2+VleRnXc61jEED2WM tiHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FV8ocweE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c8-20020a17090ad90800b0027749a98349si10598958pjv.4.2023.09.27.18.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 18:48:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FV8ocweE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 8B6EA8294F7B; Wed, 27 Sep 2023 01:28:22 -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 S230163AbjI0I2C (ORCPT + 23 others); Wed, 27 Sep 2023 04:28:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjI0I1t (ORCPT ); Wed, 27 Sep 2023 04:27:49 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36BC31AC; Wed, 27 Sep 2023 01:27:48 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2bffc55af02so172410331fa.2; Wed, 27 Sep 2023 01:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695803266; x=1696408066; 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=Hj1fAt2POw3G1BVuIsXBKGLxebPu14W+cyBpSJ0ZvcI=; b=FV8ocweEHg8MOpz/GP3m88ft4DP+kL++AYzTqo7SVK1cFVuHy0qLy6d40Hm38vrHaj ZUcFF3oALF4W2DaBNDtP4H31SxenWPhLFATIZvAj61cMjdexJCL9wT4Xg0/CK8FwaNpA fECravsyKdfcShIF6v3YMRSpuGIRrRwGN7yw3J7IgfvYs91698lxFnDm9M5NOxhL1HJg cnnDz/AmKjPckbUQizjuklqvwRS51v+e7LMx/9zeuU6Z1UvoAR3AX/wLzL91Otq+ldnB F1WW1l4kQwrC3PHSMXluVFBZ+5KH67Mh+1Ah+/tgT4qWfwsPDqbKiRM/Y1s24eWlO02D 19qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695803266; x=1696408066; 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=Hj1fAt2POw3G1BVuIsXBKGLxebPu14W+cyBpSJ0ZvcI=; b=LQl78bnKQzC+12GXOP7iEflB7Hund3B/09Hk8eiaY6GulXRJ/+qWt8atOYnkvdj2bv JIumaMMnZZzFVm49FddezNEm1PFlVzgOdyf6QTxTuanaJOkuNQx//e1mLuumdfNuI5zT i4ewB8QJsf+j2UXkd58An3odKIi/pqnp1I58o6Yw3tyHDBYDHvoiXD9ec/nf+d6kPDbc tXuyVwrNKnObIGnNoqEJQnKbpdYgena0j6u/SRicoH6RTQUBGTbfN3zbcCvl/g9ChEGO xWEsjVRL8d5ScJluM/Zx9HJCRM9K9jrMNMjvcxheo132GKN6w5aZ6IElimG7a3+okLP5 NGBA== X-Gm-Message-State: AOJu0YwwRzKg96LBmJFBPjMAYRtXj+/Q75EqUGhKH3+sBqGJk313B98a ghbHFHcAZG8OzXLszapYBxk= X-Received: by 2002:a2e:9612:0:b0:2bc:be3c:9080 with SMTP id v18-20020a2e9612000000b002bcbe3c9080mr1314766ljh.27.1695803266085; Wed, 27 Sep 2023 01:27:46 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id y4-20020a2e95c4000000b002ba586d27a2sm3038128ljh.26.2023.09.27.01.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 01:27:45 -0700 (PDT) Date: Wed, 27 Sep 2023 11:27:41 +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 , Benjamin Bara , Christophe JAILLET , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/5] iio: improve doc for available_scan_mask Message-ID: <4e43bf0186df5c8a56b470318b4827605f9cad6c.1695727471.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]); Wed, 27 Sep 2023 01:28:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778244056087983131 X-GMAIL-MSGID: 1778244056087983131 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 --- 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