From patchwork Fri Sep 13 08:45:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Lv X-Patchwork-Id: 828556 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2069.outbound.protection.outlook.com [40.107.22.69]) (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 6020F1BB6B3; Fri, 13 Sep 2024 08:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726217301; cv=fail; b=pDvDLdWzeE0Xr+IPToszMhXZSwehpYvwWwxbptqj0gVnDy27CvxGxKiaTXNG68ouH3JOGsRQHj+oq+DfO4xwqtFeDIPsk1QxTDY5NUI1tdiwaMQninWkUqsKvrNIGxJ8AjNInZlquMHSf5H+bTGzNgr1f03eynTiTxB2kUOuI9A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726217301; c=relaxed/simple; bh=m/ILB8DzZMboxn48dqsd4WnsLVP+wVpzYj5F5I7Cj4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:To:CC; b=tbAKST2RuqB4vDW6rJ7Oc5z2SrJKuFouAqPu6lkpuJ5MZ/0HU8VhwnGUn5A6ui2YpMkJibf/xz0Tj/3pcZkJCjplvRWsPHMvgL+GCRwxdtsu3OmSCsSIB5izuAWdRtGVrZQsFejfknOuJczOIFS0Uc/ySNwiZmSbVq1pBrNhSKw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=axis.com; spf=pass smtp.mailfrom=axis.com; dkim=pass (1024-bit key) header.d=axis.com header.i=@axis.com header.b=VwOUYc92; arc=fail smtp.client-ip=40.107.22.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=axis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=axis.com header.i=@axis.com header.b="VwOUYc92" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bPMd1Z+SVfr4ca2QwxOWYwa84780+0JNa/6RGEt1JZeomXAsfhDv3YshwThgKJ1AdJFB5kmd706TjAvDsQVx6okXnDgAE8hAjAXeaGgiz8Yxtze2KcZPv1ifcUFbVDWaRRs1D7MXdjgtHci2DR/6m/PxCtKD9Ih5fiCoPEbLSjQz53VszcSpI4BcvAr25K49fkTYlGiytw85AAwgOFbZ+Azc/2MpCMEIMH7PMkDJOu/Hck70KqVkFrSkPYugTI4nSQqNcrT9ppuPGz/fGNEkLHCMGnkf1u7zpaopHuV4D+KRO+UIeMcFZWU26iXOvNIuWKHqJKoSvpMVsErLhjEZpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IrX2Ho5mvjXexsbTMn47/uCAzLbzn4Z7AkV+yNsI30U=; b=yBPbWxrpuSC22v0RRYQs4vvbPQ6qQIRR+YUcb1Uzs6p/20QTLXDbZMz/jbz8KtUieyukbO6BfjlS9rTYtPoIxYf8R9vxye8XalCuk14XlccaYgwSRhWn6b+bX7aWX/Hq9IvUSlot291/0wptONY41VDgdyfZb9XhF6zeKe/vFfGO7TnP1ngC2NbDCzORUw1a3HD1EHQbAOAi2BDQg6+q+yz7g4EXe7A69QBsJkm5nADhbCT6XQTbYLZXntC7cj+z19QBpssqR87M8jfuKCC281raoE+/FraaoApN7IdvYhhnp7tplmh6U0vWGKIgpdryLDIOljyvmhl1uczHoiRFOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=kernel.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IrX2Ho5mvjXexsbTMn47/uCAzLbzn4Z7AkV+yNsI30U=; b=VwOUYc92cb9OAbnoJ6Au3e65UKGZTTRcububCGxCP8F9e8csvB7VE5XTcleudyLRjJkuTGhcI+B34mVqqyLHQaVocuJmpueLzgfBPcL90aCx2z7gXWFcMz7f5898runNfm5DRx/Qr5x+Nrjgz9K0pvK+Man96Bh3JaT2YXxqxe8= Received: from AS9PR06CA0569.eurprd06.prod.outlook.com (2603:10a6:20b:485::33) by DB9PR02MB6810.eurprd02.prod.outlook.com (2603:10a6:10:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.19; Fri, 13 Sep 2024 08:48:14 +0000 Received: from AMS1EPF00000044.eurprd04.prod.outlook.com (2603:10a6:20b:485:cafe::fd) by AS9PR06CA0569.outlook.office365.com (2603:10a6:20b:485::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25 via Frontend Transport; Fri, 13 Sep 2024 08:48:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by AMS1EPF00000044.mail.protection.outlook.com (10.167.16.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 08:48:13 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 13 Sep 2024 10:48:10 +0200 Received: from se-intmail02x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Fri, 13 Sep 2024 10:48:10 +0200 Received: from pc4cv4203v8f.sh.cn.axis.com (pc4cv4203v8f.sh.cn.axis.com [192.168.77.92]) by se-intmail02x.se.axis.com (Postfix) with ESMTP id A34CF10F; Fri, 13 Sep 2024 10:48:10 +0200 (CEST) Received: by pc4cv4203v8f.sh.cn.axis.com (Postfix, from userid 12715) id DA5466B1EE; Fri, 13 Sep 2024 16:48:09 +0800 (CST) From: Jerry Lv Date: Fri, 13 Sep 2024 16:45:37 +0800 Subject: [PATCH] power: supply: bq27xxx_battery: Do not return ENODEV when busy Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240913-foo-fix2-v1-1-a0f499404f3a@axis.com> X-B4-Tracking: v=1; b=H4sIALD742YC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDS0Nj3bT8fN20zAoj3USDFHPLlCQLs0SDJCWg8oKiVKA42Kjo2NpaAM+ XNKVaAAAA To: =?utf-8?q?Pali_Roh=C3=A1r?= , Sebastian Reichel CC: , , , Jerry Lv X-Mailer: b4 0.14.1 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF00000044:EE_|DB9PR02MB6810:EE_ X-MS-Office365-Filtering-Correlation-Id: 2eedb550-c11c-44ba-2bea-08dcd3d0cd49 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?LTkQUtehFi74Jf9QkSTFxBmj1g2YOXf?= =?utf-8?q?tnzcXP3rLDm02FGdeKH7xXO1qswyOUQwE3Zd3bOx5FrBrjSj4yY0Fg51JWNmncyTb?= =?utf-8?q?WlEQ5HAWPWuYO/v7BqaFAP5yLuyRrovqUtBeGSzFo+ZMHdTaq1524vewIVwaRB8bB?= =?utf-8?q?m8iGDCSW5ygz35YYP8snkoBkb/DmEk3Q2t5zz6QGCMoPIzAz7+bxWdIZcQaJ7huSH?= =?utf-8?q?IhTv5zMGEaujC/l0b2kFNe3i0fMmNxjdM8C9mh6s5g+tOJpBjatcKxa67o4wlmh8m?= =?utf-8?q?PRtd8sdfTegrruRPyXeXeUoHJXaHzgQ6ftRPQlWAGCNkOFKZE+EzEeon2Mai7KGpn?= =?utf-8?q?BiSIhLJylNA/bGi9k9vl70SCuH2sGj8SpWRV73PYbbK+HTdjshmqKJ5zF/b6YMTw7?= =?utf-8?q?ju1mMYaU8Lp5aePbvVsmONZXUPG38FDjQPekMCg0b2NiV8/ZJVJ0jjkF3HAYibmJy?= =?utf-8?q?/npksHgYm8SdsAUe0P+9uu089Le3B1EP+tb7P+VJk1O3at5Bj7vvYMBN7zJhhWz4b?= =?utf-8?q?Rapp5jIYhQbx1JHO01t0u01hZCcjnO54JPTnXnCKmGfq7oRLpaO89uUbmf1J3wcYs?= =?utf-8?q?8Z0OWkMI0lwu7RpcenCGEUL7KlmTcltDuMHM3aww40VEtouFFtKoDjz3DrE3uo0HV?= =?utf-8?q?dMX2VJ+N+SS+9ZgSzjU0CmXc70ww8crloDWcE/kciHDJzjOu55m5V6djSPMNeB2XU?= =?utf-8?q?j8P9j3NuVFBg2CXxQgY9+bdzJ0jbG0UzkwqZLBYeq9rH4MgFaW2WwaXt6zAtm4QzA?= =?utf-8?q?cCl5m2/r+LwMe0LFPIAmQiSVLKQYD+6TyEocbe1qeZjK2J6XHyf/fjzr8IBSyLz78?= =?utf-8?q?peFO3r64ih9fg426K+XXtxh4a7uqoVr10Fk7m7LNgH8JITzeHVBxVx3xeZANJQj0r?= =?utf-8?q?125AZGSRiYNra1tBLRWPfq+Aj2GyUh4c88cATBHAXBt2NbuSIhPk4rc3rIkvvN7bP?= =?utf-8?q?n9ktLH05aTYO7HpeXPs7zk0XVCrVNat9I5/qPN9KWP1hP7QdeoNsDmlMTFJv7GZhL?= =?utf-8?q?PFE9/GRAozaNG34z3qxUuxMT+v3S6WNYhjnzIKQ6Q/kNDXUJb4PXDxyMGMzAv881Z?= =?utf-8?q?96MWqhF0YY4CCzW1mym/14Hbe3bo5vH/UOgz/hbh10omoO4bpjUssqE2SkSD1RIs2?= =?utf-8?q?4y1JKGw2Jv4SveQpux6lQLb49zMixKFqP/Tp/nZN1MVKiU2PkGsGZbWXBUK2I7IIQ?= =?utf-8?q?WiGBI37pwwRv0YTkLf2mPpXsXLXKwUOGyo0qii6UTjgv/nf9BkaM51RqtYOf+jJka?= =?utf-8?q?Ji44uaRVvtncOE9CUvhT+dojzGzYMQPDdDcTMfyfCvhxV5SCsaCWlK8LhZyKVv2/l?= =?utf-8?q?Me3bvb8riQqKyLRRDojOMriHwMyInhRr5Xe7I5KXILKhCsPPBC91/rW/74mYhg3gt?= =?utf-8?q?jMkc3qshqlz?= X-Forefront-Antispam-Report: CIP:195.60.68.100; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.axis.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 08:48:13.0081 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2eedb550-c11c-44ba-2bea-08dcd3d0cd49 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af; Ip=[195.60.68.100]; Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF00000044.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR02MB6810 Multiple applications may access the device gauge at the same time, so the gauge may be busy and EBUSY will be returned. The driver will set a flag to record the EBUSY state, and this flag will be kept until the next periodic update. When this flag is set, bq27xxx_battery_get_property() will just return ENODEV until the flag is updated. Even if the gauge was busy during the last accessing attempt, returning ENODEV is not ideal, and can cause confusion in the applications layer. Instead, retry accessing the gauge to update the properties is as expected. The gauge typically recovers from busy state within a few milliseconds, and the cached flag will not cause issues while updating the properties. Signed-off-by: Jerry Lv --- drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: da3ea35007d0af457a0afc87e84fddaebc4e0b63 change-id: 20240913-foo-fix2-a0d79db86a0b Best regards, diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index 750fda543308..eefbb5029a3b 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -2029,7 +2029,7 @@ static int bq27xxx_battery_get_property(struct power_supply *psy, bq27xxx_battery_update_unlocked(di); mutex_unlock(&di->lock); - if (psp != POWER_SUPPLY_PROP_PRESENT && di->cache.flags < 0) + if (psp != POWER_SUPPLY_PROP_PRESENT && di->cache.flags < 0 && di->cache.flags != -EBUSY) return -ENODEV; switch (psp) {