[PATCH 1/3] platform/x86: dasharo-acpi: Extract dasharo_call() from dasharo_read_channel()

From: Filip Gołaś

Date: Fri Nov 13 2026 - 10:38:52 EST


Move the ACPI method evaluation out of dasharo_read_channel() into a new
dasharo_call() helper, which additionally accepts up to two extra integer
arguments after the channel's group and index. This allows the upcoming
write and fan curve support to reuse the same code path.

No functional change intended.

Signed-off-by: Filip Gołaś <filip.golas@xxxxxxxxx>
---
drivers/platform/x86/dasharo-acpi.c | 40 +++++++++++++++++++++--------
1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/dasharo-acpi.c b/drivers/platform/x86/dasharo-acpi.c
index dfea00cdde18..13d97eb43511 100644
--- a/drivers/platform/x86/dasharo-acpi.c
+++ b/drivers/platform/x86/dasharo-acpi.c
@@ -93,13 +93,18 @@ static int dasharo_get_feature_cap_count(struct dasharo_data *data, enum dasharo
return count;
}

-static int dasharo_read_channel(struct dasharo_data *data, char *method, enum dasharo_feature feat, int channel, long *value)
+/*
+ * Evaluate a DASH method taking the group and index of a channel, followed by
+ * up to two more integer arguments, and returning an integer.
+ */
+static int dasharo_call(struct dasharo_data *data, const char *method, enum dasharo_feature feat,
+ int channel, const u64 *args, unsigned int n_args, u64 *ret)
{
struct acpi_object_list obj_list;
- union acpi_object obj[2];
+ union acpi_object obj[4];
acpi_handle handle;
acpi_status status;
- u64 val;
+ unsigned int i;

if (feat >= ARRAY_SIZE(data->capabilities))
return -EINVAL;
@@ -107,20 +112,35 @@ static int dasharo_read_channel(struct dasharo_data *data, char *method, enum da
if (channel >= data->caps_found[feat])
return -EINVAL;

+ if (n_args > ARRAY_SIZE(obj) - 2) // 2 fixed args always at obj[0] and obj[1]
+ return -EINVAL;
+
obj[0].type = ACPI_TYPE_INTEGER;
obj[0].integer.value = data->capabilities[feat][channel].group;
obj[1].type = ACPI_TYPE_INTEGER;
obj[1].integer.value = data->capabilities[feat][channel].index;
- obj_list.count = 2;
- obj_list.pointer = &obj[0];
+ for (i = 0; i < n_args; ++i) {
+ obj[2 + i].type = ACPI_TYPE_INTEGER;
+ obj[2 + i].integer.value = args[i];
+ }
+ obj_list.count = 2 + n_args;
+ obj_list.pointer = obj;

handle = ACPI_HANDLE(&data->pdev->dev);
- status = acpi_evaluate_integer(handle, method, &obj_list, &val);
- if (ACPI_FAILURE(status))
- return -ENODEV;
+ status = acpi_evaluate_integer(handle, (acpi_string)method, &obj_list, ret);
+ return ACPI_FAILURE(status) ? -ENODEV : 0;
+}

- *value = val;
- return 0;
+static int dasharo_read_channel(struct dasharo_data *data, const char *method,
+ enum dasharo_feature feat, int channel, long *value)
+{
+ u64 val;
+ int ret;
+
+ ret = dasharo_call(data, method, feat, channel, NULL, 0, &val);
+ if (!ret)
+ *value = val;
+ return ret;
}

static int dasharo_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
--
2.56.0