public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] acpi-wmi: Enable event methods when registering notifiers
@ 2008-08-27 15:04 Matthew Garrett
  2008-08-27 21:15 ` Carlos Corbacho
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Garrett @ 2008-08-27 15:04 UTC (permalink / raw)
  To: Carlos Corbacho; +Cc: linux-acpi, linux-kernel

According to the ACPI-WMI spec, event blocks may provide a function call 
for enabling/disabling them. This patch adds support for making these 
calls when registering or removing notifications. Without this, my Dell 
firmware provides no data in the event notification.

Signed-off-by: Matthew Garrett <mjg@redhat.com>

---

diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c
index c33b1c6..c7f735f 100644
--- a/drivers/acpi/wmi.c
+++ b/drivers/acpi/wmi.c
@@ -217,6 +217,35 @@ static bool find_guid(const char *guid_string, struct wmi_block **out)
 	return 0;
 }
 
+static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
+{
+	struct guid_block *block = NULL;
+	char method[5];
+	struct acpi_object_list input;
+	union acpi_object params[1];
+	acpi_status status;
+	acpi_handle handle;
+
+	block = &wblock->gblock;
+	handle = wblock->handle;
+
+	if (!block)
+		return AE_NOT_EXIST;
+
+	input.count = 1;
+	input.pointer = params;
+	params[0].type = ACPI_TYPE_INTEGER;
+	params[0].integer.value = enable;
+
+	snprintf(method, 5, "WE%02X", block->notify_id);
+	status = acpi_evaluate_object(handle, method, &input, NULL);
+
+	if (status != AE_OK && status != AE_NOT_FOUND)
+		return status;
+	else
+		return AE_OK;
+}
+
 /*
  * Exported WMI functions
  */
@@ -427,6 +456,7 @@ acpi_status wmi_install_notify_handler(const char *guid,
 wmi_notify_handler handler, void *data)
 {
 	struct wmi_block *block;
+	acpi_status status;
 
 	if (!guid || !handler)
 		return AE_BAD_PARAMETER;
@@ -441,7 +471,9 @@ wmi_notify_handler handler, void *data)
 	block->handler = handler;
 	block->handler_data = data;
 
-	return AE_OK;
+	status = wmi_method_enable(block, 1);
+
+	return status;
 }
 EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
 
@@ -453,6 +485,7 @@ EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
 acpi_status wmi_remove_notify_handler(const char *guid)
 {
 	struct wmi_block *block;
+	acpi_status status;
 
 	if (!guid)
 		return AE_BAD_PARAMETER;
@@ -464,10 +497,12 @@ acpi_status wmi_remove_notify_handler(const char *guid)
 	if (!block->handler)
 		return AE_NULL_ENTRY;
 
+	status = wmi_method_enable(block, 0);
+
 	block->handler = NULL;
 	block->handler_data = NULL;
 
-	return AE_OK;
+	return status;
 }
 EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);
 
-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] acpi-wmi: Enable event methods when registering notifiers
  2008-08-27 15:04 [PATCH] acpi-wmi: Enable event methods when registering notifiers Matthew Garrett
@ 2008-08-27 21:15 ` Carlos Corbacho
  0 siblings, 0 replies; 2+ messages in thread
From: Carlos Corbacho @ 2008-08-27 21:15 UTC (permalink / raw)
  To: Matthew Garrett; +Cc: linux-acpi, linux-kernel, Andi Kleen

On Wednesday 27 August 2008 16:04:01 Matthew Garrett wrote:
> According to the ACPI-WMI spec, event blocks may provide a function call
> for enabling/disabling them. This patch adds support for making these
> calls when registering or removing notifications. Without this, my Dell
> firmware provides no data in the event notification.
>
> Signed-off-by: Matthew Garrett <mjg@redhat.com>

Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

Andi, can you take this into the ACPI tree?

>
> ---
>
> diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c
> index c33b1c6..c7f735f 100644
> --- a/drivers/acpi/wmi.c
> +++ b/drivers/acpi/wmi.c
> @@ -217,6 +217,35 @@ static bool find_guid(const char *guid_string, struct
> wmi_block **out) return 0;
>  }
>
> +static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
> +{
> +	struct guid_block *block = NULL;
> +	char method[5];
> +	struct acpi_object_list input;
> +	union acpi_object params[1];
> +	acpi_status status;
> +	acpi_handle handle;
> +
> +	block = &wblock->gblock;
> +	handle = wblock->handle;
> +
> +	if (!block)
> +		return AE_NOT_EXIST;
> +
> +	input.count = 1;
> +	input.pointer = params;
> +	params[0].type = ACPI_TYPE_INTEGER;
> +	params[0].integer.value = enable;
> +
> +	snprintf(method, 5, "WE%02X", block->notify_id);
> +	status = acpi_evaluate_object(handle, method, &input, NULL);
> +
> +	if (status != AE_OK && status != AE_NOT_FOUND)
> +		return status;
> +	else
> +		return AE_OK;
> +}
> +
>  /*
>   * Exported WMI functions
>   */
> @@ -427,6 +456,7 @@ acpi_status wmi_install_notify_handler(const char
> *guid, wmi_notify_handler handler, void *data)
>  {
>  	struct wmi_block *block;
> +	acpi_status status;
>
>  	if (!guid || !handler)
>  		return AE_BAD_PARAMETER;
> @@ -441,7 +471,9 @@ wmi_notify_handler handler, void *data)
>  	block->handler = handler;
>  	block->handler_data = data;
>
> -	return AE_OK;
> +	status = wmi_method_enable(block, 1);
> +
> +	return status;
>  }
>  EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
>
> @@ -453,6 +485,7 @@ EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
>  acpi_status wmi_remove_notify_handler(const char *guid)
>  {
>  	struct wmi_block *block;
> +	acpi_status status;
>
>  	if (!guid)
>  		return AE_BAD_PARAMETER;
> @@ -464,10 +497,12 @@ acpi_status wmi_remove_notify_handler(const char
> *guid) if (!block->handler)
>  		return AE_NULL_ENTRY;
>
> +	status = wmi_method_enable(block, 0);
> +
>  	block->handler = NULL;
>  	block->handler_data = NULL;
>
> -	return AE_OK;
> +	return status;
>  }
>  EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);



-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-27 21:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-27 15:04 [PATCH] acpi-wmi: Enable event methods when registering notifiers Matthew Garrett
2008-08-27 21:15 ` Carlos Corbacho

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox