From 962ce8ca0604af0c3c5609f7613d4ec5fcfac623 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 23 Aug 2007 01:24:31 +0800 Subject: ACPI: don't duplicate input events on netlink The previous events patch added a netlink event for every user of the legacy /proc/acpi/event interface. However, some users of /proc/acpi/event are really input events, and they already report their events via the input layer. Introduce a new interface, acpi_bus_generate_netlink_event(), which is explicitly called by devices that want to repoprt events via netlink. This allows the input-like events to opt-out of generating netlink events. In summary: events that are sent via netlink: ac/battery/sbs thermal processor thinkpad_acpi dock/bay events that are sent via input layer: button video hotkey thinkpad_acpi hotkey asus_acpi/asus-laptop hotkey sonypi/sonylaptop Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/ac.c | 3 +++ drivers/acpi/battery.c | 3 +++ drivers/acpi/bus.c | 4 ---- drivers/acpi/event.c | 13 +++++++++---- drivers/acpi/processor_core.c | 7 +++++++ drivers/acpi/sbs.c | 1 + drivers/acpi/thermal.c | 12 ++++++++++++ 7 files changed, 35 insertions(+), 8 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index d8b35093527..b53c2cfcafd 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -205,6 +205,9 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) case ACPI_NOTIFY_DEVICE_CHECK: acpi_ac_get_state(ac); acpi_bus_generate_event(device, event, (u32) ac->state); + acpi_bus_generate_netlink_event(device->pnp.device_class, + device->dev.bus_id, event, + (u32) ac->state); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index d7b499fe0cd..9f0bf90afda 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -869,6 +869,9 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) acpi_battery_notify_update(battery); acpi_bus_generate_event(device, event, acpi_battery_present(battery)); + acpi_bus_generate_netlink_event(device->pnp.device_class, + device->dev.bus_id, event, + acpi_battery_present(battery)); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 6b2658c9624..e5084ececb6 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -292,10 +292,6 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data) if (!device) return -EINVAL; - if (acpi_bus_generate_genetlink_event(device, type, data)) - printk(KERN_WARNING PREFIX - "Failed to generate an ACPI event via genetlink!\n"); - /* drop event on the floor if no one's listening */ if (!event_is_open) return 0; diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index 95637a4ff78..b7b143288c2 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c @@ -147,7 +147,8 @@ static struct genl_multicast_group acpi_event_mcgrp = { .name = ACPI_GENL_MCAST_GROUP_NAME, }; -int acpi_bus_generate_genetlink_event(struct acpi_device *device, +int acpi_bus_generate_netlink_event(const char *device_class, + const char *bus_id, u8 type, int data) { struct sk_buff *skb; @@ -191,8 +192,8 @@ int acpi_bus_generate_genetlink_event(struct acpi_device *device, memset(event, 0, sizeof(struct acpi_genl_event)); - strcpy(event->device_class, device->pnp.device_class); - strcpy(event->bus_id, device->dev.bus_id); + strcpy(event->device_class, device_class); + strcpy(event->bus_id, bus_id); event->type = type; event->data = data; @@ -211,6 +212,8 @@ int acpi_bus_generate_genetlink_event(struct acpi_device *device, return 0; } +EXPORT_SYMBOL(acpi_bus_generate_netlink_event); + static int acpi_event_genetlink_init(void) { int result; @@ -228,12 +231,14 @@ static int acpi_event_genetlink_init(void) } #else -int acpi_bus_generate_genetlink_event(struct acpi_device *device, u8 type, +int acpi_bus_generate_netlink_event(struct acpi_device *device, u8 type, int data) { return 0; } +EXPORT_SYMBOL(acpi_generate_netlink_event); + static int acpi_event_genetlink_init(void) { return -ENODEV; diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 498422343f3..dbc2e5d9d6a 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -700,14 +700,21 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) acpi_processor_ppc_has_changed(pr); acpi_bus_generate_event(device, event, pr->performance_platform_limit); + acpi_bus_generate_netlink_event(device->pnp.device_class, + device->dev.bus_id, event, + pr->performance_platform_limit); break; case ACPI_PROCESSOR_NOTIFY_POWER: acpi_processor_cst_has_changed(pr); acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_netlink_event(device->pnp.device_class, + device->dev.bus_id, event, 0); break; case ACPI_PROCESSOR_NOTIFY_THROTTLING: acpi_processor_tstate_has_changed(pr); acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_netlink_event(device->pnp.device_class, + device->dev.bus_id, event, 0); default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported event [0x%x]\n", event)); diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 82c3a550016..2d67e92c8ff 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -445,6 +445,7 @@ static int acpi_sbs_generate_event(struct acpi_device *device, strcpy(acpi_device_bid(device), bid_saved); strcpy(acpi_device_class(device), class_saved); + acpi_bus_generate_netlink_event(class, bid, event, state); return result; } diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 1e06159fd9c..291758c9a4d 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -487,6 +487,10 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) KELVIN_TO_CELSIUS(tz->temperature)); acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); + acpi_bus_generate_netlink_event(tz->device->pnp.device_class, + tz->device->dev.bus_id, + ACPI_THERMAL_NOTIFY_CRITICAL, + tz->trips.critical.flags.enabled); orderly_poweroff(true); @@ -506,6 +510,10 @@ static int acpi_thermal_hot(struct acpi_thermal *tz) acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); + acpi_bus_generate_netlink_event(tz->device->pnp.device_class, + tz->device->dev.bus_id, + ACPI_THERMAL_NOTIFY_HOT, + tz->trips.hot.flags.enabled); /* TBD: Call user-mode "sleep(S4)" function */ @@ -1150,11 +1158,15 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) acpi_thermal_get_trip_points(tz); acpi_thermal_check(tz); acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_netlink_event(device->pnp.device_class, + device->dev.bus_id, event, 0); break; case ACPI_THERMAL_NOTIFY_DEVICES: if (tz->flags.devices) acpi_thermal_get_devices(tz); acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_netlink_event(device->pnp.device_class, + device->dev.bus_id, event, 0); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, -- cgit v1.2.3 From 14e04fb34ffa82ee61ae69f98d8fca12d2e8e31c Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 23 Aug 2007 15:20:26 -0400 Subject: ACPI: Schedule /proc/acpi/event for removal Schedule /proc/acpi/event for removal in 6 months. Re-name acpi_bus_generate_event() to acpi_bus_generate_proc_event() to make sure there is no confusion that it is for /proc/acpi/event only. Add CONFIG_ACPI_PROC_EVENT to allow removal of /proc/acpi/event. There is no functional change if CONFIG_ACPI_PROC_EVENT=y Signed-off-by: Len Brown --- drivers/acpi/Kconfig | 14 ++++++++++++++ drivers/acpi/ac.c | 2 +- drivers/acpi/asus_acpi.c | 2 +- drivers/acpi/battery.c | 2 +- drivers/acpi/bus.c | 6 ++++-- drivers/acpi/button.c | 2 +- drivers/acpi/event.c | 6 ++++++ drivers/acpi/processor_core.c | 6 +++--- drivers/acpi/sbs.c | 2 +- drivers/acpi/thermal.c | 8 ++++---- drivers/acpi/video.c | 10 +++++----- 11 files changed, 41 insertions(+), 19 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index f1372de4ce7..574259476fb 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -68,6 +68,20 @@ config ACPI_PROCFS Say N to delete /proc/acpi/ files that have moved to /sys/ +config ACPI_PROC_EVENT + bool "Deprecated /proc/acpi/event support" + depends on PROC_FS + ---help--- + A user-space daemon, acpi, typically read /proc/acpi/event + and handled all ACPI sub-system generated events. + + These events are now delivered to user-space via + either the input layer, or as netlink events. + + This build option enables the old code for for legacy + user-space implementation. After some time, this will + be moved under CONFIG_ACPI_PROCFS, and then deleted. + config ACPI_AC tristate "AC Adapter" depends on X86 diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index b53c2cfcafd..26d70702b31 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -204,7 +204,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) case ACPI_NOTIFY_BUS_CHECK: case ACPI_NOTIFY_DEVICE_CHECK: acpi_ac_get_state(ac); - acpi_bus_generate_event(device, event, (u32) ac->state); + acpi_bus_generate_proc_event(device, event, (u32) ac->state); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, (u32) ac->state); diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index 86fd142f4bf..d915fec9bf6 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c @@ -1069,7 +1069,7 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) hotk->brightness = (event & ~((u32) BR_DOWN)); } - acpi_bus_generate_event(hotk->device, event, + acpi_bus_generate_proc_event(hotk->device, event, hotk->event_count[event % 128]++); return; diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9f0bf90afda..91dc4b316a0 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -867,7 +867,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) case ACPI_NOTIFY_DEVICE_CHECK: device = battery->device; acpi_battery_notify_update(battery); - acpi_bus_generate_event(device, event, + acpi_bus_generate_proc_event(device, event, acpi_battery_present(battery)); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index e5084ececb6..9ba778a2b48 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -276,6 +276,7 @@ EXPORT_SYMBOL(acpi_bus_set_power); Event Management -------------------------------------------------------------------------- */ +#ifdef CONFIG_ACPI_PROC_EVENT static DEFINE_SPINLOCK(acpi_bus_event_lock); LIST_HEAD(acpi_bus_event_list); @@ -283,7 +284,7 @@ DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue); extern int event_is_open; -int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data) +int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data) { struct acpi_bus_event *event = NULL; unsigned long flags = 0; @@ -314,7 +315,7 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data) return 0; } -EXPORT_SYMBOL(acpi_bus_generate_event); +EXPORT_SYMBOL(acpi_bus_generate_proc_event); int acpi_bus_receive_event(struct acpi_bus_event *event) { @@ -360,6 +361,7 @@ int acpi_bus_receive_event(struct acpi_bus_event *event) } EXPORT_SYMBOL(acpi_bus_receive_event); +#endif /* CONFIG_ACPI_PROC_EVENT */ /* -------------------------------------------------------------------------- Notification Handling diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 540581338ef..2e79a3395ec 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -284,7 +284,7 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) } input_sync(input); - acpi_bus_generate_event(button->device, event, + acpi_bus_generate_proc_event(button->device, event, ++button->pushed); break; default: diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index b7b143288c2..cf6d5161cf3 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c @@ -17,6 +17,7 @@ #define _COMPONENT ACPI_SYSTEM_COMPONENT ACPI_MODULE_NAME("event"); +#ifdef CONFIG_ACPI_PROC_EVENT /* Global vars for handling event proc entry */ static DEFINE_SPINLOCK(acpi_system_event_lock); int event_is_open = 0; @@ -106,6 +107,7 @@ static const struct file_operations acpi_system_event_ops = { .release = acpi_system_close_event, .poll = acpi_system_poll_event, }; +#endif /* CONFIG_ACPI_PROC_EVENT */ #ifdef CONFIG_NET static unsigned int acpi_event_seqnum; @@ -247,7 +249,9 @@ static int acpi_event_genetlink_init(void) static int __init acpi_event_init(void) { +#ifdef CONFIG_ACPI_PROC_EVENT struct proc_dir_entry *entry; +#endif int error = 0; if (acpi_disabled) @@ -259,12 +263,14 @@ static int __init acpi_event_init(void) printk(KERN_WARNING PREFIX "Failed to create genetlink family for ACPI event\n"); +#ifdef CONFIG_ACPI_PROC_EVENT /* 'event' [R] */ entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_event_ops; else return -ENODEV; +#endif return 0; } diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index dbc2e5d9d6a..e944aaee4e0 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -698,7 +698,7 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) switch (event) { case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: acpi_processor_ppc_has_changed(pr); - acpi_bus_generate_event(device, event, + acpi_bus_generate_proc_event(device, event, pr->performance_platform_limit); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, @@ -706,13 +706,13 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) break; case ACPI_PROCESSOR_NOTIFY_POWER: acpi_processor_cst_has_changed(pr); - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, 0); break; case ACPI_PROCESSOR_NOTIFY_THROTTLING: acpi_processor_tstate_has_changed(pr); - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, 0); default: diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 2d67e92c8ff..a578986e321 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -440,7 +440,7 @@ static int acpi_sbs_generate_event(struct acpi_device *device, strcpy(acpi_device_bid(device), bid); strcpy(acpi_device_class(device), class); - result = acpi_bus_generate_event(device, event, state); + result = acpi_bus_generate_proc_event(device, event, state); strcpy(acpi_device_bid(device), bid_saved); strcpy(acpi_device_class(device), class_saved); diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 291758c9a4d..2c9cfe297f7 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -485,7 +485,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) printk(KERN_EMERG "Critical temperature reached (%ld C), shutting down.\n", KELVIN_TO_CELSIUS(tz->temperature)); - acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, + acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); acpi_bus_generate_netlink_event(tz->device->pnp.device_class, tz->device->dev.bus_id, @@ -508,7 +508,7 @@ static int acpi_thermal_hot(struct acpi_thermal *tz) } else if (tz->trips.hot.flags.enabled) tz->trips.hot.flags.enabled = 0; - acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, + acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); acpi_bus_generate_netlink_event(tz->device->pnp.device_class, tz->device->dev.bus_id, @@ -1157,14 +1157,14 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) case ACPI_THERMAL_NOTIFY_THRESHOLDS: acpi_thermal_get_trip_points(tz); acpi_thermal_check(tz); - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, 0); break; case ACPI_THERMAL_NOTIFY_DEVICES: if (tz->flags.devices) acpi_thermal_get_devices(tz); - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, 0); break; diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index d9870194198..9a5cfcfd8da 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1775,7 +1775,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) switch (event) { case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch, * most likely via hotkey. */ - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); break; case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video @@ -1783,14 +1783,14 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) acpi_video_device_enumerate(video); acpi_video_device_rebind(video); acpi_video_switch_output(video, event); - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); break; case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */ case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */ case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */ acpi_video_switch_output(video, event); - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); break; default: @@ -1815,7 +1815,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) switch (event) { case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */ - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); break; case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ @@ -1823,7 +1823,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */ case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ acpi_video_switch_brightness(video_device, event); - acpi_bus_generate_event(device, event, 0); + acpi_bus_generate_proc_event(device, event, 0); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, -- cgit v1.2.3 From 3e069ee0c30d6f28b79e409ef2df1ffa427897ae Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 24 Aug 2007 03:06:33 -0400 Subject: ACPI: fix ia64 allnoconfig build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/acpi/event.c:238: error: conflicting types for ‘acpi_bus_generate_netlink_event’ include/acpi/acpi_bus.h:324: error: previous declaration of ‘acpi_bus_generate_netlink_event’ was here Signed-off-by: Len Brown --- drivers/acpi/event.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index cf6d5161cf3..a2b9304596c 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c @@ -233,8 +233,9 @@ static int acpi_event_genetlink_init(void) } #else -int acpi_bus_generate_netlink_event(struct acpi_device *device, u8 type, - int data) +int acpi_bus_generate_netlink_event(const char *device_class, + const char *bus_id, + u8 type, int data) { return 0; } -- cgit v1.2.3