lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241031040952.109057-3-mario.limonciello@amd.com>
Date: Wed, 30 Oct 2024 23:09:32 -0500
From: Mario Limonciello <mario.limonciello@....com>
To: Hans de Goede <hdegoede@...hat.com>, Ilpo Järvinen
	<ilpo.jarvinen@...ux.intel.com>
CC: "Rafael J . Wysocki" <rafael@...nel.org>, Len Brown <lenb@...nel.org>,
	Maximilian Luz <luzmaximilian@...il.com>, Lee Chun-Yi <jlee@...e.com>, "Shyam
 Sundar S K" <Shyam-sundar.S-k@....com>, Corentin Chary
	<corentin.chary@...il.com>, "Luke D . Jones" <luke@...nes.dev>, Ike Panhc
	<ike.pan@...onical.com>, Henrique de Moraes Holschuh <hmh@....eng.br>,
	"Alexis Belmonte" <alexbelm48@...il.com>, Uwe Kleine-König
	<u.kleine-koenig@...gutronix.de>, Ai Chao <aichao@...inos.cn>, Gergo Koteles
	<soyer@....hu>, open list <linux-kernel@...r.kernel.org>, "open list:ACPI"
	<linux-acpi@...r.kernel.org>, "open list:MICROSOFT SURFACE PLATFORM PROFILE
 DRIVER" <platform-driver-x86@...r.kernel.org>, "open list:THINKPAD ACPI
 EXTRAS DRIVER" <ibm-acpi-devel@...ts.sourceforge.net>, Mark Pearson
	<mpearson-lenovo@...ebb.ca>, Matthew Schwartz <matthew.schwartz@...ux.dev>,
	Mario Limonciello <mario.limonciello@....com>
Subject: [PATCH v3 02/22] platform/x86/dell: dell-pc: Create platform device

In order to have a device for the platform profile core to reference
create a platform device for dell-pc.

While doing this change the memory allocation for the thermal handler
to be device managed to follow the lifecycle of that device.

Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
 drivers/platform/x86/dell/dell-pc.c | 35 +++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
index 3cf79e55e3129..b145fedb6b710 100644
--- a/drivers/platform/x86/dell/dell-pc.c
+++ b/drivers/platform/x86/dell/dell-pc.c
@@ -18,10 +18,13 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_profile.h>
+#include <linux/platform_device.h>
 #include <linux/slab.h>
 
 #include "dell-smbios.h"
 
+static struct platform_device *platform_device;
+
 static const struct dmi_system_id dell_device_table[] __initconst = {
 	{
 		.ident = "Dell Inc.",
@@ -244,9 +247,18 @@ static int thermal_init(void)
 	if (!supported_modes)
 		return 0;
 
-	thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL);
-	if (!thermal_handler)
+	platform_device = platform_device_alloc("dell-pc", PLATFORM_DEVID_NONE);
+	if (!platform_device)
 		return -ENOMEM;
+	ret = platform_device_add(platform_device);
+	if (ret)
+		goto cleanup_platform_device;
+
+	thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL);
+	if (!thermal_handler) {
+		ret = -ENOMEM;
+		goto cleanup_platform_device;
+	}
 	thermal_handler->name = "dell-pc";
 	thermal_handler->profile_get = thermal_platform_profile_get;
 	thermal_handler->profile_set = thermal_platform_profile_set;
@@ -262,20 +274,25 @@ static int thermal_init(void)
 
 	/* Clean up if failed */
 	ret = platform_profile_register(thermal_handler);
-	if (ret) {
-		kfree(thermal_handler);
-		thermal_handler = NULL;
-	}
+	if (ret)
+		goto cleanup_thermal_handler;
+
+	return 0;
+
+cleanup_thermal_handler:
+	thermal_handler = NULL;
+
+cleanup_platform_device:
+	platform_device_del(platform_device);
 
 	return ret;
 }
 
 static void thermal_cleanup(void)
 {
-	if (thermal_handler) {
+	if (thermal_handler)
 		platform_profile_remove();
-		kfree(thermal_handler);
-	}
+	platform_device_unregister(platform_device);
 }
 
 static int __init dell_init(void)
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ