Commit 962ce8ca0604af0c3c5609f7613d4ec5fcfac623
Committed by
Len Brown
1 parent
b377fd3982
Exists in
master
and in
7 other branches
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 <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Showing 10 changed files with 53 additions and 16 deletions Side-by-side Diff
drivers/acpi/ac.c
... | ... | @@ -205,6 +205,9 @@ |
205 | 205 | case ACPI_NOTIFY_DEVICE_CHECK: |
206 | 206 | acpi_ac_get_state(ac); |
207 | 207 | acpi_bus_generate_event(device, event, (u32) ac->state); |
208 | + acpi_bus_generate_netlink_event(device->pnp.device_class, | |
209 | + device->dev.bus_id, event, | |
210 | + (u32) ac->state); | |
208 | 211 | break; |
209 | 212 | default: |
210 | 213 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
drivers/acpi/battery.c
... | ... | @@ -869,6 +869,9 @@ |
869 | 869 | acpi_battery_notify_update(battery); |
870 | 870 | acpi_bus_generate_event(device, event, |
871 | 871 | acpi_battery_present(battery)); |
872 | + acpi_bus_generate_netlink_event(device->pnp.device_class, | |
873 | + device->dev.bus_id, event, | |
874 | + acpi_battery_present(battery)); | |
872 | 875 | break; |
873 | 876 | default: |
874 | 877 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
drivers/acpi/bus.c
... | ... | @@ -292,10 +292,6 @@ |
292 | 292 | if (!device) |
293 | 293 | return -EINVAL; |
294 | 294 | |
295 | - if (acpi_bus_generate_genetlink_event(device, type, data)) | |
296 | - printk(KERN_WARNING PREFIX | |
297 | - "Failed to generate an ACPI event via genetlink!\n"); | |
298 | - | |
299 | 295 | /* drop event on the floor if no one's listening */ |
300 | 296 | if (!event_is_open) |
301 | 297 | return 0; |
drivers/acpi/event.c
... | ... | @@ -147,7 +147,8 @@ |
147 | 147 | .name = ACPI_GENL_MCAST_GROUP_NAME, |
148 | 148 | }; |
149 | 149 | |
150 | -int acpi_bus_generate_genetlink_event(struct acpi_device *device, | |
150 | +int acpi_bus_generate_netlink_event(const char *device_class, | |
151 | + const char *bus_id, | |
151 | 152 | u8 type, int data) |
152 | 153 | { |
153 | 154 | struct sk_buff *skb; |
... | ... | @@ -191,8 +192,8 @@ |
191 | 192 | |
192 | 193 | memset(event, 0, sizeof(struct acpi_genl_event)); |
193 | 194 | |
194 | - strcpy(event->device_class, device->pnp.device_class); | |
195 | - strcpy(event->bus_id, device->dev.bus_id); | |
195 | + strcpy(event->device_class, device_class); | |
196 | + strcpy(event->bus_id, bus_id); | |
196 | 197 | event->type = type; |
197 | 198 | event->data = data; |
198 | 199 | |
... | ... | @@ -211,6 +212,8 @@ |
211 | 212 | return 0; |
212 | 213 | } |
213 | 214 | |
215 | +EXPORT_SYMBOL(acpi_bus_generate_netlink_event); | |
216 | + | |
214 | 217 | static int acpi_event_genetlink_init(void) |
215 | 218 | { |
216 | 219 | int result; |
217 | 220 | |
... | ... | @@ -228,11 +231,13 @@ |
228 | 231 | } |
229 | 232 | |
230 | 233 | #else |
231 | -int acpi_bus_generate_genetlink_event(struct acpi_device *device, u8 type, | |
234 | +int acpi_bus_generate_netlink_event(struct acpi_device *device, u8 type, | |
232 | 235 | int data) |
233 | 236 | { |
234 | 237 | return 0; |
235 | 238 | } |
239 | + | |
240 | +EXPORT_SYMBOL(acpi_generate_netlink_event); | |
236 | 241 | |
237 | 242 | static int acpi_event_genetlink_init(void) |
238 | 243 | { |
drivers/acpi/processor_core.c
... | ... | @@ -700,14 +700,21 @@ |
700 | 700 | acpi_processor_ppc_has_changed(pr); |
701 | 701 | acpi_bus_generate_event(device, event, |
702 | 702 | pr->performance_platform_limit); |
703 | + acpi_bus_generate_netlink_event(device->pnp.device_class, | |
704 | + device->dev.bus_id, event, | |
705 | + pr->performance_platform_limit); | |
703 | 706 | break; |
704 | 707 | case ACPI_PROCESSOR_NOTIFY_POWER: |
705 | 708 | acpi_processor_cst_has_changed(pr); |
706 | 709 | acpi_bus_generate_event(device, event, 0); |
710 | + acpi_bus_generate_netlink_event(device->pnp.device_class, | |
711 | + device->dev.bus_id, event, 0); | |
707 | 712 | break; |
708 | 713 | case ACPI_PROCESSOR_NOTIFY_THROTTLING: |
709 | 714 | acpi_processor_tstate_has_changed(pr); |
710 | 715 | acpi_bus_generate_event(device, event, 0); |
716 | + acpi_bus_generate_netlink_event(device->pnp.device_class, | |
717 | + device->dev.bus_id, event, 0); | |
711 | 718 | default: |
712 | 719 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
713 | 720 | "Unsupported event [0x%x]\n", event)); |
drivers/acpi/sbs.c
drivers/acpi/thermal.c
... | ... | @@ -487,6 +487,10 @@ |
487 | 487 | KELVIN_TO_CELSIUS(tz->temperature)); |
488 | 488 | acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, |
489 | 489 | tz->trips.critical.flags.enabled); |
490 | + acpi_bus_generate_netlink_event(tz->device->pnp.device_class, | |
491 | + tz->device->dev.bus_id, | |
492 | + ACPI_THERMAL_NOTIFY_CRITICAL, | |
493 | + tz->trips.critical.flags.enabled); | |
490 | 494 | |
491 | 495 | orderly_poweroff(true); |
492 | 496 | |
... | ... | @@ -506,6 +510,10 @@ |
506 | 510 | |
507 | 511 | acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, |
508 | 512 | tz->trips.hot.flags.enabled); |
513 | + acpi_bus_generate_netlink_event(tz->device->pnp.device_class, | |
514 | + tz->device->dev.bus_id, | |
515 | + ACPI_THERMAL_NOTIFY_HOT, | |
516 | + tz->trips.hot.flags.enabled); | |
509 | 517 | |
510 | 518 | /* TBD: Call user-mode "sleep(S4)" function */ |
511 | 519 | |
512 | 520 | |
... | ... | @@ -1150,11 +1158,15 @@ |
1150 | 1158 | acpi_thermal_get_trip_points(tz); |
1151 | 1159 | acpi_thermal_check(tz); |
1152 | 1160 | acpi_bus_generate_event(device, event, 0); |
1161 | + acpi_bus_generate_netlink_event(device->pnp.device_class, | |
1162 | + device->dev.bus_id, event, 0); | |
1153 | 1163 | break; |
1154 | 1164 | case ACPI_THERMAL_NOTIFY_DEVICES: |
1155 | 1165 | if (tz->flags.devices) |
1156 | 1166 | acpi_thermal_get_devices(tz); |
1157 | 1167 | acpi_bus_generate_event(device, event, 0); |
1168 | + acpi_bus_generate_netlink_event(device->pnp.device_class, | |
1169 | + device->dev.bus_id, event, 0); | |
1158 | 1170 | break; |
1159 | 1171 | default: |
1160 | 1172 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
drivers/misc/thinkpad_acpi.c
... | ... | @@ -2162,22 +2162,27 @@ |
2162 | 2162 | int docked = dock_docked(); |
2163 | 2163 | int pci = ibm->acpi->hid && ibm->acpi->device && |
2164 | 2164 | acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids); |
2165 | + int data; | |
2165 | 2166 | |
2166 | 2167 | if (event == 1 && !pci) /* 570 */ |
2167 | - acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */ | |
2168 | + data = 1; /* button */ | |
2168 | 2169 | else if (event == 1 && pci) /* 570 */ |
2169 | - acpi_bus_generate_event(ibm->acpi->device, event, 3); /* dock */ | |
2170 | + data = 3; /* dock */ | |
2170 | 2171 | else if (event == 3 && docked) |
2171 | - acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */ | |
2172 | + data = 1; /* button */ | |
2172 | 2173 | else if (event == 3 && !docked) |
2173 | - acpi_bus_generate_event(ibm->acpi->device, event, 2); /* undock */ | |
2174 | + data = 2; /* undock */ | |
2174 | 2175 | else if (event == 0 && docked) |
2175 | - acpi_bus_generate_event(ibm->acpi->device, event, 3); /* dock */ | |
2176 | + data = 3; /* dock */ | |
2176 | 2177 | else { |
2177 | 2178 | printk(IBM_ERR "unknown dock event %d, status %d\n", |
2178 | 2179 | event, _sta(dock_handle)); |
2179 | - acpi_bus_generate_event(ibm->acpi->device, event, 0); /* unknown */ | |
2180 | + data = 0; /* unknown */ | |
2180 | 2181 | } |
2182 | + acpi_bus_generate_event(ibm->acpi->device, event, data); | |
2183 | + acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, | |
2184 | + ibm->acpi->device->dev.bus_id, | |
2185 | + event, data); | |
2181 | 2186 | } |
2182 | 2187 | |
2183 | 2188 | static int dock_read(char *p) |
... | ... | @@ -2276,6 +2281,9 @@ |
2276 | 2281 | static void bay_notify(struct ibm_struct *ibm, u32 event) |
2277 | 2282 | { |
2278 | 2283 | acpi_bus_generate_event(ibm->acpi->device, event, 0); |
2284 | + acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, | |
2285 | + ibm->acpi->device->dev.bus_id, | |
2286 | + event, 0); | |
2279 | 2287 | } |
2280 | 2288 | |
2281 | 2289 | #define bay_occupied(b) (_sta(b##_handle) & 1) |
drivers/pci/hotplug/acpiphp_ibm.c
... | ... | @@ -268,6 +268,9 @@ |
268 | 268 | if (subevent == 0x80) { |
269 | 269 | dbg("%s: generationg bus event\n", __FUNCTION__); |
270 | 270 | acpi_bus_generate_event(note->device, note->event, detail); |
271 | + acpi_bus_generate_netlink_event(note->device->pnp.device_class, | |
272 | + note->device->dev.bus_id, | |
273 | + note->event, detail); | |
271 | 274 | } else |
272 | 275 | note->event = event; |
273 | 276 | } |
include/acpi/acpi_bus.h
... | ... | @@ -321,8 +321,7 @@ |
321 | 321 | }; |
322 | 322 | |
323 | 323 | extern struct kset acpi_subsys; |
324 | -extern int acpi_bus_generate_genetlink_event(struct acpi_device *device, | |
325 | - u8 type, int data); | |
324 | +extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); | |
326 | 325 | /* |
327 | 326 | * External Functions |
328 | 327 | */ |