From d5367eb9e5b5542407494d04ac1a0e77f10cc89d Mon Sep 17 00:00:00 2001
From: maniacx <macs18max@gmail.com>
Date: Sun, 3 Dec 2023 16:18:52 -0800
Subject: [PATCH] battery: ensure backward compatibility with pre 6.2 kernels
 (#2)

Closes #1
---
 framework_laptop.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/framework_laptop.c b/framework_laptop.c
index 075bc2a..b848ebe 100644
--- a/framework_laptop.c
+++ b/framework_laptop.c
@@ -25,6 +25,7 @@
 #include <linux/platform_device.h>
 #include <linux/platform_data/cros_ec_proto.h>
 #include <linux/platform_data/cros_ec_commands.h>
+#include <linux/version.h>
 
 #include <acpi/battery.h>
 
@@ -230,7 +231,11 @@ static struct attribute *framework_laptop_battery_attrs[] = {
 
 ATTRIBUTE_GROUPS(framework_laptop_battery);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)
 static int framework_laptop_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook)
+#else
+static int framework_laptop_battery_add(struct power_supply *battery)
+#endif
 {
 	// Framework EC only supports 1 battery
 	if (strcmp(battery->desc->name, "BAT1") != 0)
@@ -242,7 +247,11 @@ static int framework_laptop_battery_add(struct power_supply *battery, struct acp
 	return 0;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)
 static int framework_laptop_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook)
+#else
+static int framework_laptop_battery_remove(struct power_supply *battery)
+#endif
 {
 	device_remove_groups(&battery->dev, framework_laptop_battery_groups);
 	return 0;
-- 
GitLab