From patchwork Tue Nov 5 15:32:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13863082 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) (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 CD98E13D52E; Tue, 5 Nov 2024 15:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; cv=fail; b=rEyV/DJnAQLGjEhJiLk7KMm+rBVfKenofMG6M8q1deA1aXK47fnxrS7ZMw47KZOR6s/evrzdQ+Hc4b6jc81z4mUv2OKW+iisTCjQBCqtM92A8KnCD2KVdRKhkvypII9MvQPOWuox+EJOJZO/sw7CaniOSjQVtssqOmOH51mIyss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; c=relaxed/simple; bh=Hf4w1lZfBgnE3Sq+P9ER52v4RFaq4g6HvEIEXOsuI1w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lkzRPoCxLH32ZssqVJG11BhwQyS59AA4/uyab99vDx0KnXAwRcCKuTaB1AentV56+i/qgsBopQnNgjWEmXObmlqg8mh7a94Eb/hD0YxLCwfl5iX9gfc5kcS735ThXeOblLEAXWWvh50DFcTRlxrSJ4PBAtgisBCefSJ1SdI57BU= 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=lSzG5P+A; arc=fail smtp.client-ip=40.107.237.50 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="lSzG5P+A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AnZ97z9toftLSjMzFRhRic8jbOV3xPW+D3YkRqZxplf5TRph3HvSGXrMsDK5tJupubVt7mGiUMQqOfy5bh29XeyNarF1tEdEYpNyfxuvkiuS4tgmxi8LnT2rBpHYQ4d2bi2dkQUHPIu4t9T6njJ6+pU0X1KqLjTC8amHYjXBmO0DTKdsji7of4hHYErP9qB/WxFWe9taWSXbhWshyrmC0/UcfR0c8Axc3+zIX4icy/UvzO4t+qQRYA9y1evZjYzkOgUXWQGr7FNso8KDeIndqWdA3w10kVmoM7V+uH3fBpt2v6ZX6qqkT7FX4JmWGvxmPPDhaK6hsCLXoScWGTs0Rw== 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=3oVr6vEiyIil7hu0Gy4FhGVYc4++Na2Ht5xVbuuI/U8=; b=pKXJk9+d2YYRLtZtEhd4AZPvnPOwmM9CWsBxMdR3Ti9Pchs2/PezzkaraZ24SAmrDdeMUByJOAGtnleF+PES60Cos5pfUN6VbK1Zh9UADKaUM+aX8UTQw19pDczFjp5QwCWxDZiS7kwAX9FkjPYxkmkpnYm7MUDiVTstS0kYEftilDZx71UfV8ZrsGvKofN4Y1h7qvuEEE/lUzfc+UPwvVOD0ji3cl4TFt9QtG3u9lnFBxCLh41PyQGBmR/YhvvDrxv+5432K0GBjDC7S2eIHzpDW4Iu57d4znUJV46/ag42bRjhIac7lSf7+3SOEHWJEFpaf9BmHoC7JqmRmaVWdQ== 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=3oVr6vEiyIil7hu0Gy4FhGVYc4++Na2Ht5xVbuuI/U8=; b=lSzG5P+AwfGLUsXNFvo0VeAgma+URK7QpslxSfxQni3cmMAVuyTnKK50944i770lj0P1s6/AcwkJb6x5aTEgyqpoJxnP+vMCq+OiQaJh6FTFBI1lq0FCKNxVxKLeozBxxps13uByNSsmmTst1NlRo2VMw38ZT/OmDSEtda6F3T4= Received: from MN0PR04CA0018.namprd04.prod.outlook.com (2603:10b6:208:52d::11) by SA1PR12MB8723.namprd12.prod.outlook.com (2603:10b6:806:385::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Tue, 5 Nov 2024 15:33:34 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::1b) by MN0PR04CA0018.outlook.office365.com (2603:10b6:208:52d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33:33 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:33 +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; Tue, 5 Nov 2024 09:33:30 -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 Subject: [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device Date: Tue, 5 Nov 2024 09:32:58 -0600 Message-ID: <20241105153316.378-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-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: BN2PEPF000055DF:EE_|SA1PR12MB8723:EE_ X-MS-Office365-Filtering-Correlation-Id: dd4a8b8a-9d99-47b2-3b15-08dcfdaf3571 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?CE5KkEPfZoTRfusjwOouQLpQq8roFpC?= =?utf-8?q?d09jRnQyOdn3uz0lsyDnntB7bOMx59B1SVXY306daYbfHvYeNSUH5Oq9uXA/xtb3z?= =?utf-8?q?XRrqSLq5Uh2YJ/qTSUY2/O0/K7+c9PfNlZbQwCJpgHqFqWoEsmX005xMceYmrJkLQ?= =?utf-8?q?pq3CtvSmCX8Rn+jkl893PzMyJ5+E6VvDpYuigU5dZFzsQtuyrFXoz2XMnH0fhePgP?= =?utf-8?q?ajczyIf0Md6ZjMvwYjucda+Rzyo41U4nyPIpg4+/x5V7ziyB/EluRnMJO5c/P1evP?= =?utf-8?q?V4RmB85OGXPfXkONwQ+XVtuGTbXhQtHnliq2rQ4w8PxjgFtAl8X2tJ+yvBnO6NTfP?= =?utf-8?q?zl0ARlltb3kboEGAoXT9yrD3psK5Tx3rMMJBzMt9Fhi1eySaureY1QiioriXdVfW2?= =?utf-8?q?DJ1jPGV9uctOBBfrsO6vQXOFByD0d1y+XZztEbTk99ZI4wBg2fMyX7T4xPtM/cKQM?= =?utf-8?q?L0oCIQkcwcCCr0qrgHQnFvLQdWoRPdp62q8e3GwVsGBO7kGm7zwI0jH5I1aosOEgX?= =?utf-8?q?VawgkqJm7UwF0vIIyyL/37f/ejzvCWWL0RsntYpV+e2+hE64MRGcG39n41gjyt1XP?= =?utf-8?q?FbU1SulSeyWqHJPG+ZlDGhJnlemrJA//T3sRGh7CKX34uY5WbncM68pjv83mIxN6j?= =?utf-8?q?VLr5YxbQRj1YQHvYwK4vgH5Ox3sV9jhmORRJxX70DGnllfZu3wjTojy2DB4sqOU/E?= =?utf-8?q?cioK0YVfBQtA6kfVXIPI42EYCpJSCLbkiO6g/rq2gPSxl6N1v6SNHhMUj1iV0lVI2?= =?utf-8?q?xyh0f1RZlebubOgVbCCiHBML6MrLsa9viSFp8aRmuA1h3bFN0mk50yXwiMqqFX9ju?= =?utf-8?q?74yn9MR4InifOon4TaiLI03oFfKsOYaBft614LmgZRyoZWKO20CZlR/j1gz8A1Qyk?= =?utf-8?q?JTunicbyUHRwvOQ/B2+X57FRx5QTuI1Tb9OU0rMFr7vejaNFr+B+QByHSezeg2qH0?= =?utf-8?q?iV33Vv5KPo6nEVOHkwLTmhsphYTJXHCJVbW70JERbzuxbkJq7ph8d15IVG5c1frS8?= =?utf-8?q?Y0YlgN2VC/kYI0cFRgvYF0WdeWtgn2+cBFLxbFc+gi/tixMLBddL+4fWsfAzjfUga?= =?utf-8?q?xGkA1Jx2Zf84qp0Tc1fkrmI07W5WhnQNLIMjBVmSX8u2+rOH5zt7QzwQCrd+fFmJk?= =?utf-8?q?+NC3ExPeqsoXv0x0SwdRMaeBsWbZcNWIBGztOLKIomrATXaIZHgCFICz4RNmfS2m8?= =?utf-8?q?wGcv8WRO8rD08sqd+NLJq7Q4BerHQTJHyJFOvL9CQ/FHm7OZguICfoKk39HpxcgWC?= =?utf-8?q?rgYUMydoYfuFj1FJprqS2WrDFe3qiQDs6gQpyG5kL6tbmPtF/iCnIlElzj1YHKdGE?= =?utf-8?q?cl0f+wTSgawsSPRMTIbDmFbjdI9dCfsm9g=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)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:33.6703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd4a8b8a-9d99-47b2-3b15-08dcfdaf3571 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8723 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: Ilpo Järvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- 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 #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,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)