linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benson Leung <bleung@google.com>
To: Thierry Escande <thierry.escande@collabora.com>
Cc: Benson Leung <bleung@chromium.org>,
	Lee Jones <lee.jones@linaro.org>,
	Jonathan Cameron <jic23@kernel.org>,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>,
	Gwendal Grignou <gwendal@chromium.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 1/3] platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing.
Date: Fri, 15 Dec 2017 22:04:58 -0800	[thread overview]
Message-ID: <20171216060458.GB140982@decatoncale.mtv.corp.google.com> (raw)
In-Reply-To: <1512135743-16529-2-git-send-email-thierry.escande@collabora.com>

[-- Attachment #1: Type: text/plain, Size: 3189 bytes --]

Hi Thierry,

On Fri, Dec 01, 2017 at 02:42:21PM +0100, Thierry Escande wrote:
> From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> 
> 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.
> 
> Fixes: 12278dc7c572 ("platform/chrome: cros_ec_lpc: Add support for GOOG004 ACPI device")
> Signed-off-by: Guenter Roeck <groeck@chromium.org>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>

Applied for v4.16.

> ---
>  drivers/platform/chrome/cros_ec_lpc.c | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/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"
>  
> +/* 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 = jiffies + HZ;
> @@ -396,9 +399,21 @@ static struct platform_driver cros_ec_lpc_driver = {
>  	.remove = cros_ec_lpc_remove,
>  };
>  
> +static struct platform_device cros_ec_lpc_device = {
> +	.name = DRV_NAME
> +};
> +
> +static acpi_status cros_ec_lpc_parse_device(acpi_handle handle, u32 level,
> +					    void *context, void **retval)
> +{
> +	*(bool *)context = true;
> +	return AE_CTRL_TERMINATE;
> +}
> +
>  static int __init cros_ec_lpc_init(void)
>  {
>  	int ret;
> +	acpi_status status;
>  
>  	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;
>  	}
>  
> -	return 0;
> +	status = 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 = 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;
>  }
>  
>  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();
>  }
> -- 
> 2.7.4
> 

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2017-12-16  6:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 13:42 [PATCH v5 0/3] platform/chrome: Support for cros_ec_accel_legacy driver Thierry Escande
2017-12-01 13:42 ` [PATCH v5 1/3] platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is missing Thierry Escande
2017-12-01 19:49   ` Gwendal Grignou
2017-12-16  6:12     ` Benson Leung
2017-12-16  6:03   ` Benson Leung
2017-12-16  6:04   ` Benson Leung [this message]
2017-12-01 13:42 ` [PATCH v5 2/3] platform/chrome: cros_ec_lpc: Add support for Google Glimmer Thierry Escande
2017-12-01 19:54   ` Gwendal Grignou
2017-12-05 21:55     ` Thierry Escande
2017-12-06 18:04       ` Gwendal Grignou
2017-12-16  6:10   ` Benson Leung
2017-12-01 13:42 ` [PATCH v5 3/3] platform/chrome: Register cros_ec_accel_legacy driver Thierry Escande
2017-12-01 20:00   ` Gwendal Grignou
2017-12-07  9:31     ` Lee Jones
2018-01-18  8:05       ` Gwendal Grignou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171216060458.GB140982@decatoncale.mtv.corp.google.com \
    --to=bleung@google.com \
    --cc=bleung@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thierry.escande@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).