* [PATCH 2/6] ACPI: ac: use .notify method instead of installing handler directly
[not found] ` <20090430153419.12628.91088.stgit-tBlMHHroXgg@public.gmane.org>
@ 2009-04-30 15:35 ` Bjorn Helgaas
2009-04-30 15:35 ` [PATCH 4/6] ACPI: asus-laptop: " Bjorn Helgaas
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Bjorn Helgaas @ 2009-04-30 15:35 UTC (permalink / raw)
To: Len Brown
Cc: Karol Kozimor, acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-acpi-u79uwXL29TY76Z2rM5mHXA, Alexey Starikovskiy,
Matthew Garrett
This patch adds a .notify() method. The presence of .notify() causes
Linux/ACPI to manage event handlers and notify handlers on our behalf,
so we don't have to install and remove them ourselves.
This driver apparently relies on seeing ALL notify events, not just
device-specific ones (because it used ACPI_ALL_NOTIFY). We use the
ACPI_DRIVER_ALL_NOTIFY_EVENTS driver flag to request all events.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
CC: Alexey Starikovskiy <alexey.y.starikovskiy-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/acpi/ac.c | 20 +++++---------------
1 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 88e42ab..0df8fcb 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -61,6 +61,7 @@ static int acpi_ac_open_fs(struct inode *inode, struct file *file);
static int acpi_ac_add(struct acpi_device *device);
static int acpi_ac_remove(struct acpi_device *device, int type);
static int acpi_ac_resume(struct acpi_device *device);
+static void acpi_ac_notify(struct acpi_device *device, u32 event);
static const struct acpi_device_id ac_device_ids[] = {
{"ACPI0003", 0},
@@ -72,10 +73,12 @@ static struct acpi_driver acpi_ac_driver = {
.name = "ac",
.class = ACPI_AC_CLASS,
.ids = ac_device_ids,
+ .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = {
.add = acpi_ac_add,
.remove = acpi_ac_remove,
.resume = acpi_ac_resume,
+ .notify = acpi_ac_notify,
},
};
@@ -220,16 +223,14 @@ static int acpi_ac_remove_fs(struct acpi_device *device)
Driver Model
-------------------------------------------------------------------------- */
-static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
+static void acpi_ac_notify(struct acpi_device *device, u32 event)
{
- struct acpi_ac *ac = data;
- struct acpi_device *device = NULL;
+ struct acpi_ac *ac = acpi_driver_data(device);
if (!ac)
return;
- device = ac->device;
switch (event) {
default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -253,7 +254,6 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
static int acpi_ac_add(struct acpi_device *device)
{
int result = 0;
- acpi_status status = AE_OK;
struct acpi_ac *ac = NULL;
@@ -286,13 +286,6 @@ static int acpi_ac_add(struct acpi_device *device)
ac->charger.get_property = get_ac_property;
power_supply_register(&ac->device->dev, &ac->charger);
#endif
- status = acpi_install_notify_handler(device->handle,
- ACPI_ALL_NOTIFY, acpi_ac_notify,
- ac);
- if (ACPI_FAILURE(status)) {
- result = -ENODEV;
- goto end;
- }
printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
acpi_device_name(device), acpi_device_bid(device),
@@ -328,7 +321,6 @@ static int acpi_ac_resume(struct acpi_device *device)
static int acpi_ac_remove(struct acpi_device *device, int type)
{
- acpi_status status = AE_OK;
struct acpi_ac *ac = NULL;
@@ -337,8 +329,6 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
ac = acpi_driver_data(device);
- status = acpi_remove_notify_handler(device->handle,
- ACPI_ALL_NOTIFY, acpi_ac_notify);
#ifdef CONFIG_ACPI_SYSFS_POWER
if (ac->charger.dev)
power_supply_unregister(&ac->charger);
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 4/6] ACPI: asus-laptop: use .notify method instead of installing handler directly
[not found] ` <20090430153419.12628.91088.stgit-tBlMHHroXgg@public.gmane.org>
2009-04-30 15:35 ` [PATCH 2/6] ACPI: ac: " Bjorn Helgaas
@ 2009-04-30 15:35 ` Bjorn Helgaas
2009-04-30 15:35 ` [PATCH 5/6] ACPI: asus-acpi: " Bjorn Helgaas
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Bjorn Helgaas @ 2009-04-30 15:35 UTC (permalink / raw)
To: Len Brown
Cc: Karol Kozimor, acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-acpi-u79uwXL29TY76Z2rM5mHXA, Alexey Starikovskiy,
Matthew Garrett
This patch adds a .notify() method. The presence of .notify() causes
Linux/ACPI to manage event handlers and notify handlers on our behalf,
so we don't have to install and remove them ourselves.
This driver apparently relies on seeing ALL notify events, not just
device-specific ones (because it used ACPI_ALL_NOTIFY). We use the
ACPI_DRIVER_ALL_NOTIFY_EVENTS driver flag to request all events.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
CC: Corentin Chary <corentincj-EjuBZuxMvz2sTnJN9+BGXg@public.gmane.org>
CC: acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
---
drivers/platform/x86/asus-laptop.c | 23 +++++------------------
1 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index eeafc6c..22a38fe 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -207,13 +207,17 @@ MODULE_DEVICE_TABLE(acpi, asus_device_ids);
static int asus_hotk_add(struct acpi_device *device);
static int asus_hotk_remove(struct acpi_device *device, int type);
+static void asus_hotk_notify(struct acpi_device *device, u32 event);
+
static struct acpi_driver asus_hotk_driver = {
.name = ASUS_HOTK_NAME,
.class = ASUS_HOTK_CLASS,
.ids = asus_device_ids,
+ .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = {
.add = asus_hotk_add,
.remove = asus_hotk_remove,
+ .notify = asus_hotk_notify,
},
};
@@ -812,7 +816,7 @@ static int asus_setkeycode(struct input_dev *dev, int scancode, int keycode)
return -EINVAL;
}
-static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
+static void asus_hotk_notify(struct acpi_device *device, u32 event)
{
static struct key_entry *key;
u16 count;
@@ -1124,7 +1128,6 @@ static int asus_hotk_found;
static int asus_hotk_add(struct acpi_device *device)
{
- acpi_status status = AE_OK;
int result;
if (!device)
@@ -1149,15 +1152,6 @@ static int asus_hotk_add(struct acpi_device *device)
asus_hotk_add_fs();
- /*
- * We install the handler, it will receive the hotk in parameter, so, we
- * could add other data to the hotk struct
- */
- status = acpi_install_notify_handler(hotk->handle, ACPI_ALL_NOTIFY,
- asus_hotk_notify, hotk);
- if (ACPI_FAILURE(status))
- printk(ASUS_ERR "Error installing notify handler\n");
-
asus_hotk_found = 1;
/* WLED and BLED are on by default */
@@ -1198,16 +1192,9 @@ end:
static int asus_hotk_remove(struct acpi_device *device, int type)
{
- acpi_status status = 0;
-
if (!device || !acpi_driver_data(device))
return -EINVAL;
- status = acpi_remove_notify_handler(hotk->handle, ACPI_ALL_NOTIFY,
- asus_hotk_notify);
- if (ACPI_FAILURE(status))
- printk(ASUS_ERR "Error removing notify handler\n");
-
kfree(hotk->name);
kfree(hotk);
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 5/6] ACPI: asus-acpi: use .notify method instead of installing handler directly
[not found] ` <20090430153419.12628.91088.stgit-tBlMHHroXgg@public.gmane.org>
2009-04-30 15:35 ` [PATCH 2/6] ACPI: ac: " Bjorn Helgaas
2009-04-30 15:35 ` [PATCH 4/6] ACPI: asus-laptop: " Bjorn Helgaas
@ 2009-04-30 15:35 ` Bjorn Helgaas
2009-04-30 15:36 ` [PATCH 6/6] ACPI: eeepc-laptop: " Bjorn Helgaas
2009-05-27 22:51 ` [PATCH 0/6] ACPI: support system events for .notify Len Brown
4 siblings, 0 replies; 11+ messages in thread
From: Bjorn Helgaas @ 2009-04-30 15:35 UTC (permalink / raw)
To: Len Brown
Cc: Karol Kozimor, acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-acpi-u79uwXL29TY76Z2rM5mHXA, Alexey Starikovskiy,
Matthew Garrett
This patch adds a .notify() method. The presence of .notify() causes
Linux/ACPI to manage event handlers and notify handlers on our behalf,
so we don't have to install and remove them ourselves.
This driver relies on seeing system notify events, not device-specific
ones (because it used ACPI_SYSTEM_NOTIFY). We use the
ACPI_DRIVER_ALL_NOTIFY_EVENTS driver flag to request all events, then
just ignore any device events we get.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
CC: Corentin Chary <corentincj-EjuBZuxMvz2sTnJN9+BGXg@public.gmane.org>
CC: Karol Kozimor <sziwan-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
CC: acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
---
drivers/platform/x86/asus_acpi.c | 30 +++++++++++++-----------------
1 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c
index ba1f749..ddf5240 100644
--- a/drivers/platform/x86/asus_acpi.c
+++ b/drivers/platform/x86/asus_acpi.c
@@ -455,6 +455,8 @@ static struct asus_hotk *hotk;
*/
static int asus_hotk_add(struct acpi_device *device);
static int asus_hotk_remove(struct acpi_device *device, int type);
+static void asus_hotk_notify(struct acpi_device *device, u32 event);
+
static const struct acpi_device_id asus_device_ids[] = {
{"ATK0100", 0},
{"", 0},
@@ -465,9 +467,11 @@ static struct acpi_driver asus_hotk_driver = {
.name = "asus_acpi",
.class = ACPI_HOTK_CLASS,
.ids = asus_device_ids,
+ .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = {
.add = asus_hotk_add,
.remove = asus_hotk_remove,
+ .notify = asus_hotk_notify,
},
};
@@ -1101,12 +1105,20 @@ static int asus_hotk_remove_fs(struct acpi_device *device)
return 0;
}
-static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
+static void asus_hotk_notify(struct acpi_device *device, u32 event)
{
/* TODO Find a better way to handle events count. */
if (!hotk)
return;
+ /*
+ * The BIOS *should* be sending us device events, but apparently
+ * Asus uses system events instead, so just ignore any device
+ * events we get.
+ */
+ if (event > ACPI_MAX_SYS_NOTIFY)
+ return;
+
if ((event & ~((u32) BR_UP)) < 16)
hotk->brightness = (event & ~((u32) BR_UP));
else if ((event & ~((u32) BR_DOWN)) < 16)
@@ -1346,15 +1358,6 @@ static int asus_hotk_add(struct acpi_device *device)
if (result)
goto end;
- /*
- * We install the handler, it will receive the hotk in parameter, so, we
- * could add other data to the hotk struct
- */
- status = acpi_install_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
- asus_hotk_notify, hotk);
- if (ACPI_FAILURE(status))
- printk(KERN_ERR " Error installing notify handler\n");
-
/* For laptops without GPLV: init the hotk->brightness value */
if ((!hotk->methods->brightness_get)
&& (!hotk->methods->brightness_status)
@@ -1389,16 +1392,9 @@ end:
static int asus_hotk_remove(struct acpi_device *device, int type)
{
- acpi_status status = 0;
-
if (!device || !acpi_driver_data(device))
return -EINVAL;
- status = acpi_remove_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
- asus_hotk_notify);
- if (ACPI_FAILURE(status))
- printk(KERN_ERR "Asus ACPI: Error removing notify handler\n");
-
asus_hotk_remove_fs(device);
kfree(hotk);
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 6/6] ACPI: eeepc-laptop: use .notify method instead of installing handler directly
[not found] ` <20090430153419.12628.91088.stgit-tBlMHHroXgg@public.gmane.org>
` (2 preceding siblings ...)
2009-04-30 15:35 ` [PATCH 5/6] ACPI: asus-acpi: " Bjorn Helgaas
@ 2009-04-30 15:36 ` Bjorn Helgaas
2009-05-27 22:47 ` Len Brown
2009-05-27 22:51 ` [PATCH 0/6] ACPI: support system events for .notify Len Brown
4 siblings, 1 reply; 11+ messages in thread
From: Bjorn Helgaas @ 2009-04-30 15:36 UTC (permalink / raw)
To: Len Brown
Cc: Karol Kozimor, acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-acpi-u79uwXL29TY76Z2rM5mHXA, Alexey Starikovskiy,
Matthew Garrett
This patch adds a .notify() method. The presence of .notify() causes
Linux/ACPI to manage event handlers and notify handlers on our behalf,
so we don't have to install and remove them ourselves.
This driver relies on seeing system notify events, not device-specific
ones (because it used ACPI_SYSTEM_NOTIFY). We use the
ACPI_DRIVER_ALL_NOTIFY_EVENTS driver flag to request all events, then
just ignore any device events we get.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
CC: Corentin Chary <corentincj-EjuBZuxMvz2sTnJN9+BGXg@public.gmane.org>
CC: acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
CC: Matthew Garrett <mjg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
drivers/platform/x86/eeepc-laptop.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 6f54fd1..d9424fd 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -177,6 +177,7 @@ static struct key_entry eeepc_keymap[] = {
*/
static int eeepc_hotk_add(struct acpi_device *device);
static int eeepc_hotk_remove(struct acpi_device *device, int type);
+static void eeepc_hotk_notify(struct acpi_device *device, u32 event);
static const struct acpi_device_id eeepc_device_ids[] = {
{EEEPC_HOTK_HID, 0},
@@ -188,9 +189,11 @@ static struct acpi_driver eeepc_hotk_driver = {
.name = EEEPC_HOTK_NAME,
.class = EEEPC_HOTK_CLASS,
.ids = eeepc_device_ids,
+ .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = {
.add = eeepc_hotk_add,
.remove = eeepc_hotk_remove,
+ .notify = eeepc_hotk_notify,
},
};
@@ -554,13 +557,15 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
}
}
-static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
+static void eeepc_hotk_notify(struct acpi_device *device, u32 event)
{
static struct key_entry *key;
u16 count;
if (!ehotk)
return;
+ if (event > ACPI_MAX_SYS_NOTIFY)
+ return;
if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
notify_brn();
count = ehotk->event_count[event % 128]++;
@@ -626,7 +631,6 @@ static void eeepc_unregister_rfkill_notifier(char *node)
static int eeepc_hotk_add(struct acpi_device *device)
{
- acpi_status status = AE_OK;
int result;
if (!device)
@@ -644,11 +648,6 @@ static int eeepc_hotk_add(struct acpi_device *device)
result = eeepc_hotk_check();
if (result)
goto ehotk_fail;
- status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY,
- eeepc_hotk_notify, ehotk);
- if (ACPI_FAILURE(status))
- printk(EEEPC_ERR "Error installing notify handler\n");
-
if (get_acpi(CM_ASL_WLAN) != -1) {
ehotk->eeepc_wlan_rfkill = rfkill_allocate(&device->dev,
RFKILL_TYPE_WLAN);
@@ -726,14 +725,8 @@ static int eeepc_hotk_add(struct acpi_device *device)
static int eeepc_hotk_remove(struct acpi_device *device, int type)
{
- acpi_status status = 0;
-
if (!device || !acpi_driver_data(device))
return -EINVAL;
- status = acpi_remove_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY,
- eeepc_hotk_notify);
- if (ACPI_FAILURE(status))
- printk(EEEPC_ERR "Error removing notify handler\n");
eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 0/6] ACPI: support system events for .notify
[not found] ` <20090430153419.12628.91088.stgit-tBlMHHroXgg@public.gmane.org>
` (3 preceding siblings ...)
2009-04-30 15:36 ` [PATCH 6/6] ACPI: eeepc-laptop: " Bjorn Helgaas
@ 2009-05-27 22:51 ` Len Brown
4 siblings, 0 replies; 11+ messages in thread
From: Len Brown @ 2009-05-27 22:51 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Karol Kozimor, acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-acpi-u79uwXL29TY76Z2rM5mHXA, Alexey Starikovskiy,
Matthew Garrett
applied to acpi-test
thanks,
Len Brown, Intel Open Source Technology Center
On Thu, 30 Apr 2009, Bjorn Helgaas wrote:
> This series extends the .notify method I recently added so drivers
> can request system notification events as well as device-specific
> events. This simplifies some drivers a bit.
>
> Comments welcome.
>
> ---
>
> Bjorn Helgaas (6):
> ACPI: eeepc-laptop: use .notify method instead of installing handler directly
> ACPI: asus-acpi: use .notify method instead of installing handler directly
> ACPI: asus-laptop: use .notify method instead of installing handler directly
> ACPI: battery: use .notify method instead of installing handler directly
> ACPI: ac: use .notify method instead of installing handler directly
> ACPI: allow drivers to request both device and system notify events
>
>
> drivers/acpi/ac.c | 20 +++++---------------
> drivers/acpi/battery.c | 22 +++++-----------------
> drivers/acpi/bus.c | 6 +++++-
> drivers/platform/x86/asus-laptop.c | 23 +++++------------------
> drivers/platform/x86/asus_acpi.c | 30 +++++++++++++-----------------
> drivers/platform/x86/eeepc-laptop.c | 19 ++++++-------------
> include/acpi/acpi_bus.h | 3 +++
> 7 files changed, 42 insertions(+), 81 deletions(-)
>
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
^ permalink raw reply [flat|nested] 11+ messages in thread