From patchwork Thu Nov 7 06:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842140 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2076.outbound.protection.outlook.com [40.107.93.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1170192D7E; Thu, 7 Nov 2024 06:03:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; cv=fail; b=cUfGM3KdpL2efT2AhRh36I23YH/1WcHy8C/c8ERcGONy5IVKrh+CkQQZtV6bUR9A4jSGEYHGjr2zwcn+UC3Z9TsJ3bhenzZV2s3MpG8VIkVZaNqJFrTmLMzJDqguftiF1BpkXLyjxRHgDnhuFHhUk3gkG5nYngSOvQVg/Mf7whI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; c=relaxed/simple; bh=YrvhKUBrmKASOjRrsD4+2FutuCJZ/+C9KrTb2y2zj1E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=okvfKpP0lgY/RtalaGXMNPjMb99wYywAJ1OWPLF9EwTnnYr7l5T0/xpsKnL152ljIbvfaSK1msu2xp/vEDVjEL2r+vE/ZWrqWgWD3xMcWg2NP0LDt9yevto9YY0Ehi13SoID8HVNmOqjqbPgx2bEYX2IEWeEYH8WQShm6XlAwxA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=uwAepv1V; arc=fail smtp.client-ip=40.107.93.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uwAepv1V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kVnaV0d72dPj5RqWaJapTngmFB9LRPPDAaqePNNNIYGK6PbS/YZs+dtwWGF4zQv6Rw5RwIR3Sfe9Cnma9iNeJvblOpb7RMkkuJadm8T3TN1koO7m1Qi+oWv/JrSGKeNhNSFonpP6wDxLK8CAhnLVBFBaFbtJd0nSC8XbzW44y71MKZdIhnfzOIb73ZQ50NVo0pFNDBf3HM4+3K54lumu2ilP5z9sOrG0mjALKfXVAKynP9d1c9yOqzj2+etCXIdRhbsv18+XggjteDiGruye4P1LngrAU6rCTkOhC0ipYDWYcBq7i1tmE56uEQ91QkGLff6dlIxpQA6hcarVLplxJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4JnTbbFF5wE4ooCniMJuEfRSre9huJa0rS/D8f+fLP0=; b=CRXNEEBhuTZFyWtOcvYVdXbPpZ1BrzKCKufJWxexwB4PEaREyTDVf+cx6V9V8TZf4WFZ4GAxSofotWDCsRDVCg1tGN/FCAVuo9dy/Z0ozCCANwPlkREPrX3r76CI4v23n+yTPVHgZbBPTv3E4gSOa0uwTt/ACb/zWgDzVWtkmFNLMZGIOukrcL3MgMSAD4KXSVSYMVMwCREj7nTd3vNupm67DhL9JdVrYScCJV4GpBgTGkq/clFFBkzgqHtu6InWC9bWRXZmr38hvvrmuvp3OWTDY0OxP/6cfy4ofkOZhgW2+tqIl7zmEuu2PMpt/A6GEKW00fKpXVIX/Cj3M6bdSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4JnTbbFF5wE4ooCniMJuEfRSre9huJa0rS/D8f+fLP0=; b=uwAepv1VceZcCqqZ/Cfufy8RHoU/8dDuk7PVEAjoBLTh/tKHQ9Jt57AORFTIqjGGLLu8gQlZh949Al7QLZJlf64VXfnCNnSPFXVXR9hCtxNLEObcJKVr/D8IJ8dpmnI8XF968owDHALIGHMl1QwN34VmuHcklwFPTWDPWtXLxx8= Received: from CH2PR07CA0007.namprd07.prod.outlook.com (2603:10b6:610:20::20) by PH7PR12MB7331.namprd12.prod.outlook.com (2603:10b6:510:20e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Thu, 7 Nov 2024 06:03:29 +0000 Received: from CH2PEPF00000148.namprd02.prod.outlook.com (2603:10b6:610:20:cafe::8) by CH2PR07CA0007.outlook.office365.com (2603:10b6:610:20::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000148.mail.protection.outlook.com (10.167.244.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:29 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Nov 2024 00:03:27 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device Date: Thu, 7 Nov 2024 00:02:36 -0600 Message-ID: <20241107060254.17615-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000148:EE_|PH7PR12MB7331:EE_ X-MS-Office365-Filtering-Correlation-Id: 5805d461-7537-4b58-ee5c-08dcfef1e70a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|7416014|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HOvRLpZaWuKZ+eHXHt6IWHHnX3JxmUr?= =?utf-8?q?7esxLgHB1giDQz8B3n1zebWQnq4Y/vW9vSshWnyIyqdmGLV1nI5jXaslvpCKazvqC?= =?utf-8?q?GyeGxEi7bYT6kxcz4c0geXaIiiEwg2iitk8PfuOJtd3s83x2owcPLeDAK9ghoz+gD?= =?utf-8?q?1YBeH2JjdEiY331Rw3ONpgYy56vzJfx5bKcvVqhviMjcBQQ67/OyxT27X8kLcT2GU?= =?utf-8?q?sy4oj/2P+c53mGQbYeZYnJuD6zmwG9rJQ3rrkP2SEHWDILW9cKIWIhjnAZvdSxWvu?= =?utf-8?q?z20+o21AlHPUbcnvtgpO7OF1Iq/wixqLg/d4KNm+63okczapi+f+BGku4ULW7Huek?= =?utf-8?q?8g6NFmytR1u2eTq4NP1UmsXBPO3UitNJosSdc5n5NtLUeXJnVLHxbWlJlf9q46T+9?= =?utf-8?q?m0KNP3FIKxMs+x8M0ElhANnVenbzj2TTTrke6svEhGLdAK5iIb5VMblgs0mWys/JI?= =?utf-8?q?dW2m1tX1+PFxEwn7Cn2bsivniL40WGX0orGubXu7klYlvwu7RYNdtvkycNIv6EpM0?= =?utf-8?q?NZnQdIPICOWnDU27RGBwGwjRE90IW0nLTziLGshnk0/MSBFFCk8fTHo9rMss2icCn?= =?utf-8?q?fAbm1lFj0Xrno623w+2c67mBjEN+tepW/mRons2W2ZmyvHd6lP8zWjOqgOYQnWFiO?= =?utf-8?q?OVgNd1n964aSvAGFzEB2d+2X6/N68n/9GkbwzUg3nMoXiZnVNjipkDTEO+vuowCbI?= =?utf-8?q?p5bu1A2XC2x3o0Bme/b+ZqhGdDjxbGypHpvdR7sfv/A+/1vtTWZtQ4vecDZlvdkpk?= =?utf-8?q?O7mq6j5rrEpZm2niWO1y1KW/h3+mITiig16w7wzVMD+j0Zt/7hTCEXRuXoy2Uacfm?= =?utf-8?q?LlmL4PN1ue3IoYDxr0Zt6K6S2cAKFyja9TW36eOySjHmAe5Octl6BghFTScbko427?= =?utf-8?q?SpDjAqdjuOl9Np9/W3UZIIu58d9sk3KcQ/JdR/pA+t+ElGTQdHhqw+Xfn/KPWfYI4?= =?utf-8?q?ML+jReDE04ldiKvp0O8BWrchfuvdSvZ32kg/R6yVi2hPkHtkovds/P8R66CAcKyFN?= =?utf-8?q?Mu45//igx0sfMLtf0lP3RQFmeDe4xzCH47zlFUTab3Yl8jY0SC118ViaCY8o97lRO?= =?utf-8?q?RQDhVzFvanZ9V7QrZgaByvRe2/B82PkelKt3qprqSEnj88Mp0gGsn9fFjBFMTOENh?= =?utf-8?q?DH1WehsLQ3UWQ2E0j47jR/Ts+aUZdOlC5OoYpAnYjvd1gFTTluq6xpZmYO9smStNJ?= =?utf-8?q?p1A0R0SucBJ4V9ZUpk2DNzwQNFgPn1/ZgwoKYrco5KHAKd4uqWuFp7QjiPi5ntjnp?= =?utf-8?q?O98lXDrHdzJnr+D2CLQxC3IeltUUwf3SKPKfmKHBDBU3qqHFA7+GCh6uKyuLArGG9?= =?utf-8?q?HkPKri20DaCo4zCV/RIKlf2Itpy3GDtA1w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(7416014)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:29.4563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5805d461-7537-4b58-ee5c-08dcfef1e70a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000148.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7331 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v5: * use platform_device_register_simple() --- drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..0cd9b26572b61 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -18,10 +18,13 @@ #include #include #include +#include #include #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,15 @@ 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_register_simple("dell-pc", -1, NULL, 0); + if (!platform_device) return -ENOMEM; + + 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 +271,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_unregister(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)