[PATCH 2/4] ACPI: fan: Optimize struct acpi_fan_fif
Philip Cox
philip.cox at canonical.com
Mon Aug 14 17:00:09 UTC 2023
From: Srinivas Pandruvada <srinivas.pandruvada at linux.intel.com>
BugLink: https://bugs.launchpad.net/bugs/2031333
We don't need u64 to store the information about _FIF. There are two
booleans (fine_grain_ctrl and low_speed_notification) and one field
step_size which can take value from 1-9. There are no internal users
of revision field. So convert all fields to u8, by not directly
extracting the _FIF info the struct. Use an intermediate buffer to
extract and assign.
This will help to do u32 math using these fields. No functional
changes are expected.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada at linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki at intel.com>
(cherry picked from commit d445571fa369cf08148dcd9bce563d5fae14fcd7)
Signed-off-by: Philip Cox <philip.cox at canonical.com>
---
drivers/acpi/fan.h | 8 ++++----
drivers/acpi/fan_core.c | 8 +++++++-
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/fan.h b/drivers/acpi/fan.h
index e5582aff08cb..ce42a6c7130e 100644
--- a/drivers/acpi/fan.h
+++ b/drivers/acpi/fan.h
@@ -29,10 +29,10 @@ struct acpi_fan_fps {
};
struct acpi_fan_fif {
- u64 revision;
- u64 fine_grain_ctrl;
- u64 step_size;
- u64 low_speed_notification;
+ u8 revision;
+ u8 fine_grain_ctrl;
+ u8 step_size;
+ u8 low_speed_notification;
};
struct acpi_fan {
diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c
index 77f427fe4409..ec4229fd5c4b 100644
--- a/drivers/acpi/fan_core.c
+++ b/drivers/acpi/fan_core.c
@@ -211,7 +211,8 @@ static int acpi_fan_get_fif(struct acpi_device *device)
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_fan *fan = acpi_driver_data(device);
struct acpi_buffer format = { sizeof("NNNN"), "NNNN" };
- struct acpi_buffer fif = { sizeof(fan->fif), &fan->fif };
+ u64 fields[4];
+ struct acpi_buffer fif = { sizeof(fields), fields };
union acpi_object *obj;
acpi_status status;
@@ -232,6 +233,11 @@ static int acpi_fan_get_fif(struct acpi_device *device)
status = -EINVAL;
}
+ fan->fif.revision = fields[0];
+ fan->fif.fine_grain_ctrl = fields[1];
+ fan->fif.step_size = fields[2];
+ fan->fif.low_speed_notification = fields[3];
+
err:
kfree(obj);
return status;
--
2.34.1
More information about the kernel-team
mailing list