]> err.no Git - linux-2.6/commitdiff
ACPI: don't duplicate input events on netlink
authorZhang Rui <rui.zhang@intel.com>
Wed, 22 Aug 2007 17:24:31 +0000 (01:24 +0800)
committerLen Brown <len.brown@intel.com>
Thu, 23 Aug 2007 18:27:23 +0000 (14:27 -0400)
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 <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/ac.c
drivers/acpi/battery.c
drivers/acpi/bus.c
drivers/acpi/event.c
drivers/acpi/processor_core.c
drivers/acpi/sbs.c
drivers/acpi/thermal.c
drivers/misc/thinkpad_acpi.c
drivers/pci/hotplug/acpiphp_ibm.c
include/acpi/acpi_bus.h

index d8b35093527a3bbb8962c180b1b7792f5a2eb48b..b53c2cfcafd30c954879bae741173013aaaa4785 100644 (file)
@@ -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,
index d7b499fe0cd932fec5f8c6a9c7237cd38b962acc..9f0bf90afdab31a246ffd5d734ad70435123b899 100644 (file)
@@ -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,
index 6b2658c9624245c7de284623058b4312bb96ff0e..e5084ececb6ff7f004326a3fcdf24828c45e2f0a 100644 (file)
@@ -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;
index 95637a4ff782b1d5975e656a23dcd2559d0dbcb9..b7b143288c229bf5627ac3f8a3752d2d77394573 100644 (file)
@@ -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;
index 498422343f38a64550532c9ab8733d94397322d5..dbc2e5d9d6a73fbd32003b7637878374c7b878a3 100644 (file)
@@ -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));
index 82c3a550016d82068798351123f5d2b429ef64d4..2d67e92c8ff70635e510dfc621bf6e7d2243292a 100644 (file)
@@ -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;
 }
 
index 1e06159fd9c4a529435615646aedce6c77c0fa96..291758c9a4d6052c046865c78250d4169a64406a 100644 (file)
@@ -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,
index f6cd34a3dbaca218cf0ff8a19ff94d03c41cb8d7..d0825a34a7b035948ac02f50009fd344b1dd6b57 100644 (file)
@@ -2162,22 +2162,27 @@ static void dock_notify(struct ibm_struct *ibm, u32 event)
        int docked = dock_docked();
        int pci = ibm->acpi->hid && ibm->acpi->device &&
                acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
+       int data;
 
        if (event == 1 && !pci) /* 570 */
-               acpi_bus_generate_event(ibm->acpi->device, event, 1);   /* button */
+               data = 1;       /* button */
        else if (event == 1 && pci)     /* 570 */
-               acpi_bus_generate_event(ibm->acpi->device, event, 3);   /* dock */
+               data = 3;       /* dock */
        else if (event == 3 && docked)
-               acpi_bus_generate_event(ibm->acpi->device, event, 1);   /* button */
+               data = 1;       /* button */
        else if (event == 3 && !docked)
-               acpi_bus_generate_event(ibm->acpi->device, event, 2);   /* undock */
+               data = 2;       /* undock */
        else if (event == 0 && docked)
-               acpi_bus_generate_event(ibm->acpi->device, event, 3);   /* dock */
+               data = 3;       /* dock */
        else {
                printk(IBM_ERR "unknown dock event %d, status %d\n",
                       event, _sta(dock_handle));
-               acpi_bus_generate_event(ibm->acpi->device, event, 0);   /* unknown */
+               data = 0;       /* unknown */
        }
+       acpi_bus_generate_event(ibm->acpi->device, event, data);
+       acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
+                                         ibm->acpi->device->dev.bus_id,
+                                         event, data);
 }
 
 static int dock_read(char *p)
@@ -2276,6 +2281,9 @@ static int __init bay_init(struct ibm_init_struct *iibm)
 static void bay_notify(struct ibm_struct *ibm, u32 event)
 {
        acpi_bus_generate_event(ibm->acpi->device, event, 0);
+       acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
+                                         ibm->acpi->device->dev.bus_id,
+                                         event, 0);
 }
 
 #define bay_occupied(b) (_sta(b##_handle) & 1)
index 70db38c0ced9f6586ed6356e4bc8ef78c6cd4235..360902476bad6ef753143ca33f6694f97300a33d 100644 (file)
@@ -268,6 +268,9 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
        if (subevent == 0x80) {
                dbg("%s: generationg bus event\n", __FUNCTION__);
                acpi_bus_generate_event(note->device, note->event, detail);
+               acpi_bus_generate_netlink_event(note->device->pnp.device_class,
+                                                 note->device->dev.bus_id,
+                                                 note->event, detail);
        } else
                note->event = event;
 }
index 3d0fea235bf341af95fb417dcea94d0872ae643b..8203cddeb4cb1c9854f05a1c3be387b62aaf3e82 100644 (file)
@@ -321,8 +321,7 @@ struct acpi_bus_event {
 };
 
 extern struct kset acpi_subsys;
-extern int acpi_bus_generate_genetlink_event(struct acpi_device *device,
-                                               u8 type, int data);
+extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
 /*
  * External Functions
  */