Skip to content

Commit f2fee24

Browse files
Christoph Hellwigrafaeljw
authored andcommitted
ACPICA: Get rid of acpi_sleep_dispatch()
No need for the array of structs of function pointers when we can just call the handfull of functions directly. This could be further cleaned up if acpi_gbl_reduced_hardware was defined true in the ACPI_REDUCED_HARDWARE case, but that's material for the next round. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 075470d commit f2fee24

File tree

2 files changed

+18
-87
lines changed

2 files changed

+18
-87
lines changed

drivers/acpi/acpica/hwxfsleep.c

Lines changed: 18 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,6 @@ acpi_hw_set_firmware_waking_vector(struct acpi_table_facs *facs,
2323
acpi_physical_address physical_address64);
2424
#endif
2525

26-
static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
27-
28-
/*
29-
* Dispatch table used to efficiently branch to the various sleep
30-
* functions.
31-
*/
32-
#define ACPI_SLEEP_FUNCTION_ID 0
33-
#define ACPI_WAKE_PREP_FUNCTION_ID 1
34-
#define ACPI_WAKE_FUNCTION_ID 2
35-
36-
/* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
37-
38-
static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
39-
{ACPI_STRUCT_INIT(legacy_function,
40-
ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep)),
41-
ACPI_STRUCT_INIT(extended_function,
42-
acpi_hw_extended_sleep)},
43-
{ACPI_STRUCT_INIT(legacy_function,
44-
ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep)),
45-
ACPI_STRUCT_INIT(extended_function,
46-
acpi_hw_extended_wake_prep)},
47-
{ACPI_STRUCT_INIT(legacy_function,
48-
ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake)),
49-
ACPI_STRUCT_INIT(extended_function,
50-
acpi_hw_extended_wake)}
51-
};
52-
5326
/*
5427
* These functions are removed for the ACPI_REDUCED_HARDWARE case:
5528
* acpi_set_firmware_waking_vector
@@ -209,53 +182,6 @@ acpi_status acpi_enter_sleep_state_s4bios(void)
209182

210183
ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
211184
#endif /* !ACPI_REDUCED_HARDWARE */
212-
/*******************************************************************************
213-
*
214-
* FUNCTION: acpi_hw_sleep_dispatch
215-
*
216-
* PARAMETERS: sleep_state - Which sleep state to enter/exit
217-
* function_id - Sleep, wake_prep, or Wake
218-
*
219-
* RETURN: Status from the invoked sleep handling function.
220-
*
221-
* DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling
222-
* function.
223-
*
224-
******************************************************************************/
225-
static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id)
226-
{
227-
acpi_status status;
228-
struct acpi_sleep_functions *sleep_functions =
229-
&acpi_sleep_dispatch[function_id];
230-
231-
#if (!ACPI_REDUCED_HARDWARE)
232-
/*
233-
* If the Hardware Reduced flag is set (from the FADT), we must
234-
* use the extended sleep registers (FADT). Note: As per the ACPI
235-
* specification, these extended registers are to be used for HW-reduced
236-
* platforms only. They are not general-purpose replacements for the
237-
* legacy PM register sleep support.
238-
*/
239-
if (acpi_gbl_reduced_hardware) {
240-
status = sleep_functions->extended_function(sleep_state);
241-
} else {
242-
/* Legacy sleep */
243-
244-
status = sleep_functions->legacy_function(sleep_state);
245-
}
246-
247-
return (status);
248-
249-
#else
250-
/*
251-
* For the case where reduced-hardware-only code is being generated,
252-
* we know that only the extended sleep registers are available
253-
*/
254-
status = sleep_functions->extended_function(sleep_state);
255-
return (status);
256-
257-
#endif /* !ACPI_REDUCED_HARDWARE */
258-
}
259185

260186
/*******************************************************************************
261187
*
@@ -362,7 +288,12 @@ acpi_status acpi_enter_sleep_state(u8 sleep_state)
362288
return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
363289
}
364290

365-
status = acpi_hw_sleep_dispatch(sleep_state, ACPI_SLEEP_FUNCTION_ID);
291+
#if !ACPI_REDUCED_HARDWARE
292+
if (!acpi_gbl_reduced_hardware)
293+
status = acpi_hw_legacy_sleep(sleep_state);
294+
else
295+
#endif
296+
status = acpi_hw_extended_sleep(sleep_state);
366297
return_ACPI_STATUS(status);
367298
}
368299

@@ -388,8 +319,12 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
388319

389320
ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
390321

391-
status =
392-
acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_PREP_FUNCTION_ID);
322+
#if !ACPI_REDUCED_HARDWARE
323+
if (!acpi_gbl_reduced_hardware)
324+
status = acpi_hw_legacy_wake_prep(sleep_state);
325+
else
326+
#endif
327+
status = acpi_hw_extended_wake_prep(sleep_state);
393328
return_ACPI_STATUS(status);
394329
}
395330

@@ -413,7 +348,12 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
413348

414349
ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
415350

416-
status = acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_FUNCTION_ID);
351+
#if !ACPI_REDUCED_HARDWARE
352+
if (!acpi_gbl_reduced_hardware)
353+
status = acpi_hw_legacy_wake(sleep_state);
354+
else
355+
#endif
356+
status = acpi_hw_extended_wake(sleep_state);
417357
return_ACPI_STATUS(status);
418358
}
419359

include/acpi/actypes.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -885,15 +885,6 @@ typedef u8 acpi_adr_space_type;
885885
#define ACPI_ENABLE_EVENT 1
886886
#define ACPI_DISABLE_EVENT 0
887887

888-
/* Sleep function dispatch */
889-
890-
typedef acpi_status (*acpi_sleep_function) (u8 sleep_state);
891-
892-
struct acpi_sleep_functions {
893-
acpi_sleep_function legacy_function;
894-
acpi_sleep_function extended_function;
895-
};
896-
897888
/*
898889
* External ACPI object definition
899890
*/

0 commit comments

Comments
 (0)