Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8239279ybi; Tue, 23 Jul 2019 05:16:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6eRhyE//Yz6MbCwq30J679tIHl8rAmPQvA9CMEz92K18A8MCjcWrDCuWBzshDr8JRrV6q X-Received: by 2002:a63:3147:: with SMTP id x68mr12325695pgx.212.1563884167996; Tue, 23 Jul 2019 05:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563884167; cv=none; d=google.com; s=arc-20160816; b=iEqoubEbjWXKOwZKcmon1BJvYULpGJbwUdbggCSVNTlpFjTgcrQhxSHQW7oL0i4wzY hyb6t08oAQEY6OcaaUCmXMh5/dvl7KjSORK5qmQmSIOIBXn6mew1VtL25GfSGgSX9tVR uRa2y+HDDw72jvsENxlsmmlBxYI4oEGCYdNMpczelxUklksms9a1Lu/VEH3bByld5j/n oXnGu2KA2DcAf5iInt2MmHEaU6QFmmwXU2ZiaHuUqKtGsQevu/+UoFbLfKqYWf/lAKLt MPSU45Q6pftLv7DH3ESRlF78/SQHyOq5nRqsXKIi3sjVZRXr6vr4eBhtA8yDpx+LA2sw jwDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fL5yem8QsUYkhZu+Pm1PTITp0l+jVscmMyZeS34IKsQ=; b=dHQmVLJHBp91aWOU/J/df65zPgeigoLQxlCQMTAY4Pk7L6AptRbv/vmgPEYzYUqdIb ItA0kmFjPQkLMVmoNda0GF67W69pHgD2+64GnqhFqAkUP2DFe/MCPdVDO4A9N6uDRMUu Yg6RinOlMDBZ8aTwxKew37TTtgbUp+MBTAXKJF/Wfw+I4BH2y5DWZYeUQrYdyd+Czumi N06frCNdsm+m6samPGa3w8o0/CLh09Z4C7j1e7oNmkuXoVPskdSZLkImvNRbzEAmHaTP GWuMVOQSx5YzHWvyntOcz6Ob1k/WZLhYjtxlSwASn8jLOYlrraJWNIfbe2P7NYSC96xR K5kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="Vb/+i3os"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si11950083pff.164.2019.07.23.05.15.51; Tue, 23 Jul 2019 05:16:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="Vb/+i3os"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731960AbfGWCqK (ORCPT + 99 others); Mon, 22 Jul 2019 22:46:10 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:55728 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbfGWCqH (ORCPT ); Mon, 22 Jul 2019 22:46:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1563849964; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=fL5yem8QsUYkhZu+Pm1PTITp0l+jVscmMyZeS34IKsQ=; b=Vb/+i3osY1n11LJAcDyhzXABp5jCqHMJnOUEKjZWHUDZvGxGJ2U0beZdgw+/ZVudnMkOqj SNYVPb1fNyl6K0KobhTaETLyhYaPad9d45FiPrzttvGZ5gcJXjbR04sYj4ZNk6ULQTtdcP Rx9jzBniH4E0gGStjD/mTqxvcwloR5Q= From: Paul Cercueil To: Sebastian Reichel Cc: od@zcrc.me, Artur Rojek , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil , stable@vger.kernel.org Subject: [PATCH] power/supply: ingenic-battery: Don't change scale if there's only one Date: Mon, 22 Jul 2019 22:45:54 -0400 Message-Id: <20190723024554.9248-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ADC in the JZ4740 can work either in high-precision mode with a 2.5V range, or in low-precision mode with a 7.5V range. The code in place in this driver will select the proper scale according to the maximum voltage of the battery. The JZ4770 however only has one mode, with a 6.6V range. If only one scale is available, there's no need to change it (and nothing to change it to), and trying to do so will fail with -EINVAL. Fixes commit fb24ccfbe1e0 ("power: supply: add Ingenic JZ47xx battery driver.") Signed-off-by: Paul Cercueil Cc: stable@vger.kernel.org --- drivers/power/supply/ingenic-battery.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/power/supply/ingenic-battery.c b/drivers/power/supply/ingenic-battery.c index 35816d4b3012..5a53057b4f64 100644 --- a/drivers/power/supply/ingenic-battery.c +++ b/drivers/power/supply/ingenic-battery.c @@ -80,6 +80,10 @@ static int ingenic_battery_set_scale(struct ingenic_battery *bat) if (ret != IIO_AVAIL_LIST || scale_type != IIO_VAL_FRACTIONAL_LOG2) return -EINVAL; + /* Only one (fractional) entry - nothing to change */ + if (scale_len == 2) + return 0; + max_mV = bat->info.voltage_max_design_uv / 1000; for (i = 0; i < scale_len; i += 2) { -- 2.21.0.593.g511ec345e18