From patchwork Sat Nov 9 04:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 842127 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) (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 3FE8F13B58F; Sat, 9 Nov 2024 04:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127347; cv=fail; b=OU4vPXbF1t/c/6KK3k09O90QY8WmAwrdSqCBSjgWg8awSfYWQgSPFIlQcJqwvcKkTXaESf3kjwHKBW8P2JkG+W8kO2SRRExaFzsddIcRkH28eBBPWfZEd35jygA5/c/5fGp1V5SndsPRTL8J8EgjxenpDk3JmpqT6q91t7Soa74= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731127347; c=relaxed/simple; bh=gVOFZQ1NkY8btPf86/D8ZFqsha0+GCMWANbhEBwFGl4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iqjMfeAbJtiEof8fKWdwN7Li8BiT97OKO/E4P0bntBjOt5Es4Bt2lYGF3AOMfLPefdiDTOUWZ/xQ3exu9QkZEKNLjlSJKz8o+WG9gjwQoI25mnaV3fxgvW7d9fhjevAeYb/upJSAnXo11Y9AWP+OcTYeXdF2SEbIU++Ny87Q6uc= 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=gxhR+9EE; arc=fail smtp.client-ip=40.107.220.47 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="gxhR+9EE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=msLyqs/qwJ+t67xCTooBZTO0i1Dj2mNUtFhCphlhcpymURlyCg/5NGdf/cjpQygMoV69hZv6o7B74eAd2J5QzQ1U4izZa+JrBq1q3ajM/vDpY6SLvYVvhODstAujfaTf1m/h7lgW9y2kaXcDfls4gNKqueLvI4sHU9kHot0iO45Y0FtaSvoC85tDdN80aPAB1PdOQad0uMPCqDSEwp38Q+nB93Ua5L7VvM2TlXI8rEe7GiV+IdQMQud3rP2VPOVjVpOh3Y0GmX29WxoMLGnoA06n+rVzXcpM9cNobuG22CyXX6Mj/MnkXm3uj+sv/Z6PXnsuLls0fUz3UkYxnPzw9g== 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=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=Kjn8nX075WczG/ajkATFpyA2YrfBC/rgVYgf7/8auehgG196cnsfqlR6CotHTeJNS1RUTdnjulFG3ZBVJ6+BnXuve7/KW8YJ1DvK+MdHDsiKBJregOk7rjfnbdKR4lSNQCLNnbBcaEmxjO1z7ctpP7pXVUiLHVcgr6HyTs9JJmkd9n2De4mbhxYUw2cChZxCKKxvVOBNwb4/x2JEeuA1ztWi+ch0ZV1H7K8NoHeJ4orc9JwIM9GrPXIJRiNPTb8phk9R9xWqF6FKaX9yVt12jwSasp0ikcL4PfwVrdDfGCtuXsGG9hWKEY+yJ0dbQeXvXMoD/kCQVqpOqTSnteAnxQ== 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=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=gxhR+9EE/24lXBODQeRVvoRJHYhjNi1iwY3YtQq89qmH/hh2VvQ6npfUKlKnL3SzjWVvs+VNeEd6tJi86CxlL8WmTbXVBzCDP2njjrR9ngpbPpzMcD5qXv1rcCZfGTtMpQuDldrds7GyjNObmqGJj5REehwM1sGb74RwD9FnU4E= Received: from SN6PR04CA0079.namprd04.prod.outlook.com (2603:10b6:805:f2::20) by PH8PR12MB6723.namprd12.prod.outlook.com (2603:10b6:510:1ce::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sat, 9 Nov 2024 04:42:21 +0000 Received: from SN1PEPF00026368.namprd02.prod.outlook.com (2603:10b6:805:f2:cafe::ea) by SN6PR04CA0079.outlook.office365.com (2603:10b6:805:f2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21 via Frontend Transport; Sat, 9 Nov 2024 04:42:21 +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 SN1PEPF00026368.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Sat, 9 Nov 2024 04:42:21 +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; Fri, 8 Nov 2024 22:42:19 -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 v6 02/22] platform/x86/dell: dell-pc: Create platform device Date: Fri, 8 Nov 2024 22:41:31 -0600 Message-ID: <20241109044151.29804-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241109044151.29804-1-mario.limonciello@amd.com> References: <20241109044151.29804-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026368:EE_|PH8PR12MB6723:EE_ X-MS-Office365-Filtering-Correlation-Id: f9a8936d-63ad-4755-721b-08dd0078e60d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hobeLkt8zmdEH8jw+DUW9mOOOkFmB9B?= =?utf-8?q?h7RaDB6OXTSo6YQk4Zdvv9eBGGgM9QrsaaJYyi4zaFfEIqGxd80oBdv/sl+C9DmmZ?= =?utf-8?q?lpMwjItboocNZ5QtgbAcnwW2Ki9hAko8vu6wkdyaezX0DreyBwPrB/fT6q/MNZoqC?= =?utf-8?q?xK6D4Mo+6mrHABRkDxUG+tLOGqijF3roloTL8eBTCryBfEARqo9/WuWMemyd78dw9?= =?utf-8?q?BGd99+Ja4R1mIMdbZMyp3vuWkZ5WtUy9DsF/XIzbr4vHcR0bwA+cZQmBNUXnnCpey?= =?utf-8?q?DBYpvA9AQQ8JqYpGZj0lSuUimhkRxdVFqnEFBnXjXMXRHz6qnWjT1BqKPUhceDmCw?= =?utf-8?q?yn8y1bCtyo7+VB3FNqGno3Px8p75rAYBO5JlRcjqJEcSmwfsRbcLki0hRIjaHiXem?= =?utf-8?q?bMU1Wle1SbQ74YuD8hIabPEquxQcsf6yf2vSECj+lbNOKAIEmtT79tv3xDlZmyhrG?= =?utf-8?q?gCDRwT2A0KZvImLIXFBScJZTHfLAvL4jTFnkQF1Y5GWUxzJ5Zb1UgOV1EMS60Yoh7?= =?utf-8?q?SJCr7lIGt7To3qGqJvnzQyRgJqP30HP+qAF81dSpaDY4uFs7Zx6IV9BFcKbPIdO2b?= =?utf-8?q?UaJBAHBURb9xnNv/9Nhq1UhCKichPwSZ1gdg3qz7ZVMg43btp/kQiVpWtzJh/4DwB?= =?utf-8?q?KTQzf3JDdshlc5aP8ChKCvaNiU1edUZgXJZ5gofhCN8xiNMobsWt5sFiicSeEa99r?= =?utf-8?q?E3NO4BPbJAQ4qiKfFB++9XcpPaE0RXkGc2CMIgPKDVWJT3yPNSwoRbEMkcUmTjqvQ?= =?utf-8?q?UZ9Yyh6z2uRB2xa92qNa17tHuFkYyawgPC6ErTI5k+IFg9XhH2/QpwxH6dyfxIHn/?= =?utf-8?q?RJ43OBG+lCPx4C5JP8pvS5K/Tw2PWVMiKsQx3SGPzUQGsORIGXEGodnuN7h2NI10f?= =?utf-8?q?UHq7/ox8Wi4PaQagWuZ6mgYWf8PbXEY8igorNZi/yvMEXFAjm4PMp1RflogYag+P3?= =?utf-8?q?7FflOn0foBwgt6YNSHlSyx96ybrN/wsAKIrjW/LR3ctuLFRyLI/F1Wg/ObwhFHBR6?= =?utf-8?q?nG0IgrWbvH4e5Gu/orHl3pOOueD1r9wUzyz0s/dCGKjK/OCk4YFbr/XEz70Py4qwA?= =?utf-8?q?psC6KeyBOktxYR3zvDHKIVQbCYUcI0OIM7+NYN0EVEuqFR/ZFXmSSLTrGtZyv7A6A?= =?utf-8?q?8ZX6A+Pa4gvCCvKLhSyC0CArsoFqY8i1muBSDBEyr2B76w4DflUQEh6FOQ1C8jfkr?= =?utf-8?q?ZmGK0tLyLro3TnqPGmWJkc41JrOEhHqWjpYC0KrpGfwTjAOrYxpD5fjeKlKPkLGDo?= =?utf-8?q?4dqLHLOFsyWHAU7jKXrlOEfAsboLJ/lPHDqsoNRrSiKz57qo0OAhzAXBvlFMlkyUG?= =?utf-8?q?+V9jRcPQvcl0KQgsQ8CncdQ88VnPu+UuZw=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)(376014)(7416014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2024 04:42:21.1257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9a8936d-63ad-4755-721b-08dd0078e60d 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: SN1PEPF00026368.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6723 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 --- v6: * Use PLATFORM_DEVID_NONE (Armin) 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..805497e44b3a5 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", PLATFORM_DEVID_NONE, 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)