* Propose WMI patch
@ 2008-09-30 11:06 Duarte Silva
2008-09-30 11:13 ` Carlos Corbacho
0 siblings, 1 reply; 6+ messages in thread
From: Duarte Silva @ 2008-09-30 11:06 UTC (permalink / raw)
To: linux-acpi
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 :)
diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c
index cfe2c83..cdff9bf 100644
--- a/drivers/acpi/wmi.c
+++ b/drivers/acpi/wmi.c
@@ -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);
/*
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 702f79d..26f9c0a 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -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 */
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: Propose WMI patch
2008-09-30 11:06 Propose WMI patch Duarte Silva
@ 2008-09-30 11:13 ` Carlos Corbacho
2008-09-30 11:16 ` Carlos Corbacho
0 siblings, 1 reply; 6+ messages in thread
From: Carlos Corbacho @ 2008-09-30 11:13 UTC (permalink / raw)
To: Duarte Silva; +Cc: linux-acpi
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
--
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Propose WMI patch
2008-09-30 11:13 ` Carlos Corbacho
@ 2008-09-30 11:16 ` Carlos Corbacho
2008-09-30 11:29 ` Duarte Silva
0 siblings, 1 reply; 6+ messages in thread
From: Carlos Corbacho @ 2008-09-30 11:16 UTC (permalink / raw)
To: Duarte Silva; +Cc: linux-acpi
On Tuesday 30 September 2008 12:13:58 Carlos Corbacho wrote:
> 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.
s/DSDT/GUID/
-Carlos
--
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Propose WMI patch
2008-09-30 11:16 ` Carlos Corbacho
@ 2008-09-30 11:29 ` Duarte Silva
2008-09-30 11:40 ` Carlos Corbacho
0 siblings, 1 reply; 6+ messages in thread
From: Duarte Silva @ 2008-09-30 11:29 UTC (permalink / raw)
To: linux-acpi
On Tuesday 30 September 2008 12:16:10 Carlos Corbacho wrote:
> On Tuesday 30 September 2008 12:13:58 Carlos Corbacho wrote:
> > 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.
>
> s/DSDT/GUID/
>
> -Carlos
On Tuesday 30 September 2008 12:16:10 you wrote:
> On Tuesday 30 September 2008 12:13:58 Carlos Corbacho wrote:
> > 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.
>
> 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Propose WMI patch
2008-09-30 11:29 ` Duarte Silva
@ 2008-09-30 11:40 ` Carlos Corbacho
2008-09-30 13:05 ` Duarte Silva
0 siblings, 1 reply; 6+ messages in thread
From: Carlos Corbacho @ 2008-09-30 11:40 UTC (permalink / raw)
To: Duarte Silva; +Cc: linux-acpi
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);
>
> 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
--
E-Mail: carlos@strangeworlds.co.uk
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Propose WMI patch
2008-09-30 11:40 ` Carlos Corbacho
@ 2008-09-30 13:05 ` Duarte Silva
0 siblings, 0 replies; 6+ messages in thread
From: Duarte Silva @ 2008-09-30 13:05 UTC (permalink / raw)
To: linux-acpi
On Tuesday 30 September 2008 12:40:33 Carlos Corbacho wrote:
> 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);
> >
> > 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
yes, a bool should suffice, thanks :)
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-30 13:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-30 11:06 Propose WMI patch Duarte Silva
2008-09-30 11:13 ` Carlos Corbacho
2008-09-30 11:16 ` Carlos Corbacho
2008-09-30 11:29 ` Duarte Silva
2008-09-30 11:40 ` Carlos Corbacho
2008-09-30 13:05 ` Duarte Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox