ACPICA: Events: Reduce source code difference for the ACPI_EVENT_FLAG_HANDLE support.
authorLv Zheng <lv.zheng@intel.com>
Fri, 10 Oct 2014 02:39:57 +0000 (10:39 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 20 Oct 2014 22:39:40 +0000 (00:39 +0200)
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>
drivers/acpi/acpica/evxfevnt.c
drivers/acpi/acpica/evxfgpe.c
drivers/acpi/acpica/hwgpe.c
include/acpi/actypes.h

index e286640ad4ff9e02974bc9d7c9c1d2a64fd58a92..a8a077c971870debab1ebd707df6daf7390120b7 100644 (file)
@@ -324,8 +324,9 @@ ACPI_EXPORT_SYMBOL(acpi_clear_event)
  ******************************************************************************/
 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
 {
-       acpi_status status = AE_OK;
-       u32 value;
+       acpi_status status;
+       acpi_event_status local_event_status = 0;
+       u32 in_byte;
 
        ACPI_FUNCTION_TRACE(acpi_get_event_status);
 
@@ -339,29 +340,40 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
                return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
 
-       /* Get the status of the requested fixed event */
+       /* Fixed event currently can be dispatched? */
+
+       if (acpi_gbl_fixed_event_handlers[event].handler) {
+               local_event_status |= ACPI_EVENT_FLAG_HANDLE;
+       }
+
+       /* Fixed event currently enabled? */
 
        status =
            acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
-                             enable_register_id, &value);
-       if (ACPI_FAILURE(status))
+                                  enable_register_id, &in_byte);
+       if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
+       }
 
-       *event_status = value;
+       if (in_byte) {
+               local_event_status |= ACPI_EVENT_FLAG_ENABLED;
+       }
+
+       /* Fixed event currently active? */
 
        status =
            acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
-                             status_register_id, &value);
-       if (ACPI_FAILURE(status))
+                                  status_register_id, &in_byte);
+       if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
+       }
 
-       if (value)
-               *event_status |= ACPI_EVENT_FLAG_SET;
-
-       if (acpi_gbl_fixed_event_handlers[event].handler)
-               *event_status |= ACPI_EVENT_FLAG_HANDLE;
+       if (in_byte) {
+               local_event_status |= ACPI_EVENT_FLAG_SET;
+       }
 
-       return_ACPI_STATUS(status);
+       (*event_status) = local_event_status;
+       return_ACPI_STATUS(AE_OK);
 }
 
 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
index 2529d3c1c6b7b4486252a597c3beffc1e58310aa..e889a5304abd2fe9206b4a9a911378f4f4a0e050 100644 (file)
@@ -523,9 +523,6 @@ acpi_get_gpe_status(acpi_handle gpe_device,
 
        status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
 
-       if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)
-               *event_status |= ACPI_EVENT_FLAG_HANDLE;
-
 unlock_and_exit:
        acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
        return_ACPI_STATUS(status);
index aa884d42361cd863264bb2d9fb256f56b62d36f9..0302bc36287b89d1e8d47713cb65c83d9349f486 100644 (file)
@@ -216,6 +216,13 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
                return (AE_BAD_PARAMETER);
        }
 
+       /* GPE currently handled? */
+
+       if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) !=
+           ACPI_GPE_DISPATCH_NONE) {
+               local_event_status |= ACPI_EVENT_FLAG_HANDLE;
+       }
+
        /* Get the info block for the entire GPE register */
 
        gpe_register_info = gpe_event_info->register_info;
index ac03ec81d342c3a1cb6d25861c51b1b5c6a14dd8..857830d8989b89c3d58a3cbc4c5f57d5e9e7d390 100644 (file)
@@ -721,7 +721,7 @@ typedef u32 acpi_event_type;
  *          |     | | +--- Enabled for wake?
  *          |     | +----- Set?
  *          |     +------- Has a handler?
- *          +----------- <Reserved>
+ *          +------------- <Reserved>
  */
 typedef u32 acpi_event_status;
 
@@ -729,7 +729,7 @@ typedef u32 acpi_event_status;
 #define ACPI_EVENT_FLAG_ENABLED         (acpi_event_status) 0x01
 #define ACPI_EVENT_FLAG_WAKE_ENABLED    (acpi_event_status) 0x02
 #define ACPI_EVENT_FLAG_SET             (acpi_event_status) 0x04
-#define ACPI_EVENT_FLAG_HANDLE         (acpi_event_status) 0x08
+#define ACPI_EVENT_FLAG_HANDLE          (acpi_event_status) 0x08
 
 /* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */