Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2359701rdg; Mon, 16 Oct 2023 01:40:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGH2HTNWPVlCySphSLRPRiI0xeHIW5sLd4sIOOxUkyONcjkv+VVLB2Hyol2AghbOFkMHch X-Received: by 2002:a05:6e02:1d8c:b0:357:47a3:adbd with SMTP id h12-20020a056e021d8c00b0035747a3adbdmr18042152ila.30.1697445628508; Mon, 16 Oct 2023 01:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697445628; cv=none; d=google.com; s=arc-20160816; b=oRkUcrXcfE3wzRpJMYOzLli9IbveyTXtJakyGBpnfHlLgGTgtUYLr/kxLSANMcV8lo y6O4rMXvqd/A9yEV1Ohy0P1tASGB0yRBVgyFNQqp6T3LROB6qZcAg2mHmMW1rZYKX71X IEcuVDAFPN7lG1kHOKevMGHHs9LXXTcwO3kQR/0ndcntPtdPakJiPMl+ADu1L6H4EcOZ EZNgpbLm/fdImesP8aEi47cMJhW+0DMzMjgrruG4W3wTXDn1+JzGau89jM/P08aApL6h FkftewnrhuvgQoruPR+QLM0inbA8++n7J7V3kgJOC7SraQzMN/JjX2hcY2WDtk/Cvudk onLw== 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=EIcV/eoNsTgvVRSx24uewUH2oAnDhtvzsUFfFeqBsMI=; fh=ZOEikdEIDkIqTto/ZVp7+Yvs8cACMemCPKP2g5/JgWM=; b=xurkXYhtP1uPcGR6tfPsniGxwdsDoYwp1dxXHAALTlYP7dczzdHhGZYtUhBYwn2sap YGhX667dx1+3VWxEE4CqPBnqRa0XsjR9xgNRfhEFvnU8wGSAjyr/kEyg9gdcTjvnrUoz Bok+WkyNtN4RYEqPC8OwN93DN0OX7HtoWh9M/R6OR0suGNN0AENHY4BKB/q9ZoG42iyQ oMlysxvmnyeNN1cwsBQqQvfUjcMaG/8nyxEKwzuhqb4WxWrR8UeGxv6xpcmnubpiD1Pu 9EzEiZrXvn+czBnOKhx/Rs6b+v0QU84AHulwFLpcafCpv2CvLMYA9QMw+6FypnXdOypu IdjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ecYdBBZD; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a21-20020a63e855000000b0055c1760dd8esi8251692pgk.380.2023.10.16.01.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 01:40:28 -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=@linaro.org header.s=google header.b=ecYdBBZD; 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=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1C0EA8051AA4; Mon, 16 Oct 2023 01:40:24 -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 S229574AbjJPIkJ (ORCPT + 99 others); Mon, 16 Oct 2023 04:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbjJPIkI (ORCPT ); Mon, 16 Oct 2023 04:40:08 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF4C4E1 for ; Mon, 16 Oct 2023 01:40:06 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-5a7c95b8d14so54035407b3.3 for ; Mon, 16 Oct 2023 01:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697445606; x=1698050406; darn=vger.kernel.org; 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=EIcV/eoNsTgvVRSx24uewUH2oAnDhtvzsUFfFeqBsMI=; b=ecYdBBZDrY+6oM87gO4OVus+ETittYgVAw/vFWbo/gMxbwY/lZtRx1LLitY5M8sags HdcrhL6LOp+FY236x4gzUHxvNyUC+VXEviPN48mZwGr78oeeW5p+vDKa0u/Osx0++pGe 3wSTD13P7BQ0Bw3QRkpQGRXV0DPHAgJdpdhnOgl0dyNk4h4T8ESjK2osuet7o6SyFb9I HdbJqw0xb/AHTFgWcozODfCT9/47QT7tf6R9fdz4rTE/RdlpT1GDVn2OUFu+oJw1C+Xi C7FZGXosYwRF0B7cVbVJXFqWoEMk5JVEozAySvGbyWL82utRIa+AJjQlENgYlgqpiv2a pMpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697445606; x=1698050406; 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=EIcV/eoNsTgvVRSx24uewUH2oAnDhtvzsUFfFeqBsMI=; b=pZl6h7vhKZIpF9/Z9xAFpKh7zIedErt5JdoVBt4uirL70wHioX0DazxfuwS4spsYTK UvOq7+0ok9N1bIGU17TwYbEOjn1sj5Uwg8anYYdE7Lf+SGSJ3pBSe73j+iDE7jpI2Nit 3bYs2s7ekwcDDsH7kQ1UFEKSPkzBAJCVPo7Gm5b2sOfGpGxFoEPOCPFCRgWAaGZC8Zix aINir+2Y6T72p7fu0oCJOSd1uwaCLW/sEklUacM2lLiaBdN305OsH5YILy7tqvfVW2fh JxBgR2/Z/86GBA9g+cJyEhQ/MYCPwqND1FUflkk8hA9x8YHCW7TTvCUOEVXL0o1ZhmV4 7P0g== X-Gm-Message-State: AOJu0YzW6SjHV5k9oPnzF59ngeqVgJjC2XC9TaS98BsCMZxjY0zbN6Um CzxSiC70a7qQxcyr4F4+uhqtJGRApUlvdWdr98SRVynN9McvPeCp5mI= X-Received: by 2002:a81:b40c:0:b0:592:2a17:9d88 with SMTP id h12-20020a81b40c000000b005922a179d88mr36930507ywi.47.1697445606104; Mon, 16 Oct 2023 01:40:06 -0700 (PDT) MIME-Version: 1.0 References: <20230902-iio-rescale-only-offset-v2-1-988b807754c8@linaro.org> In-Reply-To: From: Linus Walleij Date: Mon, 16 Oct 2023 10:39:54 +0200 Message-ID: Subject: Re: [PATCH v2] iio: afe: rescale: Accept only offset channels To: Peter Rosin Cc: Jonathan Cameron , Lars-Peter Clausen , Liam Beguin , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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]); Mon, 16 Oct 2023 01:40:24 -0700 (PDT) On Sun, Oct 15, 2023 at 12:38=E2=80=AFAM Peter Rosin wrot= e: > 2023-09-02 at 21:46, Linus Walleij wrote: > > if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) && > > - iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE)) { > > - dev_info(dev, "using raw+scale source channel\n"); > > + (iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE) || > > + iio_channel_has_info(schan, IIO_CHAN_INFO_OFFSET))) { > > + dev_info(dev, "using raw+scale/offset source channel\n"); > > If the rules really are that when not provided scale is 1 and offset 0 > (reasonable of course) then the above still looks suspect to me. Should > this part not simply be > > if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW)) { > dev_info(dev, "using raw source channel\n"); > > in that case? The patch is based on Jonathan's comment that while we currently support raw+scale, having just raw+offset provided is a possibility. The if()-clause above (which I guess you are commenting) is meant as "take this path if scale or offset or both are provided". Just raw (with neither offset or rescale) doesn't make sense, since the AFE rescaler does just offsetting and rescaling, in that case the user should just use the raw channel. Also it would then take precedence over a processed channel (which applies rescale and offset internally) which doesn't make sense to me. > Or was "raw + processed" some kind of special case that we want to handle > as processed? If that's the case then we need to have more complex logic. Processed is on the else-path, which will be tried only when neither scale nor offset is provided: > } else if (iio_channel_has_info(schan, IIO_CHAN_INFO_PROCESSED)) { > dev_info(dev, "using processed channel\n"); > rescale->chan_processed =3D true; I'm not sure I fully understood the remark, please elaborate if I got it wr= ong! Yours, Linus Walleij