Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp625982rdh; Sun, 24 Sep 2023 05:15:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOsLWZ27ET26W/licOu6SKvSBmajjXIILIYXju/OVbeLTuT6M89DoQCe1UhTZx/4BXyRge X-Received: by 2002:a05:6a20:8f29:b0:13f:c40c:379 with SMTP id b41-20020a056a208f2900b0013fc40c0379mr3268257pzk.13.1695557710201; Sun, 24 Sep 2023 05:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695557710; cv=none; d=google.com; s=arc-20160816; b=feeIklhBXKvCXOMSwRTF6itIkbktVBt5Cc/J50geSk5PZR8gaLh2N+DVNe/SgJGP/T RCFvfZ3GLI5R1xUMg9vWnCDvEw9ffs5LPkiXxShQlFCmf+kDiZQcx/BVB4+l2cBhMUAh VkUSc/OuzjB0CuSiSdsc745gjOzTwtUR9ACOOq9DsHb7Y2JFxSEjDMlIIyYP+q5s/YUJ ppzYOq3QZBC9kpYQDnO04sHkM5n5ig0A95RurFNGLmzJ//4buPsYx0ZWEYy4d6SX5V9Z gw+AF+cf5S+HAkfGx238T/ZulAP6Zb3fgeZ9CuIb//SUrtnxHKoYS/3z1WNEDff6E2jD RGeQ== 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=LaJcM7grKzX1axz9ZC0GN8g/rh4N9T1a3geKx2tdvbE=; fh=fy/Q0l5cs1j/VtmucBJWVWHPqJJniKSeqaWUJdd+DcE=; b=iqhPqN8W3NdG95hs3T6ozm1zPWOVvjGCbFT318ejBtsva/FWTDkXCmTG8RtnoUNTkv ZxQvC+BX92WklV000uFd5kDuebuyxeGQlnma1Elww1FKEfyUaMNk90V6p7KzGGjVjMdW I6qJIWUtsBYN7jTBdIHOgSDNYuUWF9Fdni3uKlrpuz/k6VXRI4850kCqIf4gaEVLRcul FBcJyKAbLJ8iEnHRjl8uIvKzogp2DTZztOqdHx8+X7Q/DHwbcnGwjfjDMxxygJfcRyhd IWfmNNpr6TozgQt+sSD41icWejyBW5pumWodcET2engIAbZ7ztzLrvxe2555vdetjTbT V1WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qk6DIL+3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x185-20020a6386c2000000b00578fc70f905si5887357pgd.315.2023.09.24.05.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 05:15:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qk6DIL+3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 433A98099275; Sun, 24 Sep 2023 05:15:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbjIXMPK (ORCPT + 99 others); Sun, 24 Sep 2023 08:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjIXMPJ (ORCPT ); Sun, 24 Sep 2023 08:15:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C7DAFE; Sun, 24 Sep 2023 05:15:03 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F3A4C433C8; Sun, 24 Sep 2023 12:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695557703; bh=gPXi1eCu0s1miFDC6/sjRthketQrCVLtEzbLlQDVX8A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Qk6DIL+3JVpmfVsGfuoTpzwbFVb9R3arD5zA7u3hs/aC2/zlIcu8eY42UZNKpk/WB VQLEpgsOMaBOzuS/Zq/z9yN5DHTUHYJqKEtcsPLhbzExB2eAoHtRQpgNsgXCN5TK6F f7xsKcNGTBChaF45vSHxymIeu/ZSTMBHrzc3vGAA4Mxkywz3h1/qdeddPhQ1ChGIL+ gPiOpJmMNIa2WdrBQkyhoNkaYT4AqbsGLLb8n7RVVuh90DJFuHf83J3bmgV1n0Pcq3 JL+5mvuBGvPPaXRFvmIxV6eEqxIHsZBpzeLfQywDuxDCLTdCaLJHzQbkZYZFsdDi7x D0We8EeEiiA1A== Date: Sun, 24 Sep 2023 13:14:54 +0100 From: Jonathan Cameron To: Matti Vaittinen Cc: Jonathan Cameron , Matti Vaittinen , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Angel Iglesias , Andy Shevchenko , Andreas Klinger , Benjamin Bara , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] iio: pressure: Support ROHM BU1390 Message-ID: <20230924131454.7cae02a9@jic23-huawei> In-Reply-To: <9d929df3-ac51-7d1f-ec00-856849cc70c7@gmail.com> References: <20230917113518.7c4bb1a0@jic23-huawei> <20230919155340.0000076f@Huawei.com> <7181e56e-9488-25c9-3d03-64e49b2c952a@gmail.com> <9d929df3-ac51-7d1f-ec00-856849cc70c7@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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Sun, 24 Sep 2023 05:15:09 -0700 (PDT) On Thu, 21 Sep 2023 12:00:39 +0300 Matti Vaittinen wrote: > On 9/21/23 11:17, Matti Vaittinen wrote: > > > Another thing to note is that, when we build the available_scan_mask > > array - we should either pay attention to the order of masks - or change > > the iio_scan_mask_match() to not accept first matching subset but to go > > through all of the masks unless it finds and exactly matching one (and > > in general prefer the smallest subset). Not sure this is worth the extra > > cycles though. > > Replying to myself and to those who I perhaps managed to confuse :) > > As a result of above pondering I wrote this: > > @@ -411,6 +418,8 @@ static const unsigned long > *iio_scan_mask_match(const unsigned long *av_masks, > const unsigned long *mask, > bool strict) > { > + const unsigned long *smallest = NULL; > + > if (bitmap_empty(mask, masklength)) > return NULL; > while (*av_masks) { > @@ -418,12 +427,16 @@ static const unsigned long > *iio_scan_mask_match(const unsigned long *av_masks, > if (bitmap_equal(mask, av_masks, masklength)) > return av_masks; > } else { > - if (bitmap_subset(mask, av_masks, masklength)) > - return av_masks; > + if (bitmap_subset(mask, av_masks, masklength)) { > + if (!smallest || > + bitmap_weight(av_masks, BITS_PER_LONG) < > + bitmap_weight(smallest, BITS_PER_LONG)) > + smallest = av_masks; > + } > } > av_masks += BITS_TO_LONGS(masklength); > } > - return NULL; > + return smallest; > } > > but ... > ... I see a problem that some of the channels may be more costly to > access than the other. It could be that reading some of the channels is > just a matter of getting a cached value, while other could require a > long measurement time and access to significant amount of registers. So, > the knowledge of preferred scan masks should indeed be on the driver > side. Hence, the ordering of the masks in the order of preference makes > perfect sense. What we could do in the IIO core side is still go through > all of the available masks to see if we find an exact match. I guess we > could also document the fact that the order of masks matters. I should have read on in the thread. Indeed - ordering of preferences needs to be in driver control for exactly the reason you came up with! Thanks, Jonathan > > Thanks for listening - and sorry for the noise :) > > Yours, > -- Matti >