Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp425229pxb; Tue, 1 Feb 2022 03:02:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqrzX+C8WzRdzY85eOyt1yIJEW8ROxzQZQMhdHiLXPEpMGS2REAjKGxoS2Lz3zPevlJxhI X-Received: by 2002:a05:6402:90b:: with SMTP id g11mr19433238edz.56.1643713341869; Tue, 01 Feb 2022 03:02:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643713341; cv=none; d=google.com; s=arc-20160816; b=WgBpeiljRf57bcphnKHAb5QsWEnpBJ1zzI4dhwR1dfjiRxyhRZ0Hd+SNbUDX6sTDLI CPtKv15B85/rGeM/UR3o8Yw6h4eWA5vymAwUQo2dGPGWMQujDMvUGR9NHPGa4IAHM5z6 AtUFOnMggZdlMfXAakaJAIpl0zoC5pH+jMVJmySTnhvI3X8lg35R/r9QsJgPski7E+oD LFDqQVxso2XCufVSLNS2RF8LcECd3FiZLacB90QZ90v5aGefKUq6uxYULLSyjuAIuYIw l31YRHjJysFrjyNikyNFovtW3uq//J6BWejYXkdFEyQf95sqewbG9jyaoz1xjjm9Cy48 umrg== 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=oZB9+RjUHcGrEBPjD/U8YMyBPtBxHiTx27AuwKkfNg0=; b=dPg61EhQPi+HyhjwG7jqTqLhOX3/tvmMRpMYGg9VtYOYZz5NXgC+OMZ7DV/kIKx7Kl 6UrPeXHJ3H+OcLbfzXYLAEplmKVWys4Khqwsvh2+X+GbAYOObPryA9oU/SrEONfJCEmK fb/bAu+DYsKC7G4Uk+iNdvtaSDsYF/FSKbvHQ+UKJJK352t/7ZTFFYUmOyqrGp+aFFEh NAqr5yq+/o4Ue1uGypqKySR1yK6YTQTZGl5tHdK5J02QQvKRrEkduZhRJSPccrmYJuvA wzwygVFzM4l1pqrfFS/aZgZpsQmYgt1giUrYpaDZoQFAZV+lkQT5bZBWJtQHUjdWqca5 YUPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b+4jTzJJ; 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 y13si11623234eda.1.2022.02.01.03.01.57; Tue, 01 Feb 2022 03:02:21 -0800 (PST) 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=20210112 header.b=b+4jTzJJ; 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 S1355591AbiA3QLh (ORCPT + 99 others); Sun, 30 Jan 2022 11:11:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355507AbiA3QL0 (ORCPT ); Sun, 30 Jan 2022 11:11:26 -0500 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 968C7C061753; Sun, 30 Jan 2022 08:11:25 -0800 (PST) Received: by mail-qk1-x731.google.com with SMTP id g145so9948325qke.3; Sun, 30 Jan 2022 08:11:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oZB9+RjUHcGrEBPjD/U8YMyBPtBxHiTx27AuwKkfNg0=; b=b+4jTzJJdbSigDJepW9QHFwAsA97mdbadodDkbe9iY2pFxQTVjL8wlBTCMBfcvXFXP Ie4igs8Zg9ugB+KwKesxG7xiFgNkI3GSzGdep5K5d1WA31gAPRTBStEUUqKwQxjbx2Qq BTDQUzWKgeyazHHwiDPPqWp2uh/JDAaO+Zj/Ars4Z3XhG5pj2vlu3uElLEuAbVdSh9/4 0d3LFMkefo7o1LrJvAeqgxLfucE4xinS6+ygPoXF1f+4UPjdlyL5Q7GRc6k4uqI3/LXr yW75zwHAKQg5sdAKXCzGRu3jKIdOlV9tjwLU8udI5j+SS+Kq6VohCmZWvCopjXH+ZVyC kl5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oZB9+RjUHcGrEBPjD/U8YMyBPtBxHiTx27AuwKkfNg0=; b=GIctDbLJf5hxOTiAtUPel9R80CgxRKd+7mIIxaJwM3saci6sLm/KI2YcmGOmvxORlf wdeUfrbm8dttxsezw6OzpExmbuPduMdO+yEQm+HptMe5aR6KqH5vDUQ3pcNTSsQ8iUJV 3mHe5YjXgbivYESubKzlckW0loNcZksYkfr6+86ddAvBGagB6tLOOnIlTh/nFrpc/hJC /EjWe2XekT9weWSntIIjb++egsNq9xQoAvOt5d9XWmenzHZvH7l+v37Z87poR7j+9UMl 3Pk0/dziofS/v4J0yTtpgfyISgMpLKKNrbheErCndhiVYq4zne41Z1t4bda7F0/yEmzB hRHQ== X-Gm-Message-State: AOAM5315ZzFEH2K5bCG9tojgIxI7EMsTv0HvBZ6kC7Jd3xVwnLxX0VCy ckMBpAHG4TbKLaORm7p9RpE= X-Received: by 2002:a05:620a:1790:: with SMTP id ay16mr10763124qkb.330.1643559084766; Sun, 30 Jan 2022 08:11:24 -0800 (PST) Received: from shaak.. (modemcable055.92-163-184.mc.videotron.ca. [184.163.92.55]) by smtp.gmail.com with ESMTPSA id v73sm6906148qkb.51.2022.01.30.08.11.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 08:11:24 -0800 (PST) From: Liam Beguin To: liambeguin@gmail.com, peda@axentia.se, jic23@kernel.org, andy.shevchenko@gmail.com, lars@metafoo.de Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org Subject: [PATCH v13 06/11] iio: afe: rescale: make use of units.h Date: Sun, 30 Jan 2022 11:10:56 -0500 Message-Id: <20220130161101.1067691-7-liambeguin@gmail.com> X-Mailer: git-send-email 2.35.1.4.g5d01301f2b86 In-Reply-To: <20220130161101.1067691-1-liambeguin@gmail.com> References: <20220130161101.1067691-1-liambeguin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make use of well-defined SI metric prefixes to improve code readability. Signed-off-by: Liam Beguin --- drivers/iio/afe/iio-rescale.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c index 67273de46843..27c6664915ff 100644 --- a/drivers/iio/afe/iio-rescale.c +++ b/drivers/iio/afe/iio-rescale.c @@ -51,11 +51,11 @@ int rescale_process_scale(struct rescale *rescale, int scale_type, } fallthrough; case IIO_VAL_FRACTIONAL_LOG2: - tmp = (s64)*val * 1000000000LL; + tmp = (s64)*val * GIGA; tmp = div_s64(tmp, rescale->denominator); tmp *= rescale->numerator; - tmp = div_s64_rem(tmp, 1000000000LL, &rem); + tmp = div_s64_rem(tmp, GIGA, &rem); *val = tmp; if (!rem) @@ -71,7 +71,7 @@ int rescale_process_scale(struct rescale *rescale, int scale_type, *val2 = rem / (int)tmp; if (rem2) - *val2 += div_s64((s64)rem2 * 1000000000LL, tmp); + *val2 += div_s64((s64)rem2 * GIGA, tmp); return IIO_VAL_INT_PLUS_NANO; case IIO_VAL_INT_PLUS_NANO: @@ -332,8 +332,8 @@ static int rescale_current_sense_amplifier_props(struct device *dev, * gain_div / (gain_mult * sense), while trying to keep the * numerator/denominator from overflowing. */ - factor = gcd(sense, 1000000); - rescale->numerator = 1000000 / factor; + factor = gcd(sense, MEGA); + rescale->numerator = MEGA / factor; rescale->denominator = sense / factor; factor = gcd(rescale->numerator, gain_mult); @@ -361,8 +361,8 @@ static int rescale_current_sense_shunt_props(struct device *dev, return ret; } - factor = gcd(shunt, 1000000); - rescale->numerator = 1000000 / factor; + factor = gcd(shunt, MEGA); + rescale->numerator = MEGA / factor; rescale->denominator = shunt / factor; return 0; -- 2.35.1.4.g5d01301f2b86