Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8570910ybl; Thu, 16 Jan 2020 19:53:30 -0800 (PST) X-Google-Smtp-Source: APXvYqydsvLqYH3a4oGu0/LATW/4QhdDvSBJPLQQFdBTNBsaDqOObhCbZDjU9IuuGflSeUo+Xt74 X-Received: by 2002:a9d:76cb:: with SMTP id p11mr1032983otl.7.1579233210166; Thu, 16 Jan 2020 19:53:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579233210; cv=none; d=google.com; s=arc-20160816; b=v8Z4jfw676tcTJ0YJLv8dX1sNGj68e83zvIo8rlgrHplyGR1CtVO8K7iZPwYUCO4mp UgSovdVYCYZiIG3vERhvPkBq5588qcoHpCztTyfgQQ4FLqJSa+QkwITHc69Fd5NUbrX2 lotdvDydzd6NceB4h5Dwnv0yN/zQcxX3tfFVv96neCdVUwz7aVTPmVsBJqoixrZ/+JXo oE7nxEqmdZTZsCrUqeV9FS4jlE7r6LbCcYOFP1Fil44cXhU5TwvTEPUrGWZskMYFcJbE 2EynNZ87gfdaqOD5/2pNG3TXrcoqLimGp43ORr1Voc80EsYcji3p9dsC6qKLBOA8778h g++g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oENCplfxYS/x7buWRMyVXnbpGnLZpIshtiMHjv9RuL8=; b=Vzy7SzMpx2PfYd2Oq/IwjonZWuL24B2xDQwOOSE3jXYo89rCo8/AhkohWfc/hPsg5F hbR4A1Pe7jpZ/rta+w5ncQCZfo4xNnGrcNLRDTNPdMmD4W57wd0th1YXoCTfReM6g2r8 1Az6wqKo3zkvwVhxhrIVY36LYvxgZzFe9XpSwf3gnpYmbNcsK2ohK/jleujML6t3VxJy wM+ggwYtGqLGlI9VEMdTfdKnMR7M13JUAuDA6lLTXTHGHAgXEIiccwOSgmySxNHWcrj6 DxhV8kgDUmDKYn3SF4uhJtP86/SSqKbVh3foh0vD6pmTa2WuCNZO662mc0MvEXz+Nn14 XvXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bV2jRU6y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p207si5057413oic.111.2020.01.16.19.53.18; Thu, 16 Jan 2020 19:53:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bV2jRU6y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730545AbgAQAdU (ORCPT + 99 others); Thu, 16 Jan 2020 19:33:20 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:35705 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728898AbgAQAdU (ORCPT ); Thu, 16 Jan 2020 19:33:20 -0500 Received: by mail-pj1-f65.google.com with SMTP id s7so2472565pjc.0 for ; Thu, 16 Jan 2020 16:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oENCplfxYS/x7buWRMyVXnbpGnLZpIshtiMHjv9RuL8=; b=bV2jRU6y0Hh6CrGd9dfjiMuxbQQNzdSTfEvXeBz9zlwazA3Bv7xhlQ16RLSo1vq3qp sKAA1RLxDtCbnfvdl6r0RqQ7/YH45+KPrOXl+ZuKIs0xl6Xly3Iyc3qu4jwwVexcYQEf 3DIq3zQlj/uLuWIEaVA91MFzhRVQhmIllJ8aQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oENCplfxYS/x7buWRMyVXnbpGnLZpIshtiMHjv9RuL8=; b=PE/exTU4c6r1LSG1mot8hErHVC3409u/MAupJJpASEhuB/vPIzlLPmkS5LhO9Z/7kN IA1eQNnpoQSW1Kr1A5nQf38RCK8jxfusq6GuFUJ92RKHobqBQrCG6UqJfUFnqun7fThr qtCnxfNnn3QeFLj26lw51g5hGjV1Uh1I7WY9Zp7BlWlToGAnSfItIW2advnZCz8ZtPr6 owq01j82so5PimjSDF+Ubdm18Jg71ulCofoI/A6yaTxZMYUHYTz7C6crrLLWXuHmAw5g Gd2h5hi6cJaCJgnxxx2Bdzg4UpEFpFkM9RuxmOXR5AlaJT2tNdjLAjXIbzis1a+8qgVp n7JA== X-Gm-Message-State: APjAAAUToX36I0QSf2D1Phr1HVm3Ysdf4fjQY4hoFqkcvxjxXzyjW+4U me4CcFNZs+zrJs9TsCppd1jflA== X-Received: by 2002:a17:902:a5c2:: with SMTP id t2mr40927930plq.86.1579221198354; Thu, 16 Jan 2020 16:33:18 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:172e:4646:c089:ce59]) by smtp.gmail.com with ESMTPSA id c188sm667420pga.83.2020.01.16.16.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 16:33:17 -0800 (PST) From: Prashant Malani To: enric.balletbo@collabora.com, groeck@chromium.org, bleung@chromium.org, lee.jones@linaro.org, sre@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Jon Flatley , Prashant Malani Subject: [PATCH v7 3/3] power: supply: cros-ec-usbpd-charger: Fix host events Date: Thu, 16 Jan 2020 16:28:24 -0800 Message-Id: <20200117002820.56872-3-pmalani@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200117002820.56872-1-pmalani@chromium.org> References: <20200117002820.56872-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jon Flatley There's a bug on ACPI platforms where host events from the ECPD ACPI device never make their way to the cros-ec-usbpd-charger driver. This makes it so the only time the charger driver updates its state is when user space accesses its sysfs attributes. Now that these events have been unified into a single notifier chain on both ACPI and non-ACPI platforms, update the charger driver to use this new notifier. Reviewed-by: Benson Leung Co-Developed-by: Prashant Malani Signed-off-by: Jon Flatley Signed-off-by: Prashant Malani --- Changes in v7(pmalani@chromium.org): - Alphabetize #include header. Changes in v6(pmalani@chromium.org): - Patch first introduced into the series in v6. drivers/power/supply/Kconfig | 2 +- drivers/power/supply/cros_usbpd-charger.c | 50 ++++++++--------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 27164a1d3c7c4..ba74ddd793c3d 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -659,7 +659,7 @@ config CHARGER_RT9455 config CHARGER_CROS_USBPD tristate "ChromeOS EC based USBPD charger" - depends on CROS_EC + depends on CROS_USBPD_NOTIFY default n help Say Y here to enable ChromeOS EC based USBPD charger diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c index 6cc7c3910e098..7eea080048f43 100644 --- a/drivers/power/supply/cros_usbpd-charger.c +++ b/drivers/power/supply/cros_usbpd-charger.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -524,32 +525,21 @@ static int cros_usbpd_charger_property_is_writeable(struct power_supply *psy, } static int cros_usbpd_charger_ec_event(struct notifier_block *nb, - unsigned long queued_during_suspend, + unsigned long host_event, void *_notify) { - struct cros_ec_device *ec_device; - struct charger_data *charger; - u32 host_event; + struct charger_data *charger = container_of(nb, struct charger_data, + notifier); - charger = container_of(nb, struct charger_data, notifier); - ec_device = charger->ec_device; - - host_event = cros_ec_get_host_event(ec_device); - if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) { - cros_usbpd_charger_power_changed(charger->ports[0]->psy); - return NOTIFY_OK; - } else { - return NOTIFY_DONE; - } + cros_usbpd_charger_power_changed(charger->ports[0]->psy); + return NOTIFY_OK; } static void cros_usbpd_charger_unregister_notifier(void *data) { struct charger_data *charger = data; - struct cros_ec_device *ec_device = charger->ec_device; - blocking_notifier_chain_unregister(&ec_device->event_notifier, - &charger->notifier); + cros_usbpd_unregister_notify(&charger->notifier); } static int cros_usbpd_charger_probe(struct platform_device *pd) @@ -683,21 +673,17 @@ static int cros_usbpd_charger_probe(struct platform_device *pd) goto fail; } - if (ec_device->mkbp_event_supported) { - /* Get PD events from the EC */ - charger->notifier.notifier_call = cros_usbpd_charger_ec_event; - ret = blocking_notifier_chain_register( - &ec_device->event_notifier, - &charger->notifier); - if (ret < 0) { - dev_warn(dev, "failed to register notifier\n"); - } else { - ret = devm_add_action_or_reset(dev, - cros_usbpd_charger_unregister_notifier, - charger); - if (ret < 0) - goto fail; - } + /* Get PD events from the EC */ + charger->notifier.notifier_call = cros_usbpd_charger_ec_event; + ret = cros_usbpd_register_notify(&charger->notifier); + if (ret < 0) { + dev_warn(dev, "failed to register notifier\n"); + } else { + ret = devm_add_action_or_reset(dev, + cros_usbpd_charger_unregister_notifier, + charger); + if (ret < 0) + goto fail; } return 0; -- 2.25.0.341.g760bfbb309-goog