From patchwork Sat Apr 15 18:23:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 674435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92329C77B73 for ; Sat, 15 Apr 2023 18:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229887AbjDOSZM (ORCPT ); Sat, 15 Apr 2023 14:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbjDOSZM (ORCPT ); Sat, 15 Apr 2023 14:25:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1697448D for ; Sat, 15 Apr 2023 11:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681583034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h7BkgEYUkkEY4tnKwaGF3zyy4JgH/XYuVjrm8AAw+ig=; b=PwM3bOEM0l5LK6XRC7W/2B9dM3iiWMZBG/hg1iE16Z1YE18CAIjRG66dc0FKy3WbL2Uib5 Dc0dLF2blzEljXmDBAty1WleBk5YPV8KMnOo75fgSXNEPiKGR+6aGSeA0Jm1GCIQYgGk29 DPUHDeq7Ifcyaw2vOef9sT93CUl0SlI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-251-6yn5jVrTNeCkLWjteBcrkg-1; Sat, 15 Apr 2023 14:23:50 -0400 X-MC-Unique: 6yn5jVrTNeCkLWjteBcrkg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 617B9800B35; Sat, 15 Apr 2023 18:23:50 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F1ED51FF; Sat, 15 Apr 2023 18:23:49 +0000 (UTC) From: Hans de Goede To: Sebastian Reichel , =?utf-8?q?Pali_Roh=C3=A1r?= Cc: Hans de Goede , Marek Vasut , laji Xiao <3252204392abc@gmail.com>, linux-pm@vger.kernel.org Subject: [PATCH v2 07/10] power: supply: bq27xxx: After charger plug in/out wait 0.5s for things to stabilize Date: Sat, 15 Apr 2023 20:23:38 +0200 Message-Id: <20230415182341.86916-8-hdegoede@redhat.com> In-Reply-To: <20230415182341.86916-1-hdegoede@redhat.com> References: <20230415182341.86916-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org bq27xxx_external_power_changed() gets called when the charger is plugged in or out. Rather then immediately scheduling an update wait 0.5 seconds for things to stabilize, so that e.g. the (dis)charge current is stable when bq27xxx_battery_update() runs. Fixes: 740b755a3b34 ("bq27x00: Poll battery state") Signed-off-by: Hans de Goede --- drivers/power/supply/bq27xxx_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index f98b51ce19b5..929e813b9c44 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -2099,8 +2099,8 @@ static void bq27xxx_external_power_changed(struct power_supply *psy) { struct bq27xxx_device_info *di = power_supply_get_drvdata(psy); - cancel_delayed_work_sync(&di->work); - schedule_delayed_work(&di->work, 0); + /* After charger plug in/out wait 0.5s for things to stabilize */ + mod_delayed_work(system_wq, &di->work, HZ / 2); } int bq27xxx_battery_setup(struct bq27xxx_device_info *di)