From patchwork Tue Sep 29 11:00:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 262924 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 DBDCCC4727F for ; Tue, 29 Sep 2020 12:38:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95D892076A for ; Tue, 29 Sep 2020 12:38:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601383094; bh=yj/lYPazjcLxTYPDL2xayjRqc9FZe9CiFPn3FykP1nQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Rvwb6/A7GukgMDlnAimuhs7gqZ/aTovXBRjVLsK+VY/FQ1NLSaMT41HdMWvbaUonK 5pGg47qSiCqI9nuN8wvJ46McJSzrfrW9nt0M9zMCPgRKCldYGklQNrZLMr5Xs/AKMi Ibxu70nFrkHNaYR69dpkX/l46/58/92MqRvDOo8s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733231AbgI2MiN (ORCPT ); Tue, 29 Sep 2020 08:38:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:34310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728783AbgI2LR1 (ORCPT ); Tue, 29 Sep 2020 07:17:27 -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 1BEE8206A5; Tue, 29 Sep 2020 11:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378246; bh=yj/lYPazjcLxTYPDL2xayjRqc9FZe9CiFPn3FykP1nQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2HulgX1x78HrRo/58cvcCT07BfD9xNCGJUUgbFNXt4hMuxNiJf1UbTKdP7MRLjsPN O2yUz9tPx1552ip1KZdW06+cFKpUbgF9MMHK4eafWbm0jbPVCodiXv0li2B5XHqjp/ ncbfeDip24M8y/nLqQMLGsCcJCu/lnfnhVp6Gxog= 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 4.14 112/166] power: supply: max17040: Correct voltage reading Date: Tue, 29 Sep 2020 13:00:24 +0200 Message-Id: <20200929105940.791432575@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105935.184737111@linuxfoundation.org> References: <20200929105935.184737111@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 33c40f79d23d5..2c35c13ad546f 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -109,7 +109,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)