Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8363890ybl; Thu, 16 Jan 2020 15:24:04 -0800 (PST) X-Google-Smtp-Source: APXvYqx+ML+lcBG0TgddNDt1rlRTzEOza7WNsarNhJSSK8KHo3XUkPyYWHvC6qQsNz4snNYflWKa X-Received: by 2002:a05:6830:1353:: with SMTP id r19mr4176930otq.288.1579217044471; Thu, 16 Jan 2020 15:24:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579217044; cv=none; d=google.com; s=arc-20160816; b=kddTUi3tGoBQ5x3IKEFoFfrpidz+P89GN6bAI5oVqai2+9kXH5xNhCBvclz7jM8QD5 ECy3ub9hmJt1JQfRjIKAFUpOizCNpR1VmdFCtc3GhDxgktE/7GFeo0bj8Q8JTdB0XNuJ kQ29FQfkjz1Veg6QM0zzQZLtjH5gMTqHw3BfJPK1T65kQhB39gsmm64p1Ug6LeRzWpYq YchVKn/4uJrUZVHEuho2nnB/HgYZS3hZ4pKWOl2T1zftrjCKL2TW/7oCl3RTfyRawMmD ygAjNedQeeUg8BKeF9g2BONyFcT8JUV3IHbEsiPm3iKSaNGwq6e0MNs+zqP2dxi65B2t tXjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qWxprvQq91HlSBYMtq4wuCeE12lVfFcZvqXvzWSRM9A=; b=ZFCYsvh8SViT5jk499SY6mt4h33/EaxQWY5whwbSdK/rEYWnE4B5o8oj6EyFtJsuew oycJrf4dRhvjhkwfrVBR86QS5RAI4CxZFfQJ8bvLWf+KZ8tEP2qPz7yGD5V5ZyIxhBA3 7c+ld4/RjvXQgiB5+6vJi49U6DFzNnjo+YFRiZr+PKAHrgyKdmqTKvZlX9PfLwm64Qq3 Cm9PbfJ11dozLNNsdSiQW5kaOjy6WNIv9N26YP7Fy48H/Ngp42gQJ47iWXI5ehXVdeRc m4A6TSHFJNEZLEaMTrcAiK5FT0Wvn1HFpiLRM/v2JIoqxJvdGfndFyhzLoygJEGhDV2i i9lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="EhvP6/2o"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u191si11923957oia.86.2020.01.16.15.23.52; Thu, 16 Jan 2020 15:24:04 -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=@google.com header.s=20161025 header.b="EhvP6/2o"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729372AbgAPTqD (ORCPT + 99 others); Thu, 16 Jan 2020 14:46:03 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41426 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727023AbgAPTqC (ORCPT ); Thu, 16 Jan 2020 14:46:02 -0500 Received: by mail-pf1-f194.google.com with SMTP id w62so10729523pfw.8 for ; Thu, 16 Jan 2020 11:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qWxprvQq91HlSBYMtq4wuCeE12lVfFcZvqXvzWSRM9A=; b=EhvP6/2oQIZiZhj0JtyDkObGdHPS3i2JlXJcrmc81qk15Orbf/pb+MRAKKrL6CuZMF BrHaVrF2TcOqNLWlUJ2jYZ9UNNUgVI9TIoeJxFGtcR1tPMkPnuEQvGDVHfAltW91U4oy 1GQIWGThIAHypTeiBaPKoIOwzQu2o2x+I4xWoVqYWjtDDEv6HzPcLhBUkQVZHuoSTz3q 4tslyv+OHQfQBAjKAFaBjDQG4wLnqkCxj6JgHpJrEGOvSdGUZ+dE7XC7eukgLOA7ze6a NFKfBCfnXgth3YJmc0loFBLmjX5Y4O6ZAdil99N1qq1BCgj/2zNOalAX/5FQgoY+DGkJ n3mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qWxprvQq91HlSBYMtq4wuCeE12lVfFcZvqXvzWSRM9A=; b=nHO7BrYNRK/2qTgmBICB98vInO53byrcRuQptMoopFhnwee1h57WoUWEfoZo5MNmPo zNJgmFY1rOhRwBVgU1yZ12uUmXr+cKq5Is0T04HZFkBnS3RDP9yNob5BJhQnL/B0T9/9 4JAn5e26T+JDf+EsCNRvaVBgw6aio1owuW9n9rBoM3LuqjOa8TLVwEtkhcuWaeLtBQks ayv6KSho3hv6iFyufwFyPqvXa/rn8rYt2A7ubxsilLjNWqvsghIsecDmiejpaSsuvOGs W618hKlKq/K/ttERuzwbth+4bInVYpBy7zmvXw5T9wW9Cc+vaTfVQlVC7yn9/Jegls+k Ctzg== X-Gm-Message-State: APjAAAWp1jDbOIHmK4VMMLygY2ewzkPIlb+/r/Pkca34yusBZs3Wup7W +WoiopLlV279bTMn7BcBrCcp5Q== X-Received: by 2002:a62:ee11:: with SMTP id e17mr39523857pfi.48.1579203961867; Thu, 16 Jan 2020 11:46:01 -0800 (PST) Received: from google.com ([2620:15c:202:201:bc61:d85d:eb16:9036]) by smtp.gmail.com with ESMTPSA id i4sm25516768pgc.51.2020.01.16.11.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 11:46:01 -0800 (PST) Date: Thu, 16 Jan 2020 11:45:56 -0800 From: Benson Leung To: Prashant Malani Cc: enric.balletbo@collabora.com, groeck@chromium.org, bleung@chromium.org, lee.jones@linaro.org, sre@kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Jon Flatley Subject: Re: [PATCH v6 3/3] power: supply: cros-ec-usbpd-charger: Fix host events Message-ID: <20200116194556.GB208460@google.com> References: <20200114232219.93171-1-pmalani@chromium.org> <20200114232219.93171-3-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="QKdGvSO+nmPlgiQ/" Content-Disposition: inline In-Reply-To: <20200114232219.93171-3-pmalani@chromium.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --QKdGvSO+nmPlgiQ/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 14, 2020 at 03:22:22PM -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 > Signed-off-by: Jon Flatley > Signed-off-by: Prashant Malani Only a minor nit. Otherwise, Reviewed-by: Benson Leung > --- >=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..7f7e051262170 100644 > --- a/drivers/power/supply/cros_usbpd-charger.c > +++ b/drivers/power/supply/cros_usbpd-charger.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include Really minor nit. Alphabetize this #include. This insertion should be one line below. > #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 --=20 Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. bleung@google.com Chromium OS Project bleung@chromium.org --QKdGvSO+nmPlgiQ/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQQCtZK6p/AktxXfkOlzbaomhzOwwgUCXiC9dAAKCRBzbaomhzOw wgvbAP0QtfwoVQChl9YxkK2n6Iv1H24tLRHYhDA8vVkTKEdGDAD/TAFa3CXvqngt kVJ1m+pjWCdZBbCcTvmny2Q83xgp0QY= =aP8I -----END PGP SIGNATURE----- --QKdGvSO+nmPlgiQ/--