Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4589407rwe; Mon, 17 Apr 2023 15:21:37 -0700 (PDT) X-Google-Smtp-Source: AKy350aCuFdgKqF3Jk2mR75SAZ26dbhGajhylVmCM6PvVbQ+ZIAu59LyNKq5oDh6u+jtmm54xJQc X-Received: by 2002:a17:90a:8f02:b0:247:714e:94e5 with SMTP id g2-20020a17090a8f0200b00247714e94e5mr8909428pjo.23.1681770096785; Mon, 17 Apr 2023 15:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681770096; cv=none; d=google.com; s=arc-20160816; b=y5sntQyHAEMbBX3R7ikRClApdXqnv8Qjm7rtfqiDs11BJfTo9SVWEYLN8pALKPwPGw +jLuID/VkJZDZq+p/eyfN6TwQPqQ1N3lIumvrpdT/jL0wFWvqwGdrh/KloZHgaBTgMvV kTJARszlrL0nYFJZLRE2My6ouAIqyomojnmKtrPQXBX+0K1QAHtZlXWjb+730SpWK4k8 EpJwsopOZ5arftnfvNHxBY1HPLuGraMdnOybnlElnB1hBcAkmn3b0V6MhgoAZwQpTyX9 NnO/EwJw1RW8fhe5c9ac6oi1wdtuUwLz+Kycx+I9Omjh3Py+tL+ZV+LHzqzMJj5uW+aZ QQxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HX6x50X1I0Zl7KqrE4lTGH4kDeVIRVgagffI4hk1W4w=; b=f2Peh24QYjahwKpAsizCCNGDg5RDH79lkSOpMc19Sau74RWPPhrmjaWUww8pybnPpw xrpafMkTRfZVRkruM9ekKL+J59veWeyLBNAOqhr+qQpuGkDKaafyP771ZHtzoInUht3D HSoTEoxekg/v/x+XrKkH2pusdlmhVguqRXlDcS6gmgfcfqX7FHflOyqL67WKGnVRHuE1 YsJMvaOQnve/7as1+Z9s8WAH/WGK/0LHMHuEp2Ban4VC/lglMHvjjmqtFqOXrggWqhbY NFhcS08f5qHefM3bj964maG5i5t6wLYtL4cDKBSuO5P6dcTYeaEKyRnu2b4yZNpiuuTB A+nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="BAQM/Qj6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi16-20020a17090b4b5000b0023f14c9a5fesi5118900pjb.100.2023.04.17.15.21.12; Mon, 17 Apr 2023 15:21:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="BAQM/Qj6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbjDQWQi (ORCPT + 99 others); Mon, 17 Apr 2023 18:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjDQWQR (ORCPT ); Mon, 17 Apr 2023 18:16:17 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6AD15279 for ; Mon, 17 Apr 2023 15:16:16 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-63b73203e0aso4190745b3a.1 for ; Mon, 17 Apr 2023 15:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681769776; x=1684361776; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HX6x50X1I0Zl7KqrE4lTGH4kDeVIRVgagffI4hk1W4w=; b=BAQM/Qj6aW6qQVkNxEdFfvp4L2v43/c1sWfOR0aw0h4Q4QXr91VuuUfUq4AAd0INWD YwUAjIo/zgar/4MiknTnJOhzPmBP5cT+Eq6J5LrcP/OVrQBjHwp8yuW4S91pa7GLFw/S ao8TZKF4rpXW4x3pxnaWwY/z/1I9ZK3fC7dSY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681769776; x=1684361776; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HX6x50X1I0Zl7KqrE4lTGH4kDeVIRVgagffI4hk1W4w=; b=TOG1ZPiPSJU7HmAEv7wYecfj3iVmzAjwEkj/6NqMWluQ8v/WMTJpcAqtfUrZ+KSFFn pncmhFu74PAqM+oJtH6kTBf7YSa1WusYJDx+xteKODpnAQX1GuokMMCNGxV9dy4Z1rLw AEKi+czvmlxEuKSVqWtqJfKgCrs8xQbAaw+5TdpEvIpntRioHEDvBCV5gDUMz0ljD+dz gcEJC5+OZu2ulaWeVJOZ+6jJrX5NwRS8suy307FtC5NDO15qfZ/H99ydVitusy9Lwmwj 2xOO4rqb77ceZzLo6FLQWr9cqLnx7MBSmharWXH+55XBvmrTQVf952f+0XNkFFHR+evx fQVw== X-Gm-Message-State: AAQBX9dDFi7E4Tx4nHFgGO/gQdRFZ/gxPV2wneIOHN98jcSgxyvpuX99 HOnPhf7bB7sKnFk6SL1Lvuqi15BoVNZ1oVjE6p8= X-Received: by 2002:a17:902:c405:b0:1a6:3630:16e1 with SMTP id k5-20020a170902c40500b001a6363016e1mr50164plk.13.1681769776269; Mon, 17 Apr 2023 15:16:16 -0700 (PDT) Received: from pc98uv11.mtv.corp.google.com ([2620:15c:9d:2:8021:f588:5cf5:d9b4]) by smtp.gmail.com with ESMTPSA id b15-20020a170902b60f00b001a27f810a2esm8139061pls.256.2023.04.17.15.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 15:16:15 -0700 (PDT) From: Daisuke Nojiri To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Daisuke Nojiri Subject: [PATCH] cros_pchg: Sync port status on resume Date: Mon, 17 Apr 2023 15:16:10 -0700 Message-ID: <20230417221610.1507341-1-dnojiri@chromium.org> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a stylus is removed (or attached) during suspend, the device detach (or attach) events can be lost. This patch makes the peripheral device charge driver retrieve the latest status from the EC on resume. BUG=b:276414488 TEST=Redrix Signed-off-by: Daisuke Nojiri --- .../power/supply/cros_peripheral_charger.c | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/cros_peripheral_charger.c b/drivers/power/supply/cros_peripheral_charger.c index 1379afd9698d..a204f2355be4 100644 --- a/drivers/power/supply/cros_peripheral_charger.c +++ b/drivers/power/supply/cros_peripheral_charger.c @@ -227,8 +227,7 @@ static int cros_pchg_get_prop(struct power_supply *psy, return 0; } -static int cros_pchg_event(const struct charger_data *charger, - unsigned long host_event) +static int cros_pchg_event(const struct charger_data *charger) { int i; @@ -256,7 +255,7 @@ static int cros_ec_notify(struct notifier_block *nb, if (!(host_event & EC_MKBP_PCHG_DEVICE_EVENT)) return NOTIFY_DONE; - return cros_pchg_event(charger, host_event); + return cros_pchg_event(charger); } static int cros_pchg_probe(struct platform_device *pdev) @@ -281,6 +280,8 @@ static int cros_pchg_probe(struct platform_device *pdev) charger->ec_dev = ec_dev; charger->ec_device = ec_device; + platform_set_drvdata(pdev, charger); + ret = cros_pchg_port_count(charger); if (ret <= 0) { /* @@ -349,9 +350,27 @@ static int cros_pchg_probe(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int __maybe_unused cros_pchg_resume(struct device *dev) +{ + struct charger_data *charger = dev_get_drvdata(dev); + + /* + * Sync all ports on resume in case reports from EC are lost during + * the last suspend. + */ + cros_pchg_event(charger); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(cros_pchg_pm_ops, NULL, cros_pchg_resume); + static struct platform_driver cros_pchg_driver = { .driver = { .name = DRV_NAME, + .pm = &cros_pchg_pm_ops, }, .probe = cros_pchg_probe }; -- 2.39.2