diff mbox series

[1/3] ACPI / utils: Add acpi_evaluate_reg() helper

Message ID 20200505132128.19476-2-hdegoede@redhat.com (mailing list archive)
State Superseded, archived
Headers show
Series ACPI / utils: Add acpi_evaluate_reg() helper | expand

Commit Message

Hans de Goede May 5, 2020, 1:21 p.m. UTC
With a recent fix to the pinctrl-cherryview driver we know 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.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/utils.c    | 25 +++++++++++++++++++++++++
 include/acpi/acpi_bus.h |  1 +
 2 files changed, 26 insertions(+)

Comments

Andy Shevchenko May 5, 2020, 3:42 p.m. UTC | #1
On Tue, May 05, 2020 at 03:21:26PM +0200, Hans de Goede wrote:
> With a recent fix to the pinctrl-cherryview driver we know 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 May 5, 2020, 3:43 p.m. UTC | #2
On Tue, May 05, 2020 at 03:21:26PM +0200, Hans de Goede wrote:
> With a recent fix to the pinctrl-cherryview driver we know 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.

> + * @function: Parameter to pass to _REG one of ACPI_REG_CONNECT or
> + *            ACPI_REG_DISCONNECT

Is it enum or definitions? If former can we refer to it?


(Sorry, clicked reply to fast with previous mail)
Bjorn Helgaas May 5, 2020, 4:44 p.m. UTC | #3
On Tue, May 05, 2020 at 03:21:26PM +0200, Hans de Goede wrote:
> With a recent fix to the pinctrl-cherryview driver we know have
> 2 drivers open-coding the parameter building / passing for calling
> _REG on an ACPI handle.

s/know/now/
Hans de Goede May 7, 2020, 10:30 a.m. UTC | #4
Hi,

On 5/5/20 5:42 PM, Andy Shevchenko wrote:
> On Tue, May 05, 2020 at 03:21:26PM +0200, Hans de Goede wrote:
>> With a recent fix to the pinctrl-cherryview driver we know 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?

Right sorry about that I will fix this for v2.

 >> + * @function: Parameter to pass to _REG one of ACPI_REG_CONNECT or
 >> + *            ACPI_REG_DISCONNECT
 >
 > Is it enum or definitions? If former can we refer to it?

These are #define-s.

Regards,

Hans
diff mbox series

Patch

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 804ac0df58ec..838b719ec7ce 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -605,6 +605,31 @@  acpi_status acpi_evaluate_lck(acpi_handle handle, int lock)
 	return status;
 }
 
+/**
+ * acpi_evaluate_reg: Evaluate _REG method to register OpRegion presence
+ * @handle: ACPI device handle
+ * @space_id: ACPI address space id to register OpRegion presence for
+ * @function: Parameter to pass to _REG one of ACPI_REG_CONNECT or
+ *            ACPI_REG_DISCONNECT
+ *
+ * Evaluate device's _REG method to register OpRegion presence.
+ */
+acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function)
+{
+	struct acpi_object_list arg_list;
+	union acpi_object params[2];
+
+	params[0].type = ACPI_TYPE_INTEGER;
+	params[0].integer.value = space_id;
+	params[1].type = ACPI_TYPE_INTEGER;
+	params[1].integer.value = function;
+	arg_list.count = 2;
+	arg_list.pointer = params;
+
+	return acpi_evaluate_object(handle, "_REG", &arg_list, NULL);
+}
+EXPORT_SYMBOL(acpi_evaluate_reg);
+
 /**
  * acpi_evaluate_dsm - evaluate device's _DSM method
  * @handle: ACPI device handle
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index a92bea7184a8..5afb6ceb284f 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -44,6 +44,7 @@  acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
 				       u64 arg);
 acpi_status acpi_evaluate_ej0(acpi_handle handle);
 acpi_status acpi_evaluate_lck(acpi_handle handle, int lock);
+acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function);
 bool acpi_ata_match(acpi_handle handle);
 bool acpi_bay_match(acpi_handle handle);
 bool acpi_dock_match(acpi_handle handle);