Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5407965rwd; Mon, 5 Jun 2023 03:15:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6I7ydsjmFmx2X67YID0/QG8MaTSiRWnpNR+T74zYXewC0tQFdQTLRa239afBxS2VOj89I1 X-Received: by 2002:a05:6a20:3cac:b0:10c:b1b0:3ee3 with SMTP id b44-20020a056a203cac00b0010cb1b03ee3mr6519024pzj.21.1685960138551; Mon, 05 Jun 2023 03:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685960138; cv=none; d=google.com; s=arc-20160816; b=R29mDcRnBZAEe9iiUTznh/1iydprUqhKtcB6DJ0XRhS4P6E504TZN2lrT/GsAoloLh BW8NVYwa0lIoEnOd2RVMiaZg9MbiTUesr0p4teAegoOTWGbn0YUtis3/APSdVLukDlGv ci/AZIyFXOjB7XRPNOtcV/mAuAfPeuUSAlMtnhYLrhxoxJ8SnvN8mFsCj8vbMoMQFwi+ /pqkzZ5hP9DvmUmTcofyPdAuyOuvg61ti7+q9QeTGUh4ID0OdAogGDQLyi0OLHyR66JB FLw4LSa99+HAS02gU7MudV+jYipLfCPzjRcoKdr9uhdeCYw6VMu1MkhFg0+/z4TVQOZq eXhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=eJsWxNn+ehAzikAnLEGHSuhlWphRfQgau36mI159SV8=; b=Bc77WDyA7pwjUgEtOp3uZWywrK2A5qD800wrbQfxrVMZSoeBTSCmYP1DIUOAHgc46q h+zXipvbFTs9gen9PkTc/yxd9wzMrdEv5lEvX1J1n3IkNwvAMi/etM/q5RhCgMrOU4Cg h0l4GFVc6+wohS4VvPYKtm3lP9e1qlyne4y8Fib2WPJrX7/zIbGc7kiJTK0baWc//C2U DX0BCFpfIvp25heUEXslpKGjvrv+Cj92zoHPcaK9UHOgJfMdJcLqSn89m1NXgGyvxOXF mfP8o3kuf8/kNYmp4V/bptX/TFQPrCwQzgaDol3SWKGSf+PeOJkuKNtp0s2VXcCUhoE5 Vbjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mXTdR4Cc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p22-20020a63c156000000b0053f27c5efe4si5051653pgi.857.2023.06.05.03.15.24; Mon, 05 Jun 2023 03:15:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mXTdR4Cc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231418AbjFEJqI (ORCPT + 99 others); Mon, 5 Jun 2023 05:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbjFEJqE (ORCPT ); Mon, 5 Jun 2023 05:46:04 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB026DB; Mon, 5 Jun 2023 02:46:01 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-6261cb1208eso31922786d6.0; Mon, 05 Jun 2023 02:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685958361; x=1688550361; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eJsWxNn+ehAzikAnLEGHSuhlWphRfQgau36mI159SV8=; b=mXTdR4CcVVVjT/Qc4hbfsPVKcGa4qvFMqokLP3mWACF+hehi0eYEZCAAh8Mly5xqZ7 OdQwB9RvK466dKJPm3Xf14I/MnPDyaCEMucCpze46I6jU9fvPWEb2aq14aedRxI+v71L TatFHLdGo2Rg1oJUNQjsOVwuVVSXFfr1tYysFr1hPhQ8oRe1Onf2jM19DMhv6J33siK3 MA4w8+18ByiU8GJrrUTFvaO66wdv/esL455cAs/VlnjO2Ru0vdNnpq+ioNINk5v+s/oX ncCrSSB+ynRvBjn9sofTSltEuX0eoaDFtr/j37ETRRGdEjxUSuGc4aCgLaXRDtGYzKJ2 3oXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685958361; x=1688550361; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eJsWxNn+ehAzikAnLEGHSuhlWphRfQgau36mI159SV8=; b=XTPNwgEl3i1i2UqECEKU5OffcN0Z3DAYA6ZVSVqXLi5nKDuhty+u9Ci5US4Ib7wR0C 9SfIlmNAXs0YM+p2E43ohGSSluVlTmxx9/KV6M+DOh8AQvqTAvWeC7Vjd4PhtAgc9vHp +5Cz+fzYLI78RlAXjdP7v67asDE5a6VJWnkO3MvsGi36wyRz5Y3+poHAQV6mrYdH+oCK bkmOH5XZ8sNbpgSQhq8tl1EYPTK/C5SkAumem0yjfKDMenq3kjPLruCBVuT8lw4PHRXd OAWnm+ye4IL8GhlxCGkuYW+LjUYPRkV3mcu7cUTbCmnrY629DQwumsUYidqKFFLvMVyZ 2pZw== X-Gm-Message-State: AC+VfDxmuOIuBcPtGC89ktRjDTx3e+18lv5jP+SKfthi3JTmGu+s79w9 yjNpXs19AxUXETW+6vVaFfwQFvt2faiV80uOfkOzYHFTIeI= X-Received: by 2002:a05:620a:46a2:b0:75b:23a1:d847 with SMTP id bq34-20020a05620a46a200b0075b23a1d847mr15874844qkb.9.1685958360822; Mon, 05 Jun 2023 02:46:00 -0700 (PDT) MIME-Version: 1.0 References: <20230523151223.109551-1-herve.codina@bootlin.com> <20230523151223.109551-6-herve.codina@bootlin.com> <20230605094637.7615b689@bootlin.com> In-Reply-To: <20230605094637.7615b689@bootlin.com> From: Andy Shevchenko Date: Mon, 5 Jun 2023 12:45:24 +0300 Message-ID: Subject: Re: [PATCH v2 5/9] iio: inkern: Add a helper to query an available minimum raw value To: Herve Codina Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Mon, Jun 5, 2023 at 10:46=E2=80=AFAM Herve Codina wrote: > On Sat, 3 Jun 2023 17:04:37 +0300 > andy.shevchenko@gmail.com wrote: > > Tue, May 23, 2023 at 05:12:19PM +0200, Herve Codina kirjoitti: ... > > > + case IIO_VAL_INT: > > > + *val =3D vals[--length]; > > > > > + while (length) { > > > > while (length--) { > > > > will do the job and at the same time... > > > > > + if (vals[--length] < *val) > > > + *val =3D vals[length]; > > > > ...this construction becomes less confusing (easier to parse). > > Indeed, I will change in the next iteration. And looking into above line, this whole construction I would prefer to have a macro in minmax.h like #define min_array(array, len) \ {( \ typeof(len) __len =3D (len); \ typeof(*(array)) __element =3D (array)[--__len]; \ while (__len--) \ __element =3D min(__element, (array)[__len]); \ __element; \ )} (it might need more work, but you got the idea) > > > + } > > > + break; ... > > > + default: > > > + /* FIXME: learn about min for other iio values */ > > > > I believe in a final version this comment won't be here. > > We have the same FIXME comment in the iio_channel_read_max() function I > copied to create this iio_channel_read_min() and, to be honest, I > don't really know how to handle these other cases. > > In this series, I would prefer to keep this FIXME. I see, Jonathan needs to be involved here then. > > > + return -EINVAL; --=20 With Best Regards, Andy Shevchenko