use apple_brightness to save brightness to EFI.
(tested on iMac20,1)
Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
---
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 <linux/pci.h>
#include <linux/vga_switcheroo.h>
#include <linux/debugfs.h>
+#include <linux/platform_data/apple-brightness.h>
#include <acpi/video.h>
#include <asm/io.h>
@@ -78,6 +79,8 @@ struct apple_gmux_data {
/* debugfs data */
u8 selected_port;
struct dentry *debug_dentry;
+
+ bool save_efi;
};
static struct apple_gmux_data *apple_gmux_data;
@@ -960,6 +963,13 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
}
gmux_init_debugfs(gmux_data);
+ if (IS_ENABLED(CONFIG_APPLE_BRIGHTNESS)) {
+ ret = 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 = true;
+ }
return 0;
err_register_handler:
@@ -1012,6 +1022,16 @@ static void gmux_remove(struct pnp_dev *pnp)
kfree(gmux_data);
}
+static void gmux_shutdown(struct pnp_dev *pnp)
+{
+ struct apple_gmux_data *gmux_data = pnp_get_drvdata(pnp);
+
+ if (gmux_data->save_efi)
+ apple_brightness_shutdown();
+
+ gmux_remove(pnp);
+}
+
static const struct pnp_device_id gmux_device_ids[] = {
{GMUX_ACPI_HID, 0},
{"", 0}
@@ -1026,6 +1046,7 @@ static struct pnp_driver gmux_pnp_driver = {
.name = "apple-gmux",
.probe = gmux_probe,
.remove = gmux_remove,
+ .shutdown = gmux_shutdown,
.id_table = gmux_device_ids,
.driver = {
.pm = &gmux_dev_pm_ops,
--
2.43.0
Hi Atharva, kernel test robot noticed the following build errors: [auto build test ERROR on efi/next] [also build test ERROR on linus/master v7.0-rc4 next-20260313] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Atharva-Tiwari/efi-Save-Brightness-using-EFI-on-Macs/20260316-084441 base: https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git next patch link: https://lore.kernel.org/r/20260315222020.24341-3-atharvatiwarilinuxdev%40gmail.com patch subject: [PATCH v3 2/2] platform/apple-gmux: use apple_brightness to save brightness to EFI config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260316/202603161105.ILZkpASC-lkp@intel.com/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260316/202603161105.ILZkpASC-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202603161105.ILZkpASC-lkp@intel.com/ All errors (new ones prefixed by >>, old ones prefixed by <<): >> ERROR: modpost: "apple_brightness_shutdown" [drivers/platform/x86/apple-gmux.ko] undefined! -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.