From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B76DBC04AB4 for ; Tue, 14 May 2019 16:37:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 84531205ED for ; Tue, 14 May 2019 16:37:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SZGZ7g/6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84531205ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qYRvK7lhsVWCt5Css92C1DMIUsIUOZoxcQCXTUFZZ3M=; b=SZGZ7g/61yVTef sPhkSzHuaOktSgsKJV8asJSHv1ojOhJ05x8qs0SLfHgn+OdNCS02E0m1IphUPvPVfICGdjBorWr7j tROdjguCyQ9otE+9QdFmL8gLk7tPSmtWintqCZP+ncPHBMkButrBEA3a3AlcHV4EGcLCGPaM8Uglc py4Cv1V8DsF2OBAdQBCPgdevrPht6XK7LKu5mzm81QKKy4PU+6A6D5/1YCZFnQcM65w2znhrgb0xf mV9Vre26w+inwclUloi10EPsOZe3m7rTbuxPF/rZGEVymCJFrCtE/i2ER957j84RJA4wQEPCYnd8T eJcKO8k9Yk6ucYJoj2vg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQaQb-0006b0-20; Tue, 14 May 2019 16:37:21 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQaQX-0006ad-TQ for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2019 16:37:19 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 20D58374; Tue, 14 May 2019 09:37:15 -0700 (PDT) Received: from e107155-lin (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 99D5A3F703; Tue, 14 May 2019 09:37:13 -0700 (PDT) Date: Tue, 14 May 2019 17:37:07 +0100 From: Sudeep Holla To: Florian Fainelli Subject: Re: [PATCH v5 2/2] hwmon: scmi: Scale values to target desired HWMON units Message-ID: <20190514163707.GA20819@e107155-lin> References: <20190508184635.5054-1-f.fainelli@gmail.com> <20190508184635.5054-3-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190508184635.5054-3-f.fainelli@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190514_093717_952616_06D153C1 X-CRM114-Status: GOOD ( 17.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:HARDWARE MONITORING" , Jean Delvare , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Guenter Roeck , Sudeep Holla , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, May 08, 2019 at 11:46:35AM -0700, Florian Fainelli wrote: > If the SCMI firmware implementation is reporting values in a scale that > is different from the HWMON units, we need to scale up or down the value > according to how far appart they are. > > Signed-off-by: Florian Fainelli > --- > drivers/hwmon/scmi-hwmon.c | 45 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > > diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c > index a80183a488c5..2c7b87edf5aa 100644 > --- a/drivers/hwmon/scmi-hwmon.c > +++ b/drivers/hwmon/scmi-hwmon.c > @@ -18,6 +18,47 @@ struct scmi_sensors { > const struct scmi_sensor_info **info[hwmon_max]; > }; > > +static inline u64 __pow10(u8 x) > +{ > + u64 r = 1; > + > + while (x--) > + r *= 10; > + > + return r; > +} > + > +static int scmi_hwmon_scale(const struct scmi_sensor_info *sensor, u64 *value) > +{ > + s8 scale = sensor->scale; > + u64 f; > + > + switch (sensor->type) { > + case TEMPERATURE_C: > + case VOLTAGE: > + case CURRENT: > + scale += 3; > + break; > + case POWER: > + case ENERGY: > + scale += 6; > + break; > + default: > + break; > + } > + I was applying this and wanted to check if we can add a check for scale=0 here and return early here to above the below check and __pow10(0) ? Let me know if you agree. I can fix up. Also I will try to test it on Juno if firmware behaves correctly :) -- Regards, Sudeep _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel