Skip to content

Commit 132565d

Browse files
jwrdegoederafaeljw
authored andcommitted
ACPI: utils: Add acpi_evaluate_reg() helper
With a recent fix to the pinctrl-cherryview driver we now have 2 drivers open-coding the parameter building / passing for calling _REG on an ACPI handle. Add a helper for this, so that these 2 drivers can be converted to this helper. Suggested-by: Andy Shevchenko <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 0e698df commit 132565d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/acpi/utils.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,31 @@ acpi_status acpi_evaluate_lck(acpi_handle handle, int lock)
605605
return status;
606606
}
607607

608+
/**
609+
* acpi_evaluate_reg: Evaluate _REG method to register OpRegion presence
610+
* @handle: ACPI device handle
611+
* @space_id: ACPI address space id to register OpRegion presence for
612+
* @function: Parameter to pass to _REG one of ACPI_REG_CONNECT or
613+
* ACPI_REG_DISCONNECT
614+
*
615+
* Evaluate device's _REG method to register OpRegion presence.
616+
*/
617+
acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function)
618+
{
619+
struct acpi_object_list arg_list;
620+
union acpi_object params[2];
621+
622+
params[0].type = ACPI_TYPE_INTEGER;
623+
params[0].integer.value = space_id;
624+
params[1].type = ACPI_TYPE_INTEGER;
625+
params[1].integer.value = function;
626+
arg_list.count = 2;
627+
arg_list.pointer = params;
628+
629+
return acpi_evaluate_object(handle, "_REG", &arg_list, NULL);
630+
}
631+
EXPORT_SYMBOL(acpi_evaluate_reg);
632+
608633
/**
609634
* acpi_evaluate_dsm - evaluate device's _DSM method
610635
* @handle: ACPI device handle

include/acpi/acpi_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
4444
u64 arg);
4545
acpi_status acpi_evaluate_ej0(acpi_handle handle);
4646
acpi_status acpi_evaluate_lck(acpi_handle handle, int lock);
47+
acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function);
4748
bool acpi_ata_match(acpi_handle handle);
4849
bool acpi_bay_match(acpi_handle handle);
4950
bool acpi_dock_match(acpi_handle handle);

0 commit comments

Comments
 (0)