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 A950CC04AB4 for ; Tue, 14 May 2019 17:01:04 +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 7A98F2084A for ; Tue, 14 May 2019 17:01:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Pe2MRVFn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A98F2084A 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=WtxeTDjCutdutlX5cZVALxNciWJfVhjPoLqlTN0rVdU=; b=Pe2MRVFntRUvYM pehnGBqX99gcY4KgNz3bXVdbqCChCWn4qY7iJaFJJrCtDhf5gj9TPpg1qnq0rsgTHwEbCKrXV55Yb IV0iGVBiUdITt2NUfjHtKzP3xvnmZ4eJd/34o5erRAEgfl0Xa97vsJJTEJOQYH6zru0OdpJv+DZBv DiVtRY9QSM8xSusWv2HaVaUQGyKc+Gt5JkmHx/qt+9GdrdHOB6rBtd/tQnw1o/6HUz41i0IZrE4Gh Tc7TS4lEyLPM5r1y5nz7t3xaT0ydfZEF9hY0QxHuSg6AfJ0HG+bExSt68AxTlLyrg8Gsyt17OGlD/ iMeq38bNd+//T3b38qHQ==; 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 1hQanS-0007Mt-8O; Tue, 14 May 2019 17:00:58 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQanP-0007MX-AO for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2019 17:00:56 +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 89FCF374; Tue, 14 May 2019 10:00:54 -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 0F33F3F703; Tue, 14 May 2019 10:00:52 -0700 (PDT) Date: Tue, 14 May 2019 18:00:50 +0100 From: Sudeep Holla To: Guenter Roeck Subject: Re: [PATCH v5 2/2] hwmon: scmi: Scale values to target desired HWMON units Message-ID: <20190514170050.GB20819@e107155-lin> References: <20190508184635.5054-1-f.fainelli@gmail.com> <20190508184635.5054-3-f.fainelli@gmail.com> <20190514163707.GA20819@e107155-lin> <2cbed0ac-fbfc-e66e-7cb9-908478466a34@gmail.com> <20190514165806.GA30274@roeck-us.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190514165806.GA30274@roeck-us.net> 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_100055_365825_0A7B8091 X-CRM114-Status: GOOD ( 19.28 ) 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, Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, 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 Tue, May 14, 2019 at 09:58:06AM -0700, Guenter Roeck wrote: > On Tue, May 14, 2019 at 09:44:02AM -0700, Florian Fainelli wrote: > > On 5/14/19 9:37 AM, Sudeep Holla wrote: > > > 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) ? > > > > Doing an early check for scale == 0 sounds like a good idea,good catch! > > Feel free to amend the patch directly when you apply it. > > > > Ok with me. Just make it == 0 :-). > Thanks Guenter and Florian for quick response, done now. -- Regards, Sudeep _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel