Skip to contentSkip to conversation

Propose WMI patch

PATCH NAK Duarte Silva 2 participants 6 messages Sep 30, 2008 ACPI

lore
Share & tools
lore
#0 lore raw

Hi,

I wanted to propose a ACPI-WMI API change. Instead of having, wmi_has_guid returning a boolean, why not returning a acpi_status. It would allow extented error handling, and it would look more ACPI style :)

drivers/acpi/wmi.c +4 -2
index cfe2c83..cdff9bf 100644
@@ -194,14 +194,16 @@ static bool wmi_parse_guid(const u8 *src, u8 *dest)
 	return true;
 }
 
-static bool find_guid(const char *guid_string, struct wmi_block **out)
+static acpi_status find_guid(const char *guid_string, struct wmi_block **out)
 {
 	char tmp[16], guid_input[16];
 	struct wmi_block *wblock;
 	struct guid_block *block;
 	struct list_head *p;
 
-	wmi_parse_guid(guid_string, tmp);
+	if (!wmi_parse_guid(guid_string, tmp))
+		return AE_BAD_PARAMETER;
+
 	wmi_swap_bytes(tmp, guid_input);
 
 	list_for_each(p, &wmi_blocks.list) {
@@ -211,10 +213,10 @@ static bool find_guid(const char *guid_string, struct 

wmi_block **out)
if (memcmp(block->guid, guid_input, 16) == 0) {
if (out)
*out = wblock;
- return 1;
+ return AE_OK;
}
}
- return 0;
+ return AE_NOT_FOUND;
}

/*
@@ -241,8 +243,10 @@ u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)
union acpi_object params[3];
char method[4] = "WM";

- if (!find_guid(guid_string, &wblock))
- return AE_BAD_ADDRESS;
+ status = find_guid(guid_string, &wblock);
+
+ if (ACPI_FAILURE(status))
+ return status;

block = &wblock->gblock;
handle = wblock->handle;
@@ -303,7 +307,9 @@ struct acpi_buffer *out)
if (!guid_string || !out)
return AE_BAD_PARAMETER;

- if (!find_guid(guid_string, &wblock))
+ status = find_guid(guid_string, &wblock);
+
+ if (ACPI_FAILURE(status))
return AE_BAD_ADDRESS;

block = &wblock->gblock;
@@ -377,6 +383,7 @@ const struct acpi_buffer *in)
struct guid_block *block = NULL;
struct wmi_block *wblock = NULL;
acpi_handle handle;
+ acpi_status status;
struct acpi_object_list input;
union acpi_object params[2];
char method[4] = "WS";
@@ -384,7 +391,9 @@ const struct acpi_buffer *in)
if (!guid_string || !in)
return AE_BAD_DATA;

- if (!find_guid(guid_string, &wblock))
+ status = find_guid(guid_string, &wblock);
+
+ if (ACPI_FAILURE(status))
return AE_BAD_ADDRESS;

block = &wblock->gblock;
@@ -427,12 +436,14 @@ 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;

- find_guid(guid, &block);
- if (!block)
+ status = find_guid(guid, &block);
+
+ if (ACPI_FAILURE(status))
return AE_NOT_EXIST;

if (block->handler)
@@ -453,12 +464,14 @@ 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;

- find_guid(guid, &block);
- if (!block)
+ status = find_guid(guid, &block);
+
+ if (ACPI_FAILURE(status))
return AE_NOT_EXIST;

if (!block->handler)
@@ -507,15 +520,21 @@ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
EXPORT_SYMBOL_GPL(wmi_get_event_data);

/**
- * wmi_has_guid - Check if a GUID is available
+ * wmi_is_guid_present - Check if a GUID is available
* @guid_string: 36 char string of the form
fa50ff2b-f2e8-45de-83fa-65417f2f49ba
*
* Check if a given GUID is defined by _WDG
*/
-bool wmi_has_guid(const char *guid_string) +acpi_status wmi_is_guid_present(const char *guid_string)
{
return find_guid(guid_string, NULL);
}
+EXPORT_SYMBOL_GPL(wmi_is_guid_present);
+
+bool wmi_has_guid(const char *guid_string)
+{
+ return ACPI_SUCCESS(find_guid(guid_string, NULL));
+}
EXPORT_SYMBOL_GPL(wmi_has_guid);

/*

include/linux/acpi.h +0 -0
index 702f79d..26f9c0a 100644
@@ -198,6 +198,7 @@ extern acpi_status wmi_install_notify_handler(const char 

*guid,
wmi_notify_handler handler, void *data);
extern acpi_status wmi_remove_notify_handler(const char *guid); extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
+extern acpi_status wmi_is_guid_present(const char *guid);
extern bool wmi_has_guid(const char *guid);

#endif /* CONFIG_ACPI_WMI */

#1 lore raw
Quoted 3 lines · On Tuesday 30 September 2008 12:06:35 Duarte Silva wrote:

I wanted to propose a ACPI-WMI API change. Instead of having, wmi_has_guid returning a boolean, why not returning a acpi_status. It would allow extented error handling, and it would look more ACPI style :)

NAK.

We're not interested in ACPI error codes here, since we're never going to do anything with them.

We only care if the DSDT exists or not with this method - it's just a means of detection for other drivers.

-Carlos

Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
#2 lore raw
Quoted 5 lines · On Tuesday 30 September 2008 12:13:58 Carlos Corbacho wrote:
Quoted 3 lines · On Tuesday 30 September 2008 12:06:35 Duarte Silva wrote:

I wanted to propose a ACPI-WMI API change. Instead of having, wmi_has_guid returning a boolean, why not returning a acpi_status. It would allow extented error handling, and it would look more ACPI style :)

Quoted 7 lines

NAK.

We're not interested in ACPI error codes here, since we're never going to do anything with them.

We only care if the DSDT exists or not with this method - it's just a means of detection for other drivers.

s/DSDT/GUID/

-Carlos

Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
#3 lore raw
Quoted 18 lines · On Tuesday 30 September 2008 12:16:10 Carlos Corbacho wrote:
Quoted 6 lines · On Tuesday 30 September 2008 12:13:58 Carlos Corbacho wrote:
Quoted 4 lines · On Tuesday 30 September 2008 12:06:35 Duarte Silva wrote:

I wanted to propose a ACPI-WMI API change. Instead of having, wmi_has_guid returning a boolean, why not returning a acpi_status. It would allow extented error handling, and it would look more ACPI style :)

Quoted 7 lines

NAK.

We're not interested in ACPI error codes here, since we're never going to do anything with them.

We only care if the DSDT exists or not with this method - it's just a means of detection for other drivers.

s/DSDT/GUID/

-Carlos

Quoted 12 lines · On Tuesday 30 September 2008 12:16:10 you wrote:
Quoted 11 lines · On Tuesday 30 September 2008 12:13:58 Carlos Corbacho wrote:
Quoted 4 lines · On Tuesday 30 September 2008 12:06:35 Duarte Silva wrote:

I wanted to propose a ACPI-WMI API change. Instead of having, wmi_has_guid returning a boolean, why not returning a acpi_status. It would allow extented error handling, and it would look more ACPI style :)

NAK.

We're not interested in ACPI error codes here, since we're never going to do anything with them.

Quoted 6 lines
Quoted 2 lines

We only care if the DSDT exists or not with this method - it's just a means of detection for other drivers.

s/DSDT/GUID/

-Carlos

For instance, it would be nice to be able to do this,

for (i = 0; i < ARRAY_SIZE(laptop->methods); i++)
        laptop->methods[i].status =
wmi_is_guid_present(laptop->methods[i].guid);

instead of

for (i = 0; i < ARRAY_SIZE(laptop->methods); i++) if (wmi_has_guid(laptop->methods[i].guid)) laptop->methods[i].status = AE_OK; else
                laptop->methods[i].status = AE_NOT_FOUND;

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 6 lines · On Tuesday 30 September 2008 12:29:17 Duarte Silva wrote:

For instance, it would be nice to be able to do this,

for (i = 0; i < ARRAY_SIZE(laptop->methods); i++)
        laptop->methods[i].status =
wmi_is_guid_present(laptop->methods[i].guid);

Quoted 7 lines

instead of

for (i = 0; i < ARRAY_SIZE(laptop->methods); i++) if (wmi_has_guid(laptop->methods[i].guid)) laptop->methods[i].status = AE_OK; else
                laptop->methods[i].status = AE_NOT_FOUND;

Why not just do:

for (i = 0; i < ARRAY_SIZE(laptop->methods); i++)

         laptop->methods[i].exists =
                 wmi_is_guid_present(laptop->methods[i].guid);

I don't see why you need an ACPI status here, when a simple bool will do just fine?

Otherwise, instead of being able to do this:

if (laptop->methods[i].exists) {
        /* do something */
}

you end up having to use one of the ACPI status wrappers all the time:

if (ACPI_SUCCESS(laptop->methods[i].status)) {
         /* do something */
}

-Carlos

Signature · 7 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 30 lines · On Tuesday 30 September 2008 12:40:33 Carlos Corbacho wrote:
Quoted 6 lines · On Tuesday 30 September 2008 12:29:17 Duarte Silva wrote:

For instance, it would be nice to be able to do this,

for (i = 0; i < ARRAY_SIZE(laptop->methods); i++)
        laptop->methods[i].status =
wmi_is_guid_present(laptop->methods[i].guid);

Quoted 7 lines

instead of

for (i = 0; i < ARRAY_SIZE(laptop->methods); i++) if (wmi_has_guid(laptop->methods[i].guid)) laptop->methods[i].status = AE_OK; else
                laptop->methods[i].status = AE_NOT_FOUND;

Why not just do:

for (i = 0; i < ARRAY_SIZE(laptop->methods); i++)

         laptop->methods[i].exists =
                 wmi_is_guid_present(laptop->methods[i].guid);

I don't see why you need an ACPI status here, when a simple bool will do just fine?

Otherwise, instead of being able to do this:

if (laptop->methods[i].exists) {
        /* do something */
}
Quoted 7 lines

you end up having to use one of the ACPI status wrappers all the time:

if (ACPI_SUCCESS(laptop->methods[i].status)) {
         /* do something */
}

-Carlos

yes, a bool should suffice, thanks :)

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html