From patchwork Tue May 7 19:35:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10933697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC46114B6 for ; Tue, 7 May 2019 19:38:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABBBE24B44 for ; Tue, 7 May 2019 19:38:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D6232870E; Tue, 7 May 2019 19:38:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B62D126246 for ; Tue, 7 May 2019 19:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbfEGTiR (ORCPT ); Tue, 7 May 2019 15:38:17 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:45450 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbfEGTiQ (ORCPT ); Tue, 7 May 2019 15:38:16 -0400 Received: by mail-pl1-f195.google.com with SMTP id a5so3735587pls.12; Tue, 07 May 2019 12:38:16 -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; bh=E3cy6coJyOOa2SbBo8UlxqrSWJcV9cpYsmbojY6zx78=; b=PdeQdBMH+PUZqj2w9dPXVinwmbVbRY3710/zgoNzmgAAwN1AnPnO68PuvRcTOgHdGC ztkUdxZHXvkX6BHIg+H4erw9aGn9DaxXx3diAqZuf3ThTXCSBbfcYT9mckVk1F/RYBI8 vFPjklCNJW2gmPY9EZSVJmdZO9xxOEsViODA/+Fdy7FjBpKFZi24JMxqOjXFmoBz7vSW AFnR5jMbkNZSEt6tRcevkk0cRRxTwksw0LKr9AldUi8bxRDcLXAQ9LB9PRwx/wLbZzk0 zVGxm/MEOKDNF91YJVNk+Ofsq89/gAt68fo76RXVPNxH40O5HAn2CUzUrYt86PSyg7rt FSog== 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; bh=E3cy6coJyOOa2SbBo8UlxqrSWJcV9cpYsmbojY6zx78=; b=BX9+KgiOhr/qvEWNzxyrTsTp+Gwmx5H1wYg2lIv0KeYOVNFkojB8cvbK/6M1j3RkzL mPWpRFxuf1h6UMh9UDkq+L+zB/BAVvGP+dUBZEKb5ceE8iYS5PlQrjufzOPm2ZwPEOHv P5379z8Mj+O008DXTenFPWumAHP9XRwipIV5v5/XkDLwNxBuzQgbE2qmOp/oyMWMe9VG zrH5yu9onqjD1dnKTBPWqKfPtpLkTyH59kMnZ3w38Tp/SZ/eB//YDAHdkyG3OAkm4ufg AsoPoS9Qp9577RVghuXf+/x2QLcirafcXhQz4XItn6QMkZ7TDSXDrzNNlJhZpGyCvYVS fVXw== X-Gm-Message-State: APjAAAUshBVqv/LqBb7IZkvF4joy7CfWAStxNlhHL4BeQ0iFO89tSWcR +xxJjqYKWvr1rtmgfPN2XYLt54xn X-Google-Smtp-Source: APXvYqwSKFH3OcPH0UwFlrAn9EVBXhRUaujmIGC6dieqwuOP4POjIFzGh4hKO76fOOfeE/bNAObGkg== X-Received: by 2002:a17:902:8a81:: with SMTP id p1mr42323974plo.106.1557257895759; Tue, 07 May 2019 12:38:15 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id l21sm5964658pff.40.2019.05.07.12.38.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2019 12:38:14 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: Florian Fainelli , Sudeep Holla , Jean Delvare , Guenter Roeck , linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), bcm-kernel-feedback-list@broadcom.com Subject: [PATCH v2 1/3] kernel: Provide a __pow10() function Date: Tue, 7 May 2019 12:35:02 -0700 Message-Id: <20190507193504.28248-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190507193504.28248-1-f.fainelli@gmail.com> References: <20190507193504.28248-1-f.fainelli@gmail.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Provide a simple macro that can return the value of 10 raised to a positive integer. We are going to use this in order to scale units from firmware to HWMON. Signed-off-by: Florian Fainelli --- include/linux/kernel.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 2d14e21c16c0..62fc8bd84bc9 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -294,6 +294,17 @@ static inline u32 reciprocal_scale(u32 val, u32 ep_ro) return (u32)(((u64) val * ep_ro) >> 32); } +/* Return in f the value of 10 raise to the power x */ +#define __pow10(x, f)( \ +{ \ + typeof(x) __x = abs(x); \ + f = 1; \ + while (__x--) \ + f *= 10; \ + f; \ +} \ +) + #if defined(CONFIG_MMU) && \ (defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)) #define might_fault() __might_fault(__FILE__, __LINE__)