From patchwork Tue Sep 29 10:59:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 291005 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=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 97CE6C4727C for ; Tue, 29 Sep 2020 11:58:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55886206DB for ; Tue, 29 Sep 2020 11:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601380728; bh=ie++nir9f+2nD4AZK2bbGTkmWoKC3p+A/hsee9XYrIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UbHZOcXIBuHJQHbX1ZLVilUyOqMtC+ODDTVHczuFD7YJ8nkATjNAUo26Tfyj0nGPw 5HIHexURkGBWt+UT+u3eAZWsEg2JUrQ/EBaMJV7EgoDUoTMCnikjNtNNRCynLLC5B8 nziTddjVLhYru8myPutaYhPQaTQSWAzou7TRp7n4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731634AbgI2L6r (ORCPT ); Tue, 29 Sep 2020 07:58:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:38492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730349AbgI2Lll (ORCPT ); Tue, 29 Sep 2020 07:41:41 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E2EB62083B; Tue, 29 Sep 2020 11:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379700; bh=ie++nir9f+2nD4AZK2bbGTkmWoKC3p+A/hsee9XYrIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0e+L0QKq5zmvXdPbaDP6bFIhUPjChpuUb6rbrcPIY2A5cwG989qMbObYgcpkGRoc g9x90OM8qNVsX74y9QonU3gqsYBde+qFbFPljSua0V5dGW4QptizaWgrfaB4akm/XK eL1zoCOF50xh2qczETYdShaKAJgmGitfsDk9l1D0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Bakker , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.4 252/388] power: supply: max17040: Correct voltage reading Date: Tue, 29 Sep 2020 12:59:43 +0200 Message-Id: <20200929110022.681056757@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Bakker [ Upstream commit 0383024f811aa469df258039807810fc3793a105 ] According to the datasheet available at (1), the bottom four bits are always zero and the actual voltage is 1.25x this value in mV. Since the kernel API specifies that voltages should be in uV, it should report 1250x the shifted value. 1) https://datasheets.maximintegrated.com/en/ds/MAX17040-MAX17041.pdf Signed-off-by: Jonathan Bakker Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/max17040_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index 62499018e68bf..2e845045a3fc0 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -105,7 +105,7 @@ static void max17040_get_vcell(struct i2c_client *client) vcell = max17040_read_reg(client, MAX17040_VCELL); - chip->vcell = vcell; + chip->vcell = (vcell >> 4) * 1250; } static void max17040_get_soc(struct i2c_client *client)