diff options
| author | Olivier Certner <olce@FreeBSD.org> | 2026-05-04 14:52:31 +0000 |
|---|---|---|
| committer | Olivier Certner <olce@FreeBSD.org> | 2026-05-13 12:38:19 +0000 |
| commit | f77731ee95c179cede7dec0e87bc8146a2c546bc (patch) | |
| tree | acb0f29e1cc1c20e9cc0d129e6bfd2e8428bb981 | |
| parent | 27d99ff07908a0333774b4c364a798154ae9fa8c (diff) | |
acpi_spmc(4): Introduce supports_function()
For better readability and because this stance will be used in many
more places in a subsequent commit.
No functional change (intended).
Reviewed by: imp (older version), obiwac
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56803
| -rw-r--r-- | sys/dev/acpica/acpi_spmc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/dev/acpica/acpi_spmc.c b/sys/dev/acpica/acpi_spmc.c index e7f658dbcad0..a6b18767e91b 100644 --- a/sys/dev/acpica/acpi_spmc.c +++ b/sys/dev/acpica/acpi_spmc.c @@ -34,6 +34,9 @@ static char *spmc_ids[] = { NULL }; +/* Conversion of an index to a mask. */ +#define IDX_TO_BIT(idx) (1ull << (idx)) + enum intel_dsm_index { DSM_ENUM_FUNCTIONS = 0, DSM_GET_DEVICE_CONSTRAINTS = 1, @@ -173,6 +176,12 @@ struct acpi_spmc_softc { }; static bool +supports_function(const struct dsm_desc *const dsm, const int function_index) +{ + return ((dsm->supported_functions & IDX_TO_BIT(function_index)) != 0); +} + +static bool has_dsm(const struct acpi_spmc_softc *const sc, const int dsm_bit) { return ((sc->dsms & dsm_bit) != 0); @@ -617,8 +626,7 @@ acpi_spmc_exit_notif(device_t dev) acpi_spmc_run_dsm(dev, &dsm_amd, AMD_DSM_EXIT_NOTIF); if (has_dsm(sc, DSM_MS)) { acpi_spmc_run_dsm(dev, &dsm_ms, DSM_EXIT_NOTIF); - if (dsm_ms.supported_functions & - (1 << DSM_MODERN_TURN_ON_DISPLAY)) + if (supports_function(&dsm_ms, DSM_MODERN_TURN_ON_DISPLAY)) acpi_spmc_run_dsm(dev, &dsm_ms, DSM_MODERN_TURN_ON_DISPLAY); acpi_spmc_run_dsm(dev, &dsm_ms, DSM_MODERN_EXIT_NOTIF); |
