From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8848F19EEBD; Thu, 15 Aug 2024 13:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723729068; cv=none; b=WtxpYgEDe6jdMg9aaIGUMBEN16DJPa8YATY1rNZyLmfZBPAJ2jFXljm39wECw/TVH8NK4sfTx/2J5/YX8pmJxhlHMVjRYMSd1e36p6SjkDZJmKY1hB5m5b4PbmQmJLFzwpDkTN5B3ooQwbX+uYGi7d53nxQ+VcELfSli4WCztb0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723729068; c=relaxed/simple; bh=WGPJmj0nZGcWLa/18yMJFENo804x+skNtPqy7jzZEZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oLWlOkq2QZS1jwUT/XNs9p5McwQXxdWNKJyR0ZODnPu4KMmsgYXd5zxceQjGZoYsJIyNl18b+S//kLv+viGUem7I17mYrQyJKuoxnPnJy5HuRfoyLcsTsish4DNHd2aC60g0U61jKfhxpOE4CEXLMZgnH0GDbTMNsWuTvYVPm10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=syIIxpuw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="syIIxpuw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04E3CC32786; Thu, 15 Aug 2024 13:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723729068; bh=WGPJmj0nZGcWLa/18yMJFENo804x+skNtPqy7jzZEZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=syIIxpuwoV4O2ybT3WBimGWlwXw6DJVsXJRh+6LCRSFGZ+c3qvg3A1wyP32KAhW2D qcWUkpqDR7ncoCZi2pzej8A4o8uy/JDOOM2I6Yf/JZNxOZdJOFbD/xPvXlWg6Vb4ob EfVTlHkqTD4zBKor6CVCuq35j+YC+Vu5uiWLNNqE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hans de Goede , Sebastian Reichel Subject: [PATCH 4.19 183/196] power: supply: axp288_charger: Round constant_charge_voltage writes down Date: Thu, 15 Aug 2024 15:25:00 +0200 Message-ID: <20240815131859.072191603@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240815131852.063866671@linuxfoundation.org> References: <20240815131852.063866671@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans de Goede commit 81af7f2342d162e24ac820c10e68684d9f927663 upstream. Round constant_charge_voltage writes down to the first supported lower value, rather then rounding them up to the first supported higher value. This fixes e.g. writing 4250000 resulting in a value of 4350000 which might be dangerous, instead writing 4250000 will now result in a safe 4200000 value. Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20240717200333.56669-2-hdegoede@redhat.com Signed-off-by: Sebastian Reichel Signed-off-by: Greg Kroah-Hartman --- drivers/power/supply/axp288_charger.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -175,18 +175,18 @@ static inline int axp288_charger_set_cv( u8 reg_val; int ret; - if (cv <= CV_4100MV) { - reg_val = CHRG_CCCV_CV_4100MV; - cv = CV_4100MV; - } else if (cv <= CV_4150MV) { - reg_val = CHRG_CCCV_CV_4150MV; - cv = CV_4150MV; - } else if (cv <= CV_4200MV) { + if (cv >= CV_4350MV) { + reg_val = CHRG_CCCV_CV_4350MV; + cv = CV_4350MV; + } else if (cv >= CV_4200MV) { reg_val = CHRG_CCCV_CV_4200MV; cv = CV_4200MV; + } else if (cv >= CV_4150MV) { + reg_val = CHRG_CCCV_CV_4150MV; + cv = CV_4150MV; } else { - reg_val = CHRG_CCCV_CV_4350MV; - cv = CV_4350MV; + reg_val = CHRG_CCCV_CV_4100MV; + cv = CV_4100MV; } reg_val = reg_val << CHRG_CCCV_CV_BIT_POS;