Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPICA: Events: Reduce source code difference for the ACPI_EVENT_FLAG_HANDLE support.

This patch is a partial linuxized result of the following ACPICA commit:
ACPICA commit: a73b66c6aa1846d055bb6390d9c9b9902f7d804d
Subject: Add "has handler" flag to event/gpe status interfaces.
This change adds a new flag, ACPI_EVENT_FLAGS_HAS_HANDLER to the
acpi_get_event_status and acpi_get_gpe_status external interfaces. It
is set if the event/gpe currently has a handler associated with it.
This commit back ports ACPI_EVENT_FLAG_HANDLE from Linux upstream to
ACPICA, the flag along with its support code currently can only be found
in the Linux upstream and is used by the ACPI sysfs GPE interfaces and
the ACPI bus scanning support.

Link: https://github.com/acpica/acpica/commit/a73b66c6
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Lv Zheng and committed by
Rafael J. Wysocki
a08f813e 1809919a

+35 -19
+26 -14
drivers/acpi/acpica/evxfevnt.c
··· 324 324 ******************************************************************************/ 325 325 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) 326 326 { 327 - acpi_status status = AE_OK; 328 - u32 value; 327 + acpi_status status; 328 + acpi_event_status local_event_status = 0; 329 + u32 in_byte; 329 330 330 331 ACPI_FUNCTION_TRACE(acpi_get_event_status); 331 332 ··· 340 339 return_ACPI_STATUS(AE_BAD_PARAMETER); 341 340 } 342 341 343 - /* Get the status of the requested fixed event */ 342 + /* Fixed event currently can be dispatched? */ 343 + 344 + if (acpi_gbl_fixed_event_handlers[event].handler) { 345 + local_event_status |= ACPI_EVENT_FLAG_HANDLE; 346 + } 347 + 348 + /* Fixed event currently enabled? */ 344 349 345 350 status = 346 351 acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. 347 - enable_register_id, &value); 348 - if (ACPI_FAILURE(status)) 352 + enable_register_id, &in_byte); 353 + if (ACPI_FAILURE(status)) { 349 354 return_ACPI_STATUS(status); 355 + } 350 356 351 - *event_status = value; 357 + if (in_byte) { 358 + local_event_status |= ACPI_EVENT_FLAG_ENABLED; 359 + } 360 + 361 + /* Fixed event currently active? */ 352 362 353 363 status = 354 364 acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. 355 - status_register_id, &value); 356 - if (ACPI_FAILURE(status)) 365 + status_register_id, &in_byte); 366 + if (ACPI_FAILURE(status)) { 357 367 return_ACPI_STATUS(status); 368 + } 358 369 359 - if (value) 360 - *event_status |= ACPI_EVENT_FLAG_SET; 370 + if (in_byte) { 371 + local_event_status |= ACPI_EVENT_FLAG_SET; 372 + } 361 373 362 - if (acpi_gbl_fixed_event_handlers[event].handler) 363 - *event_status |= ACPI_EVENT_FLAG_HANDLE; 364 - 365 - return_ACPI_STATUS(status); 374 + (*event_status) = local_event_status; 375 + return_ACPI_STATUS(AE_OK); 366 376 } 367 377 368 378 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
-3
drivers/acpi/acpica/evxfgpe.c
··· 523 523 524 524 status = acpi_hw_get_gpe_status(gpe_event_info, event_status); 525 525 526 - if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) 527 - *event_status |= ACPI_EVENT_FLAG_HANDLE; 528 - 529 526 unlock_and_exit: 530 527 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 531 528 return_ACPI_STATUS(status);
+7
drivers/acpi/acpica/hwgpe.c
··· 216 216 return (AE_BAD_PARAMETER); 217 217 } 218 218 219 + /* GPE currently handled? */ 220 + 221 + if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != 222 + ACPI_GPE_DISPATCH_NONE) { 223 + local_event_status |= ACPI_EVENT_FLAG_HANDLE; 224 + } 225 + 219 226 /* Get the info block for the entire GPE register */ 220 227 221 228 gpe_register_info = gpe_event_info->register_info;
+2 -2
include/acpi/actypes.h
··· 721 721 * | | | +--- Enabled for wake? 722 722 * | | +----- Set? 723 723 * | +------- Has a handler? 724 - * +----------- <Reserved> 724 + * +------------- <Reserved> 725 725 */ 726 726 typedef u32 acpi_event_status; 727 727 ··· 729 729 #define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01 730 730 #define ACPI_EVENT_FLAG_WAKE_ENABLED (acpi_event_status) 0x02 731 731 #define ACPI_EVENT_FLAG_SET (acpi_event_status) 0x04 732 - #define ACPI_EVENT_FLAG_HANDLE (acpi_event_status) 0x08 732 + #define ACPI_EVENT_FLAG_HANDLE (acpi_event_status) 0x08 733 733 734 734 /* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */ 735 735