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 934CB2236EB; Tue, 30 Sep 2025 15:12:30 +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=1759245150; cv=none; b=AAxSq080tC0v0e+52QhS+ErbVBtmgkDwKqSqbYKWaxBVgL2ORYnzJHj6ivnOIJ6HPqcKKp5jXOLaTnyhc3MEmyz5DAc3P+aDkRvv1qOhUndqF9Btgat/yKWz9XvLOykFpBca2P103beOUWswTbiHBcdOMmaJFBEUk9JrlBawWec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759245150; c=relaxed/simple; bh=1LaO4BwljlRwAk43xzUaStEkVITr7CsoNb1qQeewhRU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IZgpFJ2O7XadG3Qt5WOeA2pJTBtHxtFmdRZzhbznpRyXw60r7gqwCSO1N4qUTjPpjdHicfHSgHZMARAuPmQQ4K+smxFo7g77eY69J7kxVgRR2WfPq56h2fvf6X4lqKXE/sAfYfZxjG30Xdp27g2gDxlONsKnLIgkRbq5STJYPGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=q1bZYbbA; 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="q1bZYbbA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F203C4CEF0; Tue, 30 Sep 2025 15:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1759245150; bh=1LaO4BwljlRwAk43xzUaStEkVITr7CsoNb1qQeewhRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q1bZYbbAP6jE/59fpv8anQeprNKPmjSiPFSfNENCX+cNRvnf3LjHbr8ka7mOEG6p2 z75ZAVHH+7No2/HHZn7WPOAyqSrqu20ocbstQ+A0VF2qNPISE39dPLMRmVLCP6tkkS gPoitX69hSNpqwybatloAJltlARB7rre2V7x39hw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jerry Lv , "H. Nikolaus Schaller" , Sebastian Reichel Subject: [PATCH 5.15 079/151] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery Date: Tue, 30 Sep 2025 16:46:49 +0200 Message-ID: <20250930143830.739604928@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250930143827.587035735@linuxfoundation.org> References: <20250930143827.587035735@linuxfoundation.org> User-Agent: quilt/0.69 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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: H. Nikolaus Schaller commit 2c334d038466ac509468fbe06905a32d202117db upstream. Since commit commit f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy") the console log of some devices with hdq enabled but no bq27000 battery (like e.g. the Pandaboard) is flooded with messages like: [ 34.247833] power_supply bq27000-battery: driver failed to report 'status' property: -1 as soon as user-space is finding a /sys entry and trying to read the "status" property. It turns out that the offending commit changes the logic to now return the value of cache.flags if it is <0. This is likely under the assumption that it is an error number. In normal errors from bq27xxx_read() this is indeed the case. But there is special code to detect if no bq27000 is installed or accessible through hdq/1wire and wants to report this. In that case, the cache.flags are set historically by commit 3dd843e1c26a ("bq27000: report missing device better.") to constant -1 which did make reading properties return -ENODEV. So everything appeared to be fine before the return value was passed upwards. Now the -1 is returned as -EPERM instead of -ENODEV, triggering the error condition in power_supply_format_property() which then floods the console log. So we change the detection of missing bq27000 battery to simply set cache.flags = -ENODEV instead of -1. Fixes: f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy") Cc: Jerry Lv Cc: stable@vger.kernel.org Signed-off-by: H. Nikolaus Schaller Link: https://lore.kernel.org/r/692f79eb6fd541adb397038ea6e750d4de2deddf.1755945297.git.hns@goldelico.com Signed-off-by: Sebastian Reichel Signed-off-by: Greg Kroah-Hartman --- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -1873,7 +1873,7 @@ static void bq27xxx_battery_update_unloc cache.flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag); if ((cache.flags & 0xff) == 0xff) - cache.flags = -1; /* read error */ + cache.flags = -ENODEV; /* read error */ if (cache.flags >= 0) { cache.temperature = bq27xxx_battery_read_temperature(di); if (di->regs[BQ27XXX_REG_TTE] != INVALID_REG_ADDR)