From nobody Tue Apr 7 06:30:19 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECF09367F3D for ; Sun, 15 Mar 2026 22:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773613239; cv=none; b=N2IhDPFfhZkl6a5oLDMZ+vusRaY2eXrMEJsx79rKEw8SpmcH6mpwwL4P439DdzYHvjHBmZetlzQ/TF8xNaYWCREvlWIgBsud4fGt0fBJDf/PIMYlIAzDvvkY7rilS9tBVYmIAbTKizE01h90fz+Fpd0iEu4tF3upY9XzOhQB2Lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773613239; c=relaxed/simple; bh=d4jChEeUUc0f0rEMKPi4UAZuovkMFjwzj0INK1YLEaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z4vL8z9oiTJK0fxygqe+exPf/WYENkooj8GOEkFJCazWeSXDddxYaV/MA5/ITWwbco7FfoBV7JYxBL2NzZL849fbMbvT0Wvqy/Me1aLDNs17UiWrZubd2ToU0Q0T2mnpSZ6qvV0UaJBjMgS5n6JCm8OYpITaLU1spyQmSFNS710= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iFR7tdAk; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iFR7tdAk" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-35a288a2c00so1008029a91.2 for ; Sun, 15 Mar 2026 15:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773613237; x=1774218037; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R6JQWklIlJSZA3P4ZxqqueLAj4IsTzAWLg/HK7yKGJM=; b=iFR7tdAkoXa6GcKRjWuVOjC3094LSGTHCn3uQqDthbXeCtAzrheOF2a3jTYYN3CJsn 7AVKRcGWbEAD7QmBdi8Tj1pE0RO9gNHYIaE83tvFlD1nQGgORVCzi7upWh/ntLhzoh7O TAfEvueDN5KqVVQca5s/hoJRK2TKsXR0JGqZihd2vt4CXCflzfI5mzLv8F+b9iYI8/7e 7Lc94dYYwc3THFb3/2M0XxUzujFFkM9iaMbgQmZruB/1Wcpo+ncBjzDkueUhU498BbbP bb9YPTXed7QjTW0iMYtzRF5UXwaOh1HMmjN8hECUy9cV/3RfZoeB7LlRVGghE6IUVydk hm4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773613237; x=1774218037; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R6JQWklIlJSZA3P4ZxqqueLAj4IsTzAWLg/HK7yKGJM=; b=AnKyy+X26QBIU8leEcMYTDatuZ2GtYZx/pbKynksfi/0703f1gxQvBDy9A7C+HilIz /eS/hPh9qGnYwoaXkT5P1xQYr/T023bNvwIcydtR+Z5EI8cE5rM2vqwfXrGSqI4fAij9 9Z1dNjO3fQEcL0vjfTShyPD5GXiwQGbN4K7IYVpQbwzaJMI+FjDzdm/YtrwF4ZVstd9p E1nC5SQEBrZQb5JCZNt4KKUd7RvVaWet2UbRbUcv60DgWJjS/XIS1P52BipDNaQ/dT5R spfUdelVPX1+ReGSLDjVRyVQDsy/s4HouqjTh39ulMzgNEYRdR9iYR6G8VQLsib6NNuR kPjg== X-Forwarded-Encrypted: i=1; AJvYcCUsdzjLyd2gB8QUoyNdtVsaQReK65At7+RmADyqfNJ6on1ELZBgRmsB1hoHfJSAI75MTpxIwfvD9QPojbw=@vger.kernel.org X-Gm-Message-State: AOJu0YwoR0JXc4/IcBJWrxK34p/DbVBWZbhIhHFXXIN9qtdcqU2pOhnG oPZrPducseW2+1TiPt1iDmB6Orj7mJCVrGaYu9vhmYRPDnzOQprYv+o= X-Gm-Gg: ATEYQzwtH/qXHCcAeeYOvKzYPFKOtpL/lGOldRNZrOie7K3v+ZWz3z54hr5bxC/5PHE mz23MhcFZwA6iLzuedAaWubq0k/KxkLKBwUTvo0kL5pmPuBUwsGSzw2XViYMNAC79a4iV3WMRCV VIr1mp9H6uB1VBnXMF866bK+/Yd4X0HliYohcC5YdS7nsosNHQ7SsijQCTwGXblS0AouZ9tMg0m zo81KWkXxs0F2o7gN0XDF5eT1I6/GpMqYqO3BKDYysqp0M4bCeu/MZOs5PXAI9YLSuostSVWe7o zC8Umw0xHfRDMolNhFMjHBt7DL9gA5sId+pN5FZcQTlqy9s+WbUv1mt0dKFg5SZXA6Iu6cRfHZF xF0uIlQf2tJOfuuytX5amGHWmORaZwYM9Wd/vg2RNeuo6Q0OPAnBr7ax03DWBSDQo877t3OsYau eW2OrGyrDX/hjt4WQlfZwHkwglZWpvUCrk2dCkK9AvewQ5YXSxEjfHtctPpE5uXoG6sxaXnyvGk g== X-Received: by 2002:a17:90b:1d09:b0:33b:bed8:891c with SMTP id 98e67ed59e1d1-35a22053278mr9573278a91.23.1773613237313; Sun, 15 Mar 2026 15:20:37 -0700 (PDT) Received: from at-Standard-PC-Q35-ICH9-2009.. ([171.61.163.197]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35b98f0e5a6sm2547141a91.5.2026.03.15.15.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2026 15:20:37 -0700 (PDT) From: Atharva Tiwari To: Cc: Atharva Tiwari , Lukas Wunner , Ard Biesheuvel , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , linux-kernel@vger.kernel.org (open list), linux-efi@vger.kernel.org (open list:EXTENSIBLE FIRMWARE INTERFACE (EFI)), platform-driver-x86@vger.kernel.org (open list:X86 PLATFORM DRIVERS) Subject: [PATCH v3 1/2] efi: Save Brightness using EFI on Macs Date: Mon, 16 Mar 2026 03:49:59 +0530 Message-ID: <20260315222020.24341-2-atharvatiwarilinuxdev@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260315222020.24341-1-atharvatiwarilinuxdev@gmail.com> References: <20260315222020.24341-1-atharvatiwarilinuxdev@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently when a Mac reboots, the brightness is not the same as the previous boot instead its the same as the last time the Mac booted macOS. We can fix this issue by saving the brightness level to the efivar backlight-level. (tested on iMac20,1) Suggested-by: Lukas Wunner Signed-off-by: Atharva Tiwari --- drivers/firmware/efi/Kconfig | 10 +++ drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/apple-brightness.c | 67 +++++++++++++++++++ .../linux/platform_data/apple-brightness.h | 20 ++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/firmware/efi/apple-brightness.c create mode 100644 include/linux/platform_data/apple-brightness.h diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index 29e0729299f5..dd0a9c9a772a 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -167,6 +167,16 @@ config APPLE_PROPERTIES =20 If unsure, say Y if you have a Mac. Otherwise N. =20 +config APPLE_BRIGHTNESS + bool "Apple Backlight control for EFI" + depends on X86 + help + This will save the brightness level to EFI, so brightness + level is preserved across reboots and shutdows. allowing + for improved support of Apple hardware. + + If unsure, say Y if you have a Mac, Otherwise N. + config RESET_ATTACK_MITIGATION bool "Reset memory attack mitigation" depends on EFI_STUB diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index 8efbcf699e4f..1f5705cc87a2 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_EFI_BOOTLOADER_CONTROL) +=3D efibc.o obj-$(CONFIG_EFI_TEST) +=3D test/ obj-$(CONFIG_EFI_DEV_PATH_PARSER) +=3D dev-path-parser.o obj-$(CONFIG_APPLE_PROPERTIES) +=3D apple-properties.o +obj-$(CONFIG_APPLE_BRIGHTNESS) +=3D apple-brightness.o obj-$(CONFIG_EFI_RCI2_TABLE) +=3D rci2-table.o obj-$(CONFIG_EFI_EMBEDDED_FIRMWARE) +=3D embedded-firmware.o obj-$(CONFIG_LOAD_UEFI_KEYS) +=3D mokvar-table.o diff --git a/drivers/firmware/efi/apple-brightness.c b/drivers/firmware/efi= /apple-brightness.c new file mode 100644 index 000000000000..b060861b0795 --- /dev/null +++ b/drivers/firmware/efi/apple-brightness.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * apple-brightness.c - EFI brightness saver on Macs + * Copyright (C) 2026 Atharva Tiwari + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include + +static u32 efi_attr; +static u16 last_saved_level; + +static int (*get_brightness)(struct backlight_device *bl); +static struct backlight_device *bl_dev; + +void apple_brightness_shutdown(void) +{ + u16 level; + efi_status_t status; + + level =3D (u16)get_brightness(bl_dev); + + if (level =3D=3D last_saved_level) + return; + + status =3D efivar_set_variable(APPLE_BRIGHTNESS_NAME, &APPLE_BRIGHTNESS_G= UID, + efi_attr, sizeof(level), &level); + if (status !=3D EFI_SUCCESS) + pr_debug("Unable to set brightness: 0x%lx\n", status); +} +EXPORT_SYMBOL(apple_brightness_shutdown); + +int apple_brightness_probe(struct backlight_device *bl, + int (*get_brightnessfn)(struct backlight_device *bl)) +{ + efi_status_t status; + unsigned long size =3D sizeof(last_saved_level); + int ret; + + bl_dev =3D bl; + get_brightness =3D get_brightnessfn; + + if (!efi_rt_services_supported(EFI_RT_SUPPORTED_SET_VARIABLE)) + return -ENODEV; + + ret =3D efivar_lock(); + if (ret) + return ret; + + status =3D efivar_get_variable(APPLE_BRIGHTNESS_NAME, &APPLE_BRIGHTNESS_G= UID, + &efi_attr, &size, &last_saved_level); + + efivar_unlock(); + + if (status !=3D EFI_SUCCESS) + return -ENODEV; + + return 0; +} +EXPORT_SYMBOL(apple_brightness_probe); + +MODULE_AUTHOR("Atharva Tiwari "); +MODULE_DESCRIPTION("EFI Brightness saver for Macs"); +MODULE_LICENSE("Dual MIT/GPL"); diff --git a/include/linux/platform_data/apple-brightness.h b/include/linux= /platform_data/apple-brightness.h new file mode 100644 index 000000000000..54e3f3f8aa1c --- /dev/null +++ b/include/linux/platform_data/apple-brightness.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* + * apple-brightness.h - EFI brightness saver for Macs + * Copyright (C) 2026 Atharva Tiwari + */ + +#ifndef _APPLE_BL_H_ +#define _APPLE_BL_H_ + +#include +#include + +#define APPLE_BRIGHTNESS_NAME L"backlight-level" +#define APPLE_BRIGHTNESS_GUID EFI_GUID(0x7c436110, 0xab2a, 0x4bb= b, 0xa8, 0x80, 0xfe, 0x41, 0x99, 0x5c, 0x9f, 0x82) + +int apple_brightness_probe(struct backlight_device *bl, + int (*get_brightnessfn)(struct backlight_device *bl)); + +void apple_brightness_shutdown(void); +#endif /* _APPLE_BL_H */ --=20 2.43.0 From nobody Tue Apr 7 06:30:19 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20DD830B535 for ; Sun, 15 Mar 2026 22:20:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773613246; cv=none; b=qIkhowjd9zj3xwUcMYwt1DKHuQsnFfGXheWjbPfTO9SYV11ZOk7TdwXDnNE2nBmX+7RrF0llWujJBha0s3NNyfBSEdlJMvSxrga1WHlKsW4iqbiOcqHn++OHCdwE5QIDoVYll0VixO8+EwqJjETp8ZxuLCMq8hasZulMCrX/1GA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773613246; c=relaxed/simple; bh=oOvWfhRkf5OBj5wu+oQpsajq+P1fnPHlOTGZkcFTyGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DEaIoRka16hIgW++cAH0webpQoFigq98eVHLbADuXqFJV7vUuTdrXlKgJYh+ojr7/P7psRCdiDBqI3bOzEWqe25jcj9xyExB5fJLDxHRVbh8cAAeqawcNn3HajRR443K2uEzJoO6H3aQVb2xnR/egkz3QXCFyzlw8uG4+v5HdA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aiGavZC0; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aiGavZC0" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-35a211df8e3so1795996a91.2 for ; Sun, 15 Mar 2026 15:20:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773613244; x=1774218044; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=svmo5aWxoEnBP2787XF4CmgcR+jwYxqJJ3ujEK+SovQ=; b=aiGavZC0i0mBJJnIkR8/OnHudd2BQJlKMd6ZqUNKEhpenswrdhKP2RDo1RIfkYS5hm pGfdiRmuixRkxe7zCZMTHxEqM8Koa3MCOodoHW6MdpQFTmhj8cJT9O7+hmopNC9Vz4SF 8/i8X7knRuLFmGvH8DacsOs5YoX0Y/ePe0My5O9v46/MkqvSyCEfzlHRBoId4H505Edy V2V7QRK1SshdMMuRBvKSW0auBQQFWnUuwDD+q4RB6xeS4YFs1GEOtUCLLphSD59jdB7d 5BN8DQEt23nQIxRHTPjwv30HbFsu9ysfkcpX8iNVImkgyzpEG0tNilN6p9+dJMwoQ22R Gfrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773613244; x=1774218044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=svmo5aWxoEnBP2787XF4CmgcR+jwYxqJJ3ujEK+SovQ=; b=HWP/EQfeneAQLoIfHkkd6we4eXU2RDoZ6/Hy+7FvR9ZsasKLlgMzismlsGkf+yJsGM 17bDNr29eGTbOXFPwvc1oac/uoKm5yI5QG63yerDy3GSMm0oR5HkRB1w+v+kOtdiMYZP t0qxnavtltu3SuKUgbFVHT+zrIXXNbnlzVDUgLVH/MU07u0f/J/11zf1ySj9zqiBLnUL LX0xMJwl+/6Jb16TqKPZjTfbjy0+fd4F9tQySUv+r2LOjvMqXE3q3tBHCwl0wiUNcaTB I3sPY2e1HWVIV7N7pmoMeCKmdDTeKIyeK/2j/JyM2ePLrRMqsGnhEQ3ZBpeWXPGgcBP/ yeuw== X-Forwarded-Encrypted: i=1; AJvYcCWcN3D9zY6LKTPIDSfMCf3e3o4NvkxY3Soa3NqDktnOvw5xxLpI7xLduSulhDyOrJLDe/r8hUtyygG+vY0=@vger.kernel.org X-Gm-Message-State: AOJu0YwuoiNXtnjit4ncH+9xgUGfahyD507yeO2uURswP8QqG7azOPU6 5t+1sbLT4KanpYYWgKce50+LYoGloYKKnv4mKkUUjIwnGl6TXHLGQFE= X-Gm-Gg: ATEYQzymU5ZF0GJQeNWv8ey3DAsm343e01B82l2AjtYLPREP3dhZGIAe0feRVODcuSi GCV/rRjAEa+GCmLbyAfiROFq1INT1IH7YYO9HeOI0ZQX1k75nbSyNNoyJIQq5DPd8uv6xpekv6F e2GuOPhWc/CfQqvrhOC59Zz/KaHPBUN4iTMVwCCNlD2MDMTf23mrxKBnyEpa2776JWtL+QEoahk tAX9NOZhnPCFgFKBr/7qIE+jwLT2GtSdgOpIgkeZEKTewS/4nA2hT1bXl2Xz3R0KBOB7kAzJVSN 9Y7os7w363HeyHREmJliUPe+ck67C/LIPNuQdx86K6j9om4O4EjXQSHDESAhulqWhYzbSOP4lCL ++hQmbeoOftMMXF7O8yGLlqE0nHz9fAQg689hRoSzl30a5nUE3vfggJm3LRdmPgGx6FDtFcVo1W X/Trx0dYJUDvQO6/QfTt5lnx3qp3tKqDWtSrXnlHDrz4b+8sQEaLUK43xuJ18N9Iw= X-Received: by 2002:a17:90b:4e84:b0:35b:9d0c:a2f5 with SMTP id 98e67ed59e1d1-35b9d0cb646mr1425497a91.33.1773613244590; Sun, 15 Mar 2026 15:20:44 -0700 (PDT) Received: from at-Standard-PC-Q35-ICH9-2009.. ([171.61.163.197]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35b98f0e5a6sm2547141a91.5.2026.03.15.15.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2026 15:20:44 -0700 (PDT) From: Atharva Tiwari To: Cc: Atharva Tiwari , Ard Biesheuvel , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , linux-kernel@vger.kernel.org (open list), linux-efi@vger.kernel.org (open list:EXTENSIBLE FIRMWARE INTERFACE (EFI)), platform-driver-x86@vger.kernel.org (open list:X86 PLATFORM DRIVERS) Subject: [PATCH v3 2/2] platform/apple-gmux: use apple_brightness to save brightness to EFI Date: Mon, 16 Mar 2026 03:50:00 +0530 Message-ID: <20260315222020.24341-3-atharvatiwarilinuxdev@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260315222020.24341-1-atharvatiwarilinuxdev@gmail.com> References: <20260315222020.24341-1-atharvatiwarilinuxdev@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" use apple_brightness to save brightness to EFI. (tested on iMac20,1) Signed-off-by: Atharva Tiwari --- drivers/platform/x86/apple-gmux.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple= -gmux.c index 1417e230edbd..3797a0e7ff40 100644 --- a/drivers/platform/x86/apple-gmux.c +++ b/drivers/platform/x86/apple-gmux.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include =20 @@ -78,6 +79,8 @@ struct apple_gmux_data { /* debugfs data */ u8 selected_port; struct dentry *debug_dentry; + + bool save_efi; }; =20 static struct apple_gmux_data *apple_gmux_data; @@ -960,6 +963,13 @@ static int gmux_probe(struct pnp_dev *pnp, const struc= t pnp_device_id *id) } =20 gmux_init_debugfs(gmux_data); + if (IS_ENABLED(CONFIG_APPLE_BRIGHTNESS)) { + ret =3D apple_brightness_probe(gmux_data->bdev, &gmux_get_brightness); + if (ret) + pr_warn("Unable to Enable EFI brightness save: %d\n", ret); + else + gmux_data->save_efi =3D true; + } return 0; =20 err_register_handler: @@ -1012,6 +1022,16 @@ static void gmux_remove(struct pnp_dev *pnp) kfree(gmux_data); } =20 +static void gmux_shutdown(struct pnp_dev *pnp) +{ + struct apple_gmux_data *gmux_data =3D pnp_get_drvdata(pnp); + + if (gmux_data->save_efi) + apple_brightness_shutdown(); + + gmux_remove(pnp); +} + static const struct pnp_device_id gmux_device_ids[] =3D { {GMUX_ACPI_HID, 0}, {"", 0} @@ -1026,6 +1046,7 @@ static struct pnp_driver gmux_pnp_driver =3D { .name =3D "apple-gmux", .probe =3D gmux_probe, .remove =3D gmux_remove, + .shutdown =3D gmux_shutdown, .id_table =3D gmux_device_ids, .driver =3D { .pm =3D &gmux_dev_pm_ops, --=20 2.43.0