Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp175895pxv; Wed, 30 Jun 2021 18:02:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/I/iVBphxoApHF0Xx4EuaVbkbQ3LtCwG8UL+f3V+ISK4dzWr5jJu74h0Q6sbQiMTgsUuE X-Received: by 2002:a92:8e45:: with SMTP id k5mr29261908ilh.116.1625101357441; Wed, 30 Jun 2021 18:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625101357; cv=none; d=google.com; s=arc-20160816; b=beZEtnAiguewsLC+vghBxk+xIo81QNiJFt4DlGyvoKv+qQFt26jMq8ijAsvoZs7p4X I/lQE9b1MoPrxZ5lBSPIebTEg2fi24Yg57IuH5XE9qBycaYo77mzPm/NKTLCYOr8+DHv xpQiZUPcFUkYgJNqNTkrwFaqegBM8aI2LZuvybCee1YzaAj/ZdjEZUBttNBqUTw6akgQ e6jQIfPin7qCS7+Vfyc2GWJO4NyLDTkefBQhA9OajjsnCJrWihE1etdayhfwKt/6JhI1 eXW/EzD6HEwJSOVFvazQ/Li8pBHXRC+iUApnrb/bJm/fk52+aZB0GB9znYeYHZiSUoMt c9bw== 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:date:subject:cc:to:from :dkim-signature; bh=lmky5l0N9TXo0NTQ1YrbAaaRvC+qKWRHhjy6j7fXuAs=; b=aqwoba4iUmsXuo9utjh1KiGjc7dsjHyGIB298btHDr52pedVonoTSm8ClxLjzI3wQg DC+sNIV+q52XGrvF/jeB27BizuvLMg/uAAOlINbaNpptlkaqCQ9wLbsHlxWvM6KFwBDZ BELS/yVvuCiOQhrsLm8uFcysfoWOq6wWdGTJ7LmeVfRTh4jfjRvAJdG6rmGRkJDReU7J cWoYOdmM38cUvTqSdDmpQn0dW1wDVnHVp3F5pahcygF3acJ6N1UkRV1bLnQOgKbpy7Z3 Fpz2kCkRSoa9oQloFb94losh2EICPEaNYBgswU5bKTb0hc601L5Gq8iS0cFUmlYY8BHB ejBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ntCMWnr+; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si27738791ilv.67.2021.06.30.18.01.54; Wed, 30 Jun 2021 18:02:37 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ntCMWnr+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238337AbhGABD3 (ORCPT + 99 others); Wed, 30 Jun 2021 21:03:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238285AbhGABDV (ORCPT ); Wed, 30 Jun 2021 21:03:21 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D23C5C0617A8; Wed, 30 Jun 2021 18:00:51 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id h18so2159020qve.1; Wed, 30 Jun 2021 18:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lmky5l0N9TXo0NTQ1YrbAaaRvC+qKWRHhjy6j7fXuAs=; b=ntCMWnr+mb8qqz6COldcm7/FWBgC1yCjxPE+nUWSbipTWh7Or88qx72riHlmwmnYnP q8JKAhCPnGAr+x+1Xh+/ApFRzS0jWq6O8EusTI59s2XJHNAbPfM+WT0wNwTwlvsVQWiI lPer1AZjPb63rVxMMvqChIm94rNhdKWCqYsRg8lNdMLdeSJv3Tkr2xcgNW2wWZqsN5Ik YktpAsTgq+Hw7GLWrkQFXTowubqzSP+pDWy30siSP5xn7W6VcgwRKZrC7YyjQBgxUEZg wMtbEAaMlyHsA/NMYDNCes1EdcWgQG3Su3Gcvas8Vp2xRhLyf6D9BTuO87nj3qs1zGnM 1wOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lmky5l0N9TXo0NTQ1YrbAaaRvC+qKWRHhjy6j7fXuAs=; b=DOqSV3yuUWvYRgLc1pP/yh0vIIoA3UVAvH9T7yCGTwJvlj//sBJS4S+Y9IHUPqfc3R kxG/Qv7CNrs1YJqNl0lhfdVbjpINjYTWBTwICqO+ddodYFOnjwrhVfDPgk0TEOn0z66N qKLovv1stZNsZgz7h/ODY4D+36EEjva8a4nT1YvwcdgCjj4F9qehP+SHQKblAR8VU/KM OypVCSnyPPmKzZGu4GEKGiAkm0DO2wmKW3vLnAUAAqY0Zb6bVnRRloiq6+z97Nw5IOuV gcW8EXKS6DIOWerxIxjbj/csZMgbwuiLN4O5lIEEAhv80h51wheP/lVumaFbOOpicZHC 9/WA== X-Gm-Message-State: AOAM533p7XAZm8psaeSXafVeWshMqJoqx3IHSIAAvVs987HKXnVhDUIC 3Tgm127rzE+d14vMI6rbGCE= X-Received: by 2002:ad4:58d1:: with SMTP id dh17mr35648261qvb.16.1625101251014; Wed, 30 Jun 2021 18:00:51 -0700 (PDT) Received: from shaak.xiphos.ca (198-48-202-89.cpe.pppoe.ca. [198.48.202.89]) by smtp.gmail.com with ESMTPSA id l127sm14087782qkc.64.2021.06.30.18.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 18:00:50 -0700 (PDT) From: Liam Beguin To: liambeguin@gmail.com, peda@axentia.se, jic23@kernel.org, lars@metafoo.de, pmeerw@pmeerw.net Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org Subject: [PATCH v3 05/10] iio: afe: rescale: add INT_PLUS_{MICRO,NANO} support Date: Wed, 30 Jun 2021 21:00:29 -0400 Message-Id: <20210701010034.303088-6-liambeguin@gmail.com> X-Mailer: git-send-email 2.30.1.489.g328c10930387 In-Reply-To: <20210701010034.303088-1-liambeguin@gmail.com> References: <20210701010034.303088-1-liambeguin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + 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: -- 2.30.1.489.g328c10930387