Subject: [PATCH] [acpi events] Add infrastructure for specifying events to listen for - Create struct acpi_event for describing a single event - Add helper macros for declaring events - Add declare_acpi_events() for drivers to use to describe a set of events - Add ->e_events and ->e_num_events fields to struct acpi_device_event - Fixup setting of ->e_fixed in acpi_device_event_fixed(). Signed-off-by: Patrick Mochel --- include/acpi/event.h | 81 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 76 insertions(+), 5 deletions(-) applies-to: d548715930cb0306a8ac726c5f4b4e8d2f88e53c f00247b97d5a019147f5ba7950e39ba48edfbc75 diff --git a/include/acpi/event.h b/include/acpi/event.h index d20b618..bba481d 100644 --- a/include/acpi/event.h +++ b/include/acpi/event.h @@ -1,6 +1,70 @@ #include + +/** + * struct acpi_event + * + * This structure describes a single ACPI event for a + * driver. The fields are: + * + * ->e_event is the driver is listening for + * + * ->e_raise is a flag that tells the event core whether + * to raise an ACPI bus event when the event is caught. + * (using acpi_bus_generate_event(). + */ + +struct acpi_event { + u32 e_event; + int e_raise; +}; + + +/** + * acpi_event_raise() - Declare an event that raises an event. + * @__event - The enumerated event. + */ + +#define acpi_event_raise(__event) \ + { \ + .e_event = __event, \ + .e_raise = 1, \ + }, + +/** + * acpi_event_no_raise() - Declare an event that doesn't raise an event. + * @__event - The enumerated event. + */ + +#define acpi_event_no_raise(__event) \ + { \ + .e_event = __event, \ + .e_raise = 0, \ + }, + + +/** + * declare_acpi_events() - Declare a set of events to listen for + * @__name - The driver name. + * @... - The list of events. + * + * This macro should be used by drivers to declare a set of + * events that it wants to listen for. The two macros above + * (acpi_event_raise() and acpi_event_no_raise()) should be + * used within this to declare the individual events. + * + * Please see the AC, battery, or button drivers for an + * example of how to use this. + */ + +#define declare_acpi_events(__name, ... ) \ +static struct acpi_event __name##_events[] = { \ + __VA_ARGS__ \ +} + + + /** * struct acpi_fixed_events * @@ -44,8 +108,11 @@ static struct acpi_fixed_events __name## .f_num_fixed = ARRAY_SIZE(__name##_fixed_events), \ } + struct acpi_device_event { u32 e_type; + struct acpi_event * e_events; + u32 e_num_events; acpi_notify_handler e_handler; struct acpi_fixed_events * e_fixed; }; @@ -64,10 +131,12 @@ struct acpi_device_event { * For a simple example, see the AC driver. */ -#define acpi_device_event(__name)\ -struct acpi_device_event __name##_event = { \ - .e_type = ACPI_DEVICE_NOTIFY, \ - .e_handler = __name##_notify, \ +#define acpi_device_event(__name) \ +struct acpi_device_event __name##_event = { \ + .e_type = ACPI_DEVICE_NOTIFY, \ + .e_events = __name##_events, \ + .e_num_events = ARRAY_SIZE(__name##_events), \ + .e_handler = __name##_notify, \ } @@ -84,8 +153,10 @@ struct acpi_device_event __name##_event #define acpi_device_event_fixed(__name) \ struct acpi_device_event __name##_event = { \ .e_type = ACPI_DEVICE_NOTIFY, \ + .e_events = __name##_events, \ + .e_num_events = ARRAY_SIZE(__name##_events), \ .e_handler = __name##_notify, \ - .e_fixed = __name##_fixed, \ + .e_fixed = & __name##_fixed, \ } --- 0.99.9.GIT