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
This commit is contained in:
Abdelkader Boudih committed 2026-10-17 20:49:19 +01:00
1 parent 44ceda0a53
commit 4a059dac78
2 files changed
+16 -7

No files matched your search

+11 -4
View File
@@ -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);
}
+5 -3
View File
@@ -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 */