git: 73b1453e6d87 - main - asmc: move the backlight control level into the softc

From: Abdelkader Boudih <seuros_at_FreeBSD.org>
Date: Sat, 07 Nov 2026 22:15:09 UTC
The branch main has been updated by seuros:

URL: https://cgit.FreeBSD.org/src/commit/?id=73b1453e6d87f9af4c4761049640c238fcee3bcd

commit 73b1453e6d87f9af4c4761049640c238fcee3bcd
Author:     Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-11-07 20:27:37 +0000
Commit:     Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-11-07 20:27:37 +0000

    asmc: move the backlight control level into the softc
    
    light_control was a file-scope static shared by resume, the light.control
    sysctl and the backlight method. Per-device state belongs in the softc.
    
    No functional change.
    
    Reviewed by:    adrian
    Differential Revision:  https://reviews.freebsd.org/D61291
---
 sys/dev/asmc/asmc.c    | 15 +++++++--------
 sys/dev/asmc/asmcvar.h |  1 +
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
index 75ccb933f4d9..f5110a894c5b 100644
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -409,8 +409,6 @@ ACPI_MODULE_NAME("ASMC")
 /* NB: can't be const */
 static char *asmc_ids[] = { "APP0001", NULL };
 
-static unsigned int light_control = 0;
-
 ACPI_PNP_INFO(asmc_ids);
 DRIVER_MODULE(asmc, acpi, asmc_driver, NULL, NULL);
 MODULE_DEPEND(asmc, acpi, 1, 1, 1);
@@ -936,9 +934,10 @@ asmc_detach(device_t dev)
 static int
 asmc_resume(device_t dev)
 {
+	struct asmc_softc *sc = device_get_softc(dev);
 	uint8_t buf[2];
 
-	buf[0] = light_control;
+	buf[0] = sc->sc_light_control;
 	buf[1] = 0x00;
 	asmc_key_write(dev, ASMC_KEY_LIGHTVALUE, buf, sizeof(buf));
 
@@ -2352,15 +2351,15 @@ asmc_mbp_sysctl_light_control(SYSCTL_HANDLER_ARGS)
 	int error;
 	int v;
 
-	v = light_control;
+	v = sc->sc_light_control;
 	error = sysctl_handle_int(oidp, &v, 0, req);
 
 	if (error == 0 && req->newptr != NULL) {
 		if (v < 0 || v > 255)
 			return (EINVAL);
-		light_control = v;
+		sc->sc_light_control = v;
 		sc->sc_kbd_bkl_level = v * 100 / 255;
-		buf[0] = light_control;
+		buf[0] = sc->sc_light_control;
 		buf[1] = 0x00;
 		asmc_key_write(dev, ASMC_KEY_LIGHTVALUE, buf, sizeof(buf));
 	}
@@ -2465,8 +2464,8 @@ asmc_backlight_update_status(device_t dev, struct backlight_props *props)
 	uint8_t buf[2];
 
 	sc->sc_kbd_bkl_level = props->brightness;
-	light_control = props->brightness * 255 / 100;
-	buf[0] = light_control;
+	sc->sc_light_control = props->brightness * 255 / 100;
+	buf[0] = sc->sc_light_control;
 	buf[1] = 0x00;
 	asmc_key_write(dev, ASMC_KEY_LIGHTVALUE, buf, sizeof(buf));
 
diff --git a/sys/dev/asmc/asmcvar.h b/sys/dev/asmc/asmcvar.h
index 32449a72cc48..4a11008239f5 100644
--- a/sys/dev/asmc/asmcvar.h
+++ b/sys/dev/asmc/asmcvar.h
@@ -64,6 +64,7 @@ struct asmc_softc {
 	uint8_t			sc_sms_intr_works;
 	struct cdev		*sc_kbd_bkl;
 	uint32_t		sc_kbd_bkl_level;
+	unsigned int		sc_light_control;
 #ifdef ASMC_DEBUG
 	/* Raw key access */
 	struct sysctl_oid	*sc_raw_tree;