Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3424BC7619A for ; Fri, 17 Mar 2023 22:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230476AbjCQW51 (ORCPT ); Fri, 17 Mar 2023 18:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbjCQW5O (ORCPT ); Fri, 17 Mar 2023 18:57:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 552582CFD4; Fri, 17 Mar 2023 15:57:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E656160C24; Fri, 17 Mar 2023 22:57:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 280B8C433AC; Fri, 17 Mar 2023 22:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679093831; bh=35QN0bzeY/9nc3m2KusNIkEd3B6r2Kv+UZyBrvNelB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XroeiJggFWszgmfFVVEXYbBrzIRHfECFxjMs2w28Sj2STSKCUJojBh/zh/4PhLqOH nN3kx9KQHZB6Ygi733MTNgsQPK4AX9rP4fQG6LwtcQ/FO2TQr+gnbih4m4I5SDevRK U5sGrfdHvDJTWhtX9pbkKIs2RUYVsflsEAuLkL7JS9bdOBbB5N1b5jQdKYU8UjkmxF 6e6Ec9XaouP7PqySQMeVQTYBIF2AC8F9k+yWCQf0m6DG4MeFOtqF6uvGiwyPcvt3it OUWuEpY2iyHHga+pyWUm0ILGprt5OyKfvyWQARFWG+lfDi5UtEQNS23amHagBtG7So t8wX4950hqyfg== Received: by mercury (Postfix, from userid 1000) id 8B01A1062104; Fri, 17 Mar 2023 23:57:08 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel Cc: Linus Walleij , Matti Vaittinen , Rob Herring , Krzysztof Kozlowski , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCHv3 04/14] power: supply: generic-adc-battery: fix unit scaling Date: Fri, 17 Mar 2023 23:56:57 +0100 Message-Id: <20230317225707.1552512-5-sre@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317225707.1552512-1-sre@kernel.org> References: <20230317225707.1552512-1-sre@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org power-supply properties are reported in µV, µA and µW. The IIO API provides mV, mA, mW, so the values need to be multiplied by 1000. Fixes: e60fea794e6e ("power: battery: Generic battery driver using IIO") Reviewed-by: Linus Walleij Reviewed-by: Matti Vaittinen Signed-off-by: Sebastian Reichel --- drivers/power/supply/generic-adc-battery.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c index 917bd2a6cc52..535972a332b3 100644 --- a/drivers/power/supply/generic-adc-battery.c +++ b/drivers/power/supply/generic-adc-battery.c @@ -136,6 +136,9 @@ static int read_channel(struct gab *adc_bat, enum power_supply_property psp, result); if (ret < 0) pr_err("read channel error\n"); + else + *result *= 1000; + return ret; } -- 2.39.2