Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4791211pxv; Tue, 6 Jul 2021 09:12:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweKkJrpaSvH0aPbpdB+O3ZbbFCjVV6tcQDsPISX6Qowci/7sAjc6tQ4zB2A6b4KZMHsetz X-Received: by 2002:aa7:cf91:: with SMTP id z17mr24179385edx.112.1625587978094; Tue, 06 Jul 2021 09:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625587978; cv=none; d=google.com; s=arc-20160816; b=sZZ4SIg6dValk8N64dpXMo3WmE8pvtAGAYuBqEFNmuI08TLIkLQ1NrOI450eZ13GcF 74SLzRhS2b0nWn6HdpbWAr5Sn48zGIz6Rjx6XScTK9rwNoeL94rACZaPR9iQBKNOiR7k /wO3uNiQ1lKLnSpi+wEQcoJliX9ccdHZEyE8FGggUOQR2/IJfyy6jSWHVHsZS98lIrgS HAFA12YPTy/gySwV4JAnkyyps4dtCsI7/+NX9z8MKFgAmjZ+d5GH9q4Rbc8KKbM/nw0z tJseif64WWlm2M/TJzzv3WLbZZjImsCD4cmEkZk5LTlthRcPQqQAcvmpclEQNGzeHHkF GqqA== 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=zI0GRZjgYwyGyT21DHgJgd9yo+nslisk5YT0YJaOSJg=; b=QVRVY4aYXeeg4z4lkGW7zUVpBtCbDcZTq9zpr/jMdZQ9OtDuV/ovlOJo9TtkCyiWUJ pA3DCwWUifMRBAeoseEXgbLK/383GIDQLjphbjvnyBy0klEteuSgpLAB1kCJh4uwBp0v 9UBnxoEcTeDwVoYvGPnalk5DSKWeAqeKD3WkAB29O/ZiMPoOvzEJ4FIizxchOlje43Nu d/bd4CcPsekRJSWtNjrNX0GfN416hIIq78cch0LlWDYqsulCOBko6GTvx43PDoSi5ORC d3k3GYfqNy3RLFYCdcvWFouY3egyN41Wck26OFLitsA+jrsuc8MY3Da8VvzpWyeL8c1m o5rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CV7UzfOr; 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 e12si15538754ejy.258.2021.07.06.09.12.33; Tue, 06 Jul 2021 09:12:58 -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=CV7UzfOr; 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 S230333AbhGFQNE (ORCPT + 99 others); Tue, 6 Jul 2021 12:13:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbhGFQMi (ORCPT ); Tue, 6 Jul 2021 12:12:38 -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 86111C061766; Tue, 6 Jul 2021 09:09:54 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id h18so10012165qve.1; Tue, 06 Jul 2021 09:09:54 -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=zI0GRZjgYwyGyT21DHgJgd9yo+nslisk5YT0YJaOSJg=; b=CV7UzfOrE0x12545yuQpUUo87//GT87T/tKj7Pclrg3Zf+dpmQaZlQQc5sHh0S1FjP H++bsf3k+bq/je1yRicDjWax4dRzbvxplBNfe+215Ers4FV+AeMx/jcDzwI5tiV3VxGT QrZj9sKywQmQuhkmPsXYxRSoRkJ32FbVXIFPoY2p9jkwKpXZRCG7+xxY8S+wixYS1R5Y +lGa0zeUzXVBcOF5ZDnvXzVOsS38HRh94cZba+pgsqLt50eG7na82/GoyNUErzlehByh sd0D4cFdbi8fs0Pe7CGJcCfBGCgIq7FFYvokoKsPnnR2dPFdhrhpU7haBZ0x4ghM+p1Z a92Q== 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=zI0GRZjgYwyGyT21DHgJgd9yo+nslisk5YT0YJaOSJg=; b=jXm0aIcVkTf4fayK4QysDBMXcd1e0Q36h1e0nMXkXZEDV+Ii+vtaX22zsXbWZmE4aB Y1FeB/svyy4w3gdUSqrJq6Q5la+NI0Hx8xBRJX1J8lTpcTRmpSUV2IDa8hajmlqoCntY pjrneaLTC1hSslj3NhXyrN3KA+SaavP5IATPL85N3uomcfoWginS0i8EKjZGqkrXh9cf jruytCRoUKkSOacZJJeeIgz2GKmXWyIlttAriZwc1G5gRws8MnCj1MrJ68/QXDx4DHOl 9Oew/R02Wu3aAxRdvO1U2FRUT+O4HkSdL33sAds1ALmdkgRKywT+nXZ4/wz2iUeBYkzw meGw== X-Gm-Message-State: AOAM533InsuZk3JqQ2Mwdsf2g9poXVD2EQs7orrLSKUAQAspyDwiYcxN HShVzpB/wZmKSf2kz1BBsgk= X-Received: by 2002:a0c:a90b:: with SMTP id y11mr6273129qva.28.1625587793796; Tue, 06 Jul 2021 09:09:53 -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 n64sm6995371qkd.79.2021.07.06.09.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 09:09:53 -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 v4 05/10] iio: afe: rescale: add INT_PLUS_{MICRO,NANO} support Date: Tue, 6 Jul 2021 12:09:37 -0400 Message-Id: <20210706160942.3181474-6-liambeguin@gmail.com> X-Mailer: git-send-email 2.30.1.489.g328c10930387 In-Reply-To: <20210706160942.3181474-1-liambeguin@gmail.com> References: <20210706160942.3181474-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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c index ba3bdcc69b16..1d0e24145d87 100644 --- a/drivers/iio/afe/iio-rescale.c +++ b/drivers/iio/afe/iio-rescale.c @@ -89,7 +89,15 @@ static int rescale_read_raw(struct iio_dev *indio_dev, do_div(tmp, 1000000000LL); *val = tmp; return ret; + case IIO_VAL_INT_PLUS_NANO: + 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