Prepare applesmc patches again for 6.10

This commit is contained in:
Aditya Garg
2024-06-29 10:25:12 +05:30
parent 677fbaf84e
commit 6570a9cbfa
9 changed files with 64 additions and 66 deletions
@@ -1,7 +1,7 @@
From 09dd6c563cd73d72e917de07e8d59358c41e051d Mon Sep 17 00:00:00 2001
From aa8cbca2aa7fa99119fe0e7de616d5b0dcde3a15 Mon Sep 17 00:00:00 2001
From: Paul Pawlowski <paul@mrarm.io>
Date: Sun, 17 Nov 2019 23:12:55 +0100
Subject: [PATCH 1/6] applesmc: convert static structures to drvdata
Subject: [PATCH 1/9] applesmc: convert static structures to drvdata
All static data structures have been moved to an applesmc_device struct,
which is then associated with the platform device.
@@ -14,7 +14,7 @@ Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
1 file changed, 319 insertions(+), 221 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 79b498f816fe..62211b590a61 100644
index fc6d6a905..7fb40738d 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -6,6 +6,7 @@
@@ -1040,7 +1040,7 @@ index 79b498f816fe..62211b590a61 100644
}
static int applesmc_dmi_match(const struct dmi_system_id *id)
@@ -1302,86 +1393,100 @@ static const struct dmi_system_id applesmc_whitelist[] __initconst = {
@@ -1306,86 +1397,100 @@ static const struct dmi_system_id applesmc_whitelist[] __initconst = {
{ .ident = NULL }
};
@@ -1190,7 +1190,7 @@ index 79b498f816fe..62211b590a61 100644
out_driver:
platform_driver_unregister(&applesmc_driver);
out_region:
@@ -1393,14 +1498,6 @@ static int __init applesmc_init(void)
@@ -1397,14 +1502,6 @@ static int __init applesmc_init(void)
static void __exit applesmc_exit(void)
{
@@ -1205,7 +1205,7 @@ index 79b498f816fe..62211b590a61 100644
platform_device_unregister(pdev);
platform_driver_unregister(&applesmc_driver);
release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
@@ -1410,6 +1507,7 @@ module_init(applesmc_init);
@@ -1414,6 +1511,7 @@ module_init(applesmc_init);
module_exit(applesmc_exit);
MODULE_AUTHOR("Nicolas Boichat");
@@ -1214,5 +1214,5 @@ index 79b498f816fe..62211b590a61 100644
MODULE_LICENSE("GPL v2");
MODULE_DEVICE_TABLE(dmi, applesmc_whitelist);
--
2.30.0
2.45.2
@@ -1,7 +1,7 @@
From 713e78b8dbb8adb92d4ee09ea11e726b05577689 Mon Sep 17 00:00:00 2001
From d0b5f668d43281eda94dd64d48e39973139d107c Mon Sep 17 00:00:00 2001
From: Paul Pawlowski <paul@mrarm.io>
Date: Sun, 17 Nov 2019 23:11:56 +0100
Subject: [PATCH 2/6] applesmc: make io port base addr dynamic
Subject: [PATCH 2/9] applesmc: make io port base addr dynamic
This change makes the port base runtime configurable.
The reason why this change is made is so that when we switch to an
@@ -16,7 +16,7 @@ Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
1 file changed, 49 insertions(+), 42 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 62211b590a61..39ed0bb21365 100644
index 7fb40738d..a599db68b 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -35,10 +35,11 @@
@@ -280,7 +280,7 @@ index 62211b590a61..39ed0bb21365 100644
if (ret)
return ret;
@@ -1468,7 +1475,7 @@ static int __init applesmc_init(void)
@@ -1472,7 +1479,7 @@ static int __init applesmc_init(void)
goto out;
}
@@ -289,7 +289,7 @@ index 62211b590a61..39ed0bb21365 100644
"applesmc")) {
ret = -ENXIO;
goto out;
@@ -1490,7 +1497,7 @@ static int __init applesmc_init(void)
@@ -1494,7 +1501,7 @@ static int __init applesmc_init(void)
out_driver:
platform_driver_unregister(&applesmc_driver);
out_region:
@@ -298,7 +298,7 @@ index 62211b590a61..39ed0bb21365 100644
out:
pr_warn("driver init failed (ret=%d)!\n", ret);
return ret;
@@ -1500,7 +1507,7 @@ static void __exit applesmc_exit(void)
@@ -1504,7 +1511,7 @@ static void __exit applesmc_exit(void)
{
platform_device_unregister(pdev);
platform_driver_unregister(&applesmc_driver);
@@ -308,5 +308,5 @@ index 62211b590a61..39ed0bb21365 100644
module_init(applesmc_init);
--
2.30.0
2.45.2
@@ -1,7 +1,7 @@
From ee3d4bf4a01bc94553bde2ae3e806a63a13faa12 Mon Sep 17 00:00:00 2001
From c405f826e30e0035581b350084d61457ddde6146 Mon Sep 17 00:00:00 2001
From: Paul Pawlowski <paul@mrarm.io>
Date: Sun, 17 Nov 2019 23:12:08 +0100
Subject: [PATCH 3/6] applesmc: switch to acpi_device (from platform)
Date: Sat, 29 Jun 2024 04:49:16 +0000
Subject: [PATCH 3/9] applesmc: switch to acpi_device (from platform)
This change makes the change from platform_device
to acpi_device. The rationale for this change is
@@ -17,11 +17,11 @@ should not result in any incompatibilities.
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
---
drivers/hwmon/applesmc.c | 125 ++++++++++++++++++++++++++-------------
1 file changed, 85 insertions(+), 40 deletions(-)
drivers/hwmon/applesmc.c | 124 ++++++++++++++++++++++++++-------------
1 file changed, 84 insertions(+), 40 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 39ed0bb21365..bdaaf696f7b6 100644
index a599db68b..b4fe412c0 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -19,7 +19,7 @@
@@ -167,7 +167,7 @@ index 39ed0bb21365..bdaaf696f7b6 100644
/* Synchronize device with memorized backlight state */
static int applesmc_pm_resume(struct device *dev)
{
@@ -763,18 +820,28 @@ static int applesmc_pm_restore(struct device *dev)
@@ -763,17 +820,26 @@ static int applesmc_pm_restore(struct device *dev)
return applesmc_pm_resume(dev);
}
@@ -194,15 +194,13 @@ index 39ed0bb21365..bdaaf696f7b6 100644
+ .ops = {
+ .add = applesmc_add,
+ .remove = applesmc_remove
},
+ },
+ .drv = {
+ .pm = &applesmc_pm_ops
+ },
+ .owner = THIS_MODULE
},
};
/*
@@ -1262,7 +1329,6 @@ static int applesmc_create_nodes(struct applesmc_device *smc,
@@ -1262,7 +1328,6 @@ static int applesmc_create_nodes(struct applesmc_device *smc,
static int applesmc_create_accelerometer(struct applesmc_device *smc)
{
int ret;
@@ -210,7 +208,7 @@ index 39ed0bb21365..bdaaf696f7b6 100644
if (!smc->reg.has_accelerometer)
return 0;
@@ -1463,8 +1529,6 @@ static void applesmc_destroy_modules(struct applesmc_device *smc)
@@ -1467,8 +1532,6 @@ static void applesmc_destroy_modules(struct applesmc_device *smc)
applesmc_destroy_nodes(smc, info_group);
}
@@ -219,7 +217,7 @@ index 39ed0bb21365..bdaaf696f7b6 100644
static int __init applesmc_init(void)
{
int ret;
@@ -1475,29 +1539,12 @@ static int __init applesmc_init(void)
@@ -1479,29 +1542,12 @@ static int __init applesmc_init(void)
goto out;
}
@@ -251,7 +249,7 @@ index 39ed0bb21365..bdaaf696f7b6 100644
out:
pr_warn("driver init failed (ret=%d)!\n", ret);
return ret;
@@ -1505,9 +1552,7 @@ static int __init applesmc_init(void)
@@ -1509,9 +1555,7 @@ static int __init applesmc_init(void)
static void __exit applesmc_exit(void)
{
@@ -263,5 +261,5 @@ index 39ed0bb21365..bdaaf696f7b6 100644
module_init(applesmc_init);
--
2.30.0
2.45.2
+4 -4
View File
@@ -1,7 +1,7 @@
From 43df89a1377782788760808d8ea4bcf0730effbb Mon Sep 17 00:00:00 2001
From 1ce5dd27e4464383ddfba3ee0d7ffdc7020bd81c Mon Sep 17 00:00:00 2001
From: Paul Pawlowski <paul@mrarm.io>
Date: Sun, 17 Nov 2019 23:12:14 +0100
Subject: [PATCH 4/6] applesmc: key interface wrappers
Subject: [PATCH 4/9] applesmc: key interface wrappers
This change replaces the read_smc and write_smc
methods with wrappers, additionally removing the
@@ -20,7 +20,7 @@ Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
1 file changed, 79 insertions(+), 40 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index bdaaf696f7b6..3017d8ca2c79 100644
index b4fe412c0..5442897e3 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -172,7 +172,7 @@ static const int debug;
@@ -294,5 +294,5 @@ index bdaaf696f7b6..3017d8ca2c79 100644
out:
--
2.30.0
2.45.2
@@ -1,7 +1,7 @@
From 799e7a54c62a36007f7874c58d7dac87c9651759 Mon Sep 17 00:00:00 2001
From 665609158a43eb6ab3d79e6ee06b9c1edf1cd331 Mon Sep 17 00:00:00 2001
From: Aun-Ali Zaidi <admin@kodeit.net>
Date: Sun, 17 Nov 2019 23:12:16 +0100
Subject: [PATCH 5/6] applesmc: basic mmio interface implementation
Subject: [PATCH 5/9] applesmc: basic mmio interface implementation
This change introduces a basic MMIO-based
interface implementation required to communicate
@@ -21,7 +21,7 @@ Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
1 file changed, 231 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 3017d8ca2c79..2d23bb9ad9dd 100644
index 5442897e3..435541f9f 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -42,6 +42,18 @@
@@ -339,5 +339,5 @@ index 3017d8ca2c79..2d23bb9ad9dd 100644
}
--
2.30.0
2.45.2
+10 -10
View File
@@ -1,7 +1,7 @@
From 4e63e9b77422aae8e7411ddc7a8458c2585c86df Mon Sep 17 00:00:00 2001
From e77e6a12cd389d1d61b861a1c88a6f393daa6d91 Mon Sep 17 00:00:00 2001
From: Paul Pawlowski <paul@mrarm.io>
Date: Sun, 17 Nov 2019 23:12:18 +0100
Subject: [PATCH 6/6] applesmc: fan support on T2 Macs
Subject: [PATCH 6/9] applesmc: fan support on T2 Macs
T2 Macs changed the fan values from shorts to
floats, and changed the fan manual override
@@ -19,7 +19,7 @@ Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
1 file changed, 102 insertions(+), 17 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 2d23bb9ad9dd..0938227be612 100644
index 435541f9f..46b64eba7 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -87,6 +87,7 @@
@@ -81,7 +81,7 @@ index 2d23bb9ad9dd..0938227be612 100644
/*
* applesmc_device_init - initialize the accelerometer. Can sleep.
*/
@@ -1242,6 +1280,7 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
@@ -1241,6 +1279,7 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
struct device_attribute *attr, char *sysfsbuf)
{
struct applesmc_device *smc = dev_get_drvdata(dev);
@@ -89,7 +89,7 @@ index 2d23bb9ad9dd..0938227be612 100644
int ret;
unsigned int speed = 0;
char newkey[5];
@@ -1250,11 +1289,21 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
@@ -1249,11 +1288,21 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
scnprintf(newkey, sizeof(newkey), fan_speed_fmt[to_option(attr)],
to_index(attr));
@@ -113,7 +113,7 @@ index 2d23bb9ad9dd..0938227be612 100644
return sysfs_emit(sysfsbuf, "%u\n", speed);
}
@@ -1263,6 +1312,7 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
@@ -1262,6 +1311,7 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
const char *sysfsbuf, size_t count)
{
struct applesmc_device *smc = dev_get_drvdata(dev);
@@ -121,7 +121,7 @@ index 2d23bb9ad9dd..0938227be612 100644
int ret;
unsigned long speed;
char newkey[5];
@@ -1274,9 +1324,18 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
@@ -1273,9 +1323,18 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
scnprintf(newkey, sizeof(newkey), fan_speed_fmt[to_option(attr)],
to_index(attr));
@@ -143,7 +143,7 @@ index 2d23bb9ad9dd..0938227be612 100644
if (ret)
return ret;
@@ -1291,12 +1350,26 @@ static ssize_t applesmc_show_fan_manual(struct device *dev,
@@ -1290,12 +1349,26 @@ static ssize_t applesmc_show_fan_manual(struct device *dev,
int ret;
u16 manual = 0;
u8 buffer[2];
@@ -172,7 +172,7 @@ index 2d23bb9ad9dd..0938227be612 100644
return sysfs_emit(sysfsbuf, "%d\n", manual);
}
@@ -1307,27 +1380,39 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
@@ -1306,27 +1379,39 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
struct applesmc_device *smc = dev_get_drvdata(dev);
int ret;
u8 buffer[2];
@@ -223,5 +223,5 @@ index 2d23bb9ad9dd..0938227be612 100644
out:
if (ret)
--
2.30.0
2.45.2
@@ -1,7 +1,7 @@
From 58868e6f356229eab48cfdee1603011653a19c79 Mon Sep 17 00:00:00 2001
From 5c95c8e1ada14babfba0f21a2f481d7ff53d17c7 Mon Sep 17 00:00:00 2001
From: Orlando Chamberlain <redecorating@protonmail.com>
Date: Sun, 9 Oct 2022 15:59:01 +0530
Subject: [PATCH] applesmc: Add iMacPro to applesmc_whitelist
Subject: [PATCH 7/9] applesmc: Add iMacPro to applesmc_whitelist
The iMacPro1,1 is the only iMacPro released before the line was
discontinued. Add it to the applesmc_whitelist.
@@ -12,10 +12,10 @@ Signed-off-by: Orlando Chamberlain <redecorating@protonmail.com>
1 file changed, 4 insertions(+)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 8b3f73fcb..493f95bb0 100644
index 46b64eba7..8c7b2e2cd 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1804,6 +1804,10 @@ static const struct dmi_system_id applesmc_whitelist[] __initconst = {
@@ -1803,6 +1803,10 @@ static const struct dmi_system_id applesmc_whitelist[] __initconst = {
DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
DMI_MATCH(DMI_PRODUCT_NAME, "Macmini") },
},
@@ -27,5 +27,5 @@ index 8b3f73fcb..493f95bb0 100644
DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
--
2.34.1
2.45.2
@@ -1,7 +1,7 @@
From e52b0fad357b6203691942831715fce4f26d66e2 Mon Sep 17 00:00:00 2001
From 4d444d98c6f5f7f39540386b97aa8d77102ada74 Mon Sep 17 00:00:00 2001
From: Orlando Chamberlain <orlandoch.dev@gmail.com>
Date: Tue, 24 Jan 2023 15:46:48 +1100
Subject: [PATCH 1/1] applesmc: make applesmc_remove void
Subject: [PATCH 8/9] applesmc: make applesmc_remove void
for linux6.2 compatibility
---
@@ -9,7 +9,7 @@ for linux6.2 compatibility
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index d071130ff68d..12be9269a314 100644
index 8c7b2e2cd..5f67d7362 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -979,7 +979,7 @@ static int applesmc_add(struct acpi_device *dev)
@@ -31,5 +31,5 @@ index d071130ff68d..12be9269a314 100644
static acpi_status applesmc_walk_resources(struct acpi_resource *res,
--
2.39.1
2.45.2
+9 -9
View File
@@ -1,17 +1,17 @@
From 38786c7979c8ece013b5b7d5cb07dc2aa40198be Mon Sep 17 00:00:00 2001
From add0db8b96c3f90b844586a3b9ea32041bae4b2c Mon Sep 17 00:00:00 2001
From: Orlando Chamberlain <orlandoch.dev@gmail.com>
Date: Mon, 30 Jan 2023 18:42:21 +1100
Subject: [PATCH 1/1] applesmc: battery charge limiter
Subject: [PATCH 9/9] applesmc: battery charge limiter
---
drivers/hwmon/applesmc.c | 42 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 12be9269a314..bc1eec74cfef 100644
index 5f67d7362..698f44794 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1478,6 +1478,35 @@ static void applesmc_brightness_set(struct led_classdev *led_cdev,
@@ -1477,6 +1477,35 @@ static void applesmc_brightness_set(struct led_classdev *led_cdev,
dev_dbg(led_cdev->dev, "work was already on the queue.\n");
}
@@ -47,7 +47,7 @@ index 12be9269a314..bc1eec74cfef 100644
static ssize_t applesmc_key_count_show(struct device *dev,
struct device_attribute *attr, char *sysfsbuf)
{
@@ -1612,6 +1641,11 @@ static struct applesmc_node_group temp_group[] = {
@@ -1611,6 +1640,11 @@ static struct applesmc_node_group temp_group[] = {
{ }
};
@@ -59,7 +59,7 @@ index 12be9269a314..bc1eec74cfef 100644
/* Module stuff */
/*
@@ -1830,10 +1864,13 @@ static int applesmc_create_modules(struct applesmc_device *smc)
@@ -1829,10 +1863,13 @@ static int applesmc_create_modules(struct applesmc_device *smc)
ret = applesmc_create_nodes(smc, info_group, 1);
if (ret)
goto out;
@@ -74,7 +74,7 @@ index 12be9269a314..bc1eec74cfef 100644
ret = applesmc_create_nodes(smc, temp_group, smc->reg.index_count);
if (ret)
@@ -1869,6 +1906,8 @@ static int applesmc_create_modules(struct applesmc_device *smc)
@@ -1868,6 +1905,8 @@ static int applesmc_create_modules(struct applesmc_device *smc)
applesmc_destroy_nodes(smc, temp_group);
out_fans:
applesmc_destroy_nodes(smc, fan_group);
@@ -83,7 +83,7 @@ index 12be9269a314..bc1eec74cfef 100644
out_info:
applesmc_destroy_nodes(smc, info_group);
out:
@@ -1883,6 +1922,7 @@ static void applesmc_destroy_modules(struct applesmc_device *smc)
@@ -1882,6 +1921,7 @@ static void applesmc_destroy_modules(struct applesmc_device *smc)
applesmc_release_accelerometer(smc);
applesmc_destroy_nodes(smc, temp_group);
applesmc_destroy_nodes(smc, fan_group);
@@ -92,5 +92,5 @@ index 12be9269a314..bc1eec74cfef 100644
}
--
2.39.1
2.45.2