Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751889AbdLPGFG (ORCPT ); Sat, 16 Dec 2017 01:05:06 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:35145 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbdLPGFC (ORCPT ); Sat, 16 Dec 2017 01:05:02 -0500 X-Google-Smtp-Source: ACJfBotwkB7zxf19qn5xYxc4QiZlSNlM55QEAnv6OClBFSh0ectUQ/O9Au+uLvZYCsvXVD9lAL0i7Q== Date: Fri, 15 Dec 2017 22:04:58 -0800 From: Benson Leung To: Thierry Escande Cc: Benson Leung , Lee Jones , Jonathan Cameron , Enric Balletbo i Serra , Gwendal Grignou , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 1/3] platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing. Message-ID: <20171216060458.GB140982@decatoncale.mtv.corp.google.com> References: <1512135743-16529-1-git-send-email-thierry.escande@collabora.com> <1512135743-16529-2-git-send-email-thierry.escande@collabora.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yNb1oOkm5a9FJOVX" Content-Disposition: inline In-Reply-To: <1512135743-16529-2-git-send-email-thierry.escande@collabora.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4236 Lines: 135 --yNb1oOkm5a9FJOVX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Thierry, On Fri, Dec 01, 2017 at 02:42:21PM +0100, Thierry Escande wrote: > From: Enric Balletbo i Serra >=20 > Commit 12278dc7c572 ("platform/chrome: cros_ec_lpc: Add support for > GOOG004 ACPI device") added support when the firmware reports the ACPI > device, there are some firmwares though that doesn't report this device > but have it. In such cases we need to instantiate the driver explicitly > if it is not instantiated through ACPI. >=20 > Fixes: 12278dc7c572 ("platform/chrome: cros_ec_lpc: Add support for GOOG0= 04 ACPI device") > Signed-off-by: Guenter Roeck > Signed-off-by: Enric Balletbo i Serra > Signed-off-by: Thierry Escande Applied for v4.16. > --- > drivers/platform/chrome/cros_ec_lpc.c | 34 +++++++++++++++++++++++++++++= ++++- > 1 file changed, 33 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chr= ome/cros_ec_lpc.c > index 1baf720..0b26a09 100644 > --- a/drivers/platform/chrome/cros_ec_lpc.c > +++ b/drivers/platform/chrome/cros_ec_lpc.c > @@ -35,6 +35,9 @@ > #define DRV_NAME "cros_ec_lpcs" > #define ACPI_DRV_NAME "GOOG0004" > =20 > +/* True if ACPI device is present */ > +static bool cros_ec_lpc_acpi_device_found; > + > static int ec_response_timed_out(void) > { > unsigned long one_second =3D jiffies + HZ; > @@ -396,9 +399,21 @@ static struct platform_driver cros_ec_lpc_driver =3D= { > .remove =3D cros_ec_lpc_remove, > }; > =20 > +static struct platform_device cros_ec_lpc_device =3D { > + .name =3D DRV_NAME > +}; > + > +static acpi_status cros_ec_lpc_parse_device(acpi_handle handle, u32 leve= l, > + void *context, void **retval) > +{ > + *(bool *)context =3D true; > + return AE_CTRL_TERMINATE; > +} > + > static int __init cros_ec_lpc_init(void) > { > int ret; > + acpi_status status; > =20 > if (!dmi_check_system(cros_ec_lpc_dmi_table)) { > pr_err(DRV_NAME ": unsupported system.\n"); > @@ -415,11 +430,28 @@ static int __init cros_ec_lpc_init(void) > return ret; > } > =20 > - return 0; > + status =3D acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device, > + &cros_ec_lpc_acpi_device_found, NULL); > + if (ACPI_FAILURE(status)) > + pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME); > + > + if (!cros_ec_lpc_acpi_device_found) { > + /* Register the device, and it'll get hooked up automatically */ > + ret =3D platform_device_register(&cros_ec_lpc_device); > + if (ret) { > + pr_err(DRV_NAME ": can't register device: %d\n", ret); > + platform_driver_unregister(&cros_ec_lpc_driver); > + cros_ec_lpc_reg_destroy(); > + } > + } > + > + return ret; > } > =20 > static void __exit cros_ec_lpc_exit(void) > { > + if (!cros_ec_lpc_acpi_device_found) > + platform_device_unregister(&cros_ec_lpc_device); > platform_driver_unregister(&cros_ec_lpc_driver); > cros_ec_lpc_reg_destroy(); > } > --=20 > 2.7.4 >=20 --=20 Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. bleung@google.com Chromium OS Project bleung@chromium.org --yNb1oOkm5a9FJOVX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJaNLeKAAoJEB8J9XsKL+ZYT2kP/jjXEJatXu85SamBI7oXD9F0 tQhsp2hJoak7fFc4uy5sIYvVwy1PUJ2YOL+zY2OCHmTxGKD/bKXRxVFsqG8/kcCq zPukYBwvhFV+e5OUri4a5tkkI4AWQw83o9873iI8fVQIY8FQyyoP5AqpC1fvLOpz kL50uafifzl1g6VISN7WFmAyGKsEvVi82TnaAx2uVQ1Qe7eogNvpRSnZ6NydJdML UnOq8/q643OpSCpuRmDU2oPkDc7xG4BT0r+7Nnnz3f6XXGskgS5FrIyluYguWDV/ 6iaqSZyy3DN3T6kJI+KdTf+/7mCPh+qtcwyM5Qt0BFXycIJ68ke3B3wFOtA5e+Cp 3YxadlWzbNPURdzdVqy0aoYtJRhTz5Yz/JjMTV8iJJry0CSjmnRNN542KfO8SLGM lLDVlE8eUrsbq171f6XPf1b/41xxqqAYtMQbwALpCH43QeIh8k45O/uzYA5HFe6m PV+fVI8ktwk7Y87ahHU8hhhvq3kBoyMkI3WlhcKAbO9szdEm3L5zSjc1yvmaXITz eXj/le5xOpHeBRm2278UHqgkC6yj2+8V5R87j18NIZYqVGUr6DxSU2PNqzAML6Ib LmXBKnukAxSjEgk1EEBaGlyBBw024XyClnN4F+dr26Hbittpw9FKOqRDq4VIZXM4 yDAgQxuAHK3oc5p/JAVV =OQUq -----END PGP SIGNATURE----- --yNb1oOkm5a9FJOVX--