Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8572159ybl; Thu, 16 Jan 2020 19:55:37 -0800 (PST) X-Google-Smtp-Source: APXvYqyToQmthh9JkW0r8Z1lrGZk62ok+AcpBjj94fsd14agnY/2Z+ExU5KTAZoVhWAs0ZHRinoE X-Received: by 2002:aca:a949:: with SMTP id s70mr2030454oie.80.1579233337633; Thu, 16 Jan 2020 19:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579233337; cv=none; d=google.com; s=arc-20160816; b=R+0oOBp63RxA74Yv+vyyLYbQEhcdhkuBu0MZEAcBNFgu9vuiHN8aBfblZoOy2g+g0d kNx2lhTb9g6uTBSPCI6udG29iZzxy5POhgSd9WAuP5W9d7M3Ebtb6VY7dew8p9EpQBlg A4jdZ90aNi8/t7yBy8M9zhwsYfOv7eCubRm1ycm5SykTQ/FOG9v3AubI5QY1odp7Wqy3 gNwN+Gblolv95Td9cNPJ06Y16Y3I7nv6Vzp5JIOOGXlqCMqRYdyXErEAzPU8b74wd63X L9F7GGkgyh11EguclxK+ivsnhYE3szg8a1u6xp9Maz3vmjxN/gO/oG5BaC1IDG3i2YBn y01g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=u9PW8C/ogBxO6D6Mqw/jSdVHr5J9yPSVjFcqvmbAqqA=; b=qHEo6dt42mR3O4g1BjK6oSGkqHRzW8DdUhZXtzh9Y2Adlo7bpmjI7oXDMv++5G9m7g 9D31+l7RlYkuc3Wq3LtE6NVlcqgPsMLgiMhCw3gj+ZJv2FFMN/xKIYL3IOoqi07oNXgS QAhhE34SWZOOZ6gt7sRVKlQrSi84dS0fLyEcdY+6zXCTHRZ53aMvuj05KYc4Xl4MlYNx NtCPyDlx+oS+7pSzCErGJyfhwBga99BsE46Ea763z5N1FJUdkVXbqzRa0BtIsTuayfEl +D1mjIgNXg+28Ui4sG7Kb8hfWRORfMKg6O+vtYESKU1A2Oh6CWYDPUVF7Dv7gkh+rPuR eIxA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si13676365otq.156.2020.01.16.19.55.26; Thu, 16 Jan 2020 19:55:37 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730592AbgAQBMX (ORCPT + 99 others); Thu, 16 Jan 2020 20:12:23 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:34394 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbgAQBMW (ORCPT ); Thu, 16 Jan 2020 20:12:22 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 59B0729195F Received: by earth.universe (Postfix, from userid 1000) id BCFD23C0C7E; Fri, 17 Jan 2020 02:12:16 +0100 (CET) Date: Fri, 17 Jan 2020 02:12:16 +0100 From: Sebastian Reichel To: Prashant Malani Cc: enric.balletbo@collabora.com, groeck@chromium.org, bleung@chromium.org, lee.jones@linaro.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Jon Flatley Subject: Re: [PATCH v7 3/3] power: supply: cros-ec-usbpd-charger: Fix host events Message-ID: <20200117011216.p7etrc6oarptmhcb@earth.universe> References: <20200117002820.56872-1-pmalani@chromium.org> <20200117002820.56872-3-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="76elxl47hgu34n4a" Content-Disposition: inline In-Reply-To: <20200117002820.56872-3-pmalani@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --76elxl47hgu34n4a Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Thu, Jan 16, 2020 at 04:28:24PM -0800, Prashant Malani wrote: > From: Jon Flatley >=20 > 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. >=20 > 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. >=20 > Reviewed-by: Benson Leung > Co-Developed-by: Prashant Malani > Signed-off-by: Jon Flatley > Signed-off-by: Prashant Malani > --- Reviewed-by: Sebastian Reichel I currently have one cros_usbpd-charger patch queued in -next. This patch looks like it should not create conflicts, but it's probably better to merge an immutable branch. -- Sebastian >=20 > Changes in v7(pmalani@chromium.org): > - Alphabetize #include header. >=20 > Changes in v6(pmalani@chromium.org): > - Patch first introduced into the series in v6. >=20 > drivers/power/supply/Kconfig | 2 +- > drivers/power/supply/cros_usbpd-charger.c | 50 ++++++++--------------- > 2 files changed, 19 insertions(+), 33 deletions(-) >=20 > 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 > =20 > 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/su= pply/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, > } > =20 > 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 =3D container_of(nb, struct charger_data, > + notifier); > =20 > - charger =3D container_of(nb, struct charger_data, notifier); > - ec_device =3D charger->ec_device; > - > - host_event =3D 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; > } > =20 > static void cros_usbpd_charger_unregister_notifier(void *data) > { > struct charger_data *charger =3D data; > - struct cros_ec_device *ec_device =3D charger->ec_device; > =20 > - blocking_notifier_chain_unregister(&ec_device->event_notifier, > - &charger->notifier); > + cros_usbpd_unregister_notify(&charger->notifier); > } > =20 > 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; > } > =20 > - if (ec_device->mkbp_event_supported) { > - /* Get PD events from the EC */ > - charger->notifier.notifier_call =3D cros_usbpd_charger_ec_event; > - ret =3D blocking_notifier_chain_register( > - &ec_device->event_notifier, > - &charger->notifier); > - if (ret < 0) { > - dev_warn(dev, "failed to register notifier\n"); > - } else { > - ret =3D 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 =3D cros_usbpd_charger_ec_event; > + ret =3D cros_usbpd_register_notify(&charger->notifier); > + if (ret < 0) { > + dev_warn(dev, "failed to register notifier\n"); > + } else { > + ret =3D devm_add_action_or_reset(dev, > + cros_usbpd_charger_unregister_notifier, > + charger); > + if (ret < 0) > + goto fail; > } > =20 > return 0; > --=20 > 2.25.0.341.g760bfbb309-goog >=20 --76elxl47hgu34n4a Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl4hCfAACgkQ2O7X88g7 +prSdRAAndFRCIrvPRuln3f8oxxNC85C+Z+hPlTNWaJppPguaTZ+xBkRGPs5oyrE Gueiptsi1Ua8AaCECUU+cZeAHvVYDvVdTY21J48YMOXNgFiFC/BUN5oI9oZpe+Ri F1J1sekKfwbFz5mbC6gSlqW36bIFiFHuOXrNjuEMtua2jsbCcf1QXe5dI6uLXAGj UcFuvAvPafO9L90UojNrMGytkaAfpi04Cnj34i3INAcqsMkAYbb5o6I7lqFjjUlE GZDkJA5oylOF7CCxKHBq5rCWHXHZT1kDKk2dXLepqJeP/H7MckNi+9/8hU9bBWp+ oDeSzeQN5lkXV8+LRUlOBjG0jPYj6JIltoqKkSglfPpQBWIOvsyF3Gs9rXw8ybxt B1tCc2EG6Z4XBkYdyL31I0QZrlrVP4Kn23TNa4ah2KKMcveNEmtV5VD1R/sDFM8I zK6S4/rdJIwD66Pu6on/Au47IWIPBTGGGtF0oJsDCle2PmZfo5PnD0yC6njqaQ2o ivpEgujzcVkXRRLJB6HRqbuBoz4Tmt85MwXdDd/Q20DCLr5M77PcVaaC9agDuU+N K7g3/jHkN2c/9o+UbZNLB08uTLea4eCrrYribWl6RkBCer/F6MDlEn37U2pmBocv b2PbY0f06p9CWwRANS167dpLgBnsDgFEodvlradBVcUIGOygYAU= =Rh6s -----END PGP SIGNATURE----- --76elxl47hgu34n4a--