git: 4a059dac7815 - main - acpi_apple: make the device mode a typed enum
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 17 Oct 2026 19:49:48 UTC
The branch main has been updated by seuros:
URL: https://cgit.FreeBSD.org/src/commit/?id=4a059dac78157e6163d6e8ed6e7be5ec65a78a5f
commit 4a059dac78157e6163d6e8ed6e7be5ec65a78a5f
Author: Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-10-17 19:49:19 +0000
Commit: Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-10-17 19:49:19 +0000
acpi_apple: make the device mode a typed enum
The two mode values were spelled as bit flags, but a device is exactly
one of the two and the dispatch compared the field for equality.
Turned them into an enum, type the softc field with it, and dispatch with
a switch that lists every value
No functional change.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D60793
---
sys/dev/acpi_apple/acpi_apple.c | 15 +++++++++++----
sys/dev/acpi_apple/acpi_apple.h | 8 +++++---
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/sys/dev/acpi_apple/acpi_apple.c b/sys/dev/acpi_apple/acpi_apple.c
index 4425cb27d8f9..d0efca087b20 100644
--- a/sys/dev/acpi_apple/acpi_apple.c
+++ b/sys/dev/acpi_apple/acpi_apple.c
@@ -77,10 +77,13 @@ acpi_apple_attach(device_t dev)
else
sc->mode = ACPI_APPLE_PLATFORM;
- if (sc->mode == ACPI_APPLE_PLATFORM)
+ switch (sc->mode) {
+ case ACPI_APPLE_PLATFORM:
return (acpi_apple_platform_attach(sc));
- else
+ case ACPI_APPLE_BACKLIGHT:
return (acpi_apple_backlight_attach(sc));
+ }
+ return (ENXIO);
}
static int
@@ -89,10 +92,14 @@ acpi_apple_detach(device_t dev)
struct acpi_apple_softc *sc;
sc = device_get_softc(dev);
- if (sc->mode == ACPI_APPLE_PLATFORM)
+ switch (sc->mode) {
+ case ACPI_APPLE_PLATFORM:
acpi_apple_platform_detach(sc);
- else
+ break;
+ case ACPI_APPLE_BACKLIGHT:
acpi_apple_backlight_detach(sc);
+ break;
+ }
return (0);
}
diff --git a/sys/dev/acpi_apple/acpi_apple.h b/sys/dev/acpi_apple/acpi_apple.h
index cfd7b65f53c9..4e02b43559de 100644
--- a/sys/dev/acpi_apple/acpi_apple.h
+++ b/sys/dev/acpi_apple/acpi_apple.h
@@ -21,8 +21,10 @@
#include <dev/acpica/acpivar.h>
#include <dev/backlight/backlight.h>
-#define ACPI_APPLE_PLATFORM 0x01 /* WoL + lid (APP000B/APP9876) */
-#define ACPI_APPLE_BACKLIGHT 0x02 /* panel backlight (APP0002) */
+enum acpi_apple_mode {
+ ACPI_APPLE_PLATFORM, /* WoL + lid (APP000B/APP9876) */
+ ACPI_APPLE_BACKLIGHT, /* panel backlight (APP0002) */
+};
/*
* Apple GMUX (GPU multiplexer) registers.
@@ -116,7 +118,7 @@ struct apple_bl_hw {
struct acpi_apple_softc {
device_t dev;
ACPI_HANDLE handle;
- int mode;
+ enum acpi_apple_mode mode;
/* Backlight */
struct mtx bl_mtx; /* protects hw access + cache */