Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3167085pxv; Sun, 4 Jul 2021 09:45:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZSIQ5xj+hYiIcO98IvmEYUBvXFmL6OR+mXAeJcqO801aJeGuAdyR41jmyuQTRxcXssbJe X-Received: by 2002:a05:6402:100e:: with SMTP id c14mr11113834edu.51.1625417105791; Sun, 04 Jul 2021 09:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625417105; cv=none; d=google.com; s=arc-20160816; b=h5pDmU/m81XndFHWIRVO1CHYtRHHcHKNrQB/fmxRZGTrfYk2q08W6CNcNIn4Biw4eI mxGBY5lUsmXBBgsWNvPWzBIUjTqOJ15wiVTdEu/bnjyeBAA47Mg8txRR2XOF35+xzd24 yfO1YBH30SzwtVqEokqQzDSiP3m/uZOVr122J+OJmHKVEFTF6JBNqX+Yp9gGLRoVIQ7j PsAa/ZXs6XQQ5sp2wVsSM6Eft0sWcwROQBms6Ek2xip7eL87RwKjkQTWqZHR6ebuNSVG eNRp4L98AGTOCdwgV4FX0M3ouMmamV58c5GqT0jutSqBth1/HERS5IcNB9u13W3oX/Ud hsZw== 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; bh=w2BBB5ULyWiYDk3/rHTjZwlgmY2S65niPKYxsmPZSHA=; b=dYzy8BDWDgnT6qjEWcksalthbBU+WPzw9GNei5RwUsonT3pUNUD/VbcDv5a0oBr1ah ucjyFyZ4g+Zt2wpMOpxMrAzD11oy01VSj7LApK7tAv1JEna01Oq2LH76MpFLmZRNOCjW yFbCmDFzLqk5kfjp7C7bz+erF14VzUPlJD+ULP4Fk1Ly6B3ObGEJXcQUC7AjuDweG/tf MUL1OCMg2IB5vOz3zqxRjd+OeLP2h6E8QPdr1K55AZETGSZaCUIKPzk2RsEu9L5I/siO R2yqCwA3AFgX5GM3cr2y8wuv/Bl6+sTYRNbBdD3kD9H5F+NIipjJMNjSdDVDwXKEzo6z dskA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si527264ejo.365.2021.07.04.09.44.42; Sun, 04 Jul 2021 09:45:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbhGDQiJ (ORCPT + 99 others); Sun, 4 Jul 2021 12:38:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:42586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbhGDQiJ (ORCPT ); Sun, 4 Jul 2021 12:38:09 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 98646613C8; Sun, 4 Jul 2021 16:35:30 +0000 (UTC) Date: Sun, 4 Jul 2021 17:37:54 +0100 From: Jonathan Cameron To: Liam Beguin Cc: peda@axentia.se, lars@metafoo.de, pmeerw@pmeerw.net, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org Subject: Re: [PATCH v3 05/10] iio: afe: rescale: add INT_PLUS_{MICRO,NANO} support Message-ID: <20210704173754.64919405@jic23-huawei> In-Reply-To: <20210701010034.303088-6-liambeguin@gmail.com> References: <20210701010034.303088-1-liambeguin@gmail.com> <20210701010034.303088-6-liambeguin@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Jun 2021 21:00:29 -0400 Liam Beguin wrote: > From: Liam Beguin > > Add IIO_VAL_INT_PLUS_{NANO,MICRO} scaling support. > Scale the integer part and the decimal parts individually and keep the > original scaling type. > > Signed-off-by: Liam Beguin > --- > drivers/iio/afe/iio-rescale.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c > index 98bcb5d418d6..8f79c582519c 100644 > --- a/drivers/iio/afe/iio-rescale.c > +++ b/drivers/iio/afe/iio-rescale.c > @@ -87,7 +87,16 @@ static int rescale_read_raw(struct iio_dev *indio_dev, > do_div(tmp, 1000000000LL); > *val = tmp; > return ret; > + case IIO_VAL_INT_PLUS_NANO: > + fallthrough; As earlier, I'm fairly sure you don't need this (but I could be wrong, so if I am wrong point me at a reference). > + case IIO_VAL_INT_PLUS_MICRO: > + tmp = (s64)*val * rescale->numerator; > + *val = div_s64(tmp, rescale->denominator); > + tmp = (s64)*val2 * rescale->numerator; > + *val2 = div_s64(tmp, rescale->denominator); > + return ret; > default: > + dev_err(&indio_dev->dev, "unsupported type %d\n", ret); > return -EOPNOTSUPP; > } > default: